From 96f18ead426e90c28a39d5f72134533ee616d06e Mon Sep 17 00:00:00 2001 From: Divlo Date: Mon, 23 Mar 2020 14:42:26 +0100 Subject: [PATCH] =?UTF-8?q?Hotfix=20et=20Mod=C3=A8le=20(backend)=20complet?= =?UTF-8?q?=20d'une=20fonction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controllers/functions.js | 5 ++++- api/models/functions.js | 16 ++++++++++++++-- website/components/FunctionCard/FunctionCard.js | 7 +++++-- website/components/HeadTag.js | 6 ++++++ website/pages/functions/[slug].js | 10 +++++----- website/pages/functions/index.js | 5 ++--- website/pages/index.js | 15 ++++++--------- 7 files changed, 42 insertions(+), 22 deletions(-) diff --git a/api/controllers/functions.js b/api/controllers/functions.js index 7a1985d..11a462c 100644 --- a/api/controllers/functions.js +++ b/api/controllers/functions.js @@ -35,7 +35,10 @@ exports.getFunctions = (req, res, next) => { }, include: [ { model: Categories, attributes: ["name", "color"] } - ] + ], + attributes: { + exclude: ["updatedAt", "utilizationForm", "article", "isOnline"] + } }) .then((result) => { const { count, rows } = result; diff --git a/api/models/functions.js b/api/models/functions.js index 1e0c436..dc3fb6e 100644 --- a/api/models/functions.js +++ b/api/models/functions.js @@ -9,11 +9,11 @@ module.exports = sequelize.define('function', { primaryKey: true }, title: { - type: Sequelize.STRING(255), + type: Sequelize.STRING, allowNull: false, }, slug: { - type: Sequelize.STRING(255), + type: Sequelize.STRING, allowNull: false, }, description: { @@ -24,6 +24,18 @@ module.exports = sequelize.define('function', { type: Sequelize.STRING, allowNull: false }, + type: { + type: Sequelize.STRING, + allowNull: false + }, + article: { + type: Sequelize.TEXT, + allowNull: true + }, + utilizationForm: { + type: Sequelize.JSON, + allowNull: true + }, isOnline: { type: Sequelize.BOOLEAN, allowNull: false, diff --git a/website/components/FunctionCard/FunctionCard.js b/website/components/FunctionCard/FunctionCard.js index 49fd57f..27e4152 100644 --- a/website/components/FunctionCard/FunctionCard.js +++ b/website/components/FunctionCard/FunctionCard.js @@ -2,6 +2,7 @@ import Link from 'next/link'; import { useState, forwardRef } from 'react'; import Loader from '../Loader'; import './FunctionCard.css'; +import { API_URL } from '../../config/config'; const FunctionCard = forwardRef((props, ref) => { @@ -11,9 +12,11 @@ const FunctionCard = forwardRef((props, ref) => { setIsLoading(false); } + const isFormOrArticle = (props.type === 'form' || props.type === 'article'); + return ( {/* FunctionCard a une hauteur pendant chargement */} @@ -23,7 +26,7 @@ const FunctionCard = forwardRef((props, ref) => {
- {props.title} + {props.title}

{props.title}

{props.description}

diff --git a/website/components/HeadTag.js b/website/components/HeadTag.js index e7a6bf3..74fd2aa 100644 --- a/website/components/HeadTag.js +++ b/website/components/HeadTag.js @@ -34,4 +34,10 @@ const HeadTag = ({ title, image, description }) => ( ); +HeadTag.defaultProps = { + title: "FunctionProject", + description: "Apprenez la programmation grâce à l'apprentissage par projet alias fonction.", + image: "/images/FunctionProject_icon_small.png" +} + export default HeadTag; \ No newline at end of file diff --git a/website/pages/functions/[slug].js b/website/pages/functions/[slug].js index ed1b4ac..0ddfa78 100644 --- a/website/pages/functions/[slug].js +++ b/website/pages/functions/[slug].js @@ -5,18 +5,18 @@ import { API_URL } from '../../config/config'; const FunctionComponent = () => { - const router = useRouter(); + const { slug } = useRouter().query; return (
-

{router.query.slug}

+

{slug}

diff --git a/website/pages/functions/index.js b/website/pages/functions/index.js index 68f858a..f876cef 100644 --- a/website/pages/functions/index.js +++ b/website/pages/functions/index.js @@ -3,7 +3,6 @@ import HeadTag from '../../components/HeadTag'; import FunctionCard from '../../components/FunctionCard/FunctionCard'; import Loader from '../../components/Loader'; import '../../public/css/pages/functions.css'; -import { API_URL } from '../../config/config'; import api from '../../config/api'; import useAPI from '../../hooks/useAPI'; @@ -86,9 +85,9 @@ const Functions = () => { {functionsData.rows.map((f, index) => { // Si c'est le dernier élément if (functionsData.rows.length === index + 1) { - return ; + return ; } - return ; + return ; })}
{isLoadingFunctions && } diff --git a/website/pages/index.js b/website/pages/index.js index 40d669b..9f3f797 100644 --- a/website/pages/index.js +++ b/website/pages/index.js @@ -19,21 +19,17 @@ const Home = () => { return ( - +
- + {/* Slide 1 */}

FunctionProject

- Apprenez la programmation grâce à l'apprentissage par projet.
+ Apprenez la programmation grâce à l'apprentissage par projet alias fonction.
Découvrez la liste des fonctions disponibles :

@@ -49,8 +45,9 @@ const Home = () => {

Code Source

- Le partage est essentiel afin de progresser tous ensemble.
- Par conséquent le code source du projet est disponible sur mon profil GitHub : + Le partage est essentiel afin de progresser.
+ Par conséquent chaque fonction a un article expliquant comment elle fonctionne et
+ le code source du projet est disponible sur mon profil GitHub :