From 032ef566c7e4d1eca1d67899eb486bdf0b146442 Mon Sep 17 00:00:00 2001 From: Divlo Date: Wed, 22 Apr 2020 22:01:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20Profil=20derni=C3=A8res?= =?UTF-8?q?=20citations=20propos=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controllers/users.js | 20 ++++++++--- .../components/FunctionCard/FunctionCard.js | 2 +- website/pages/admin/manageCategories.js | 28 ++++++++-------- website/pages/admin/manageQuotes.js | 24 +++++++------- website/pages/profile/[name].js | 33 +++++++++++++++++-- website/public/css/general.css | 10 ++++++ .../public/css/pages/FunctionComponent.css | 10 ------ website/public/css/pages/admin.css | 10 ------ 8 files changed, 84 insertions(+), 53 deletions(-) diff --git a/api/controllers/users.js b/api/controllers/users.js index 80b8747..df08d58 100644 --- a/api/controllers/users.js +++ b/api/controllers/users.js @@ -14,6 +14,7 @@ const Favorites = require('.. const Functions = require('../models/functions'); const Categories = require('../models/categories'); const Comments = require('../models/comments'); +const Quotes = require('../models/quotes'); const deleteFilesNameStartWith = require('../assets/utils/deleteFilesNameStartWith'); async function handleEditUser(res, { name, email, biography, isPublicEmail }, userId, logoName) { @@ -221,16 +222,18 @@ exports.getUserInfo = async (req, res, next) => { where: { userId: user.id }, include: [ { model: Functions, attributes: { exclude: ["updatedAt", "utilizationForm", "article", "isOnline"] }, include: { model: Categories, attributes: ["name", "color"] } } - ] + ], + order: [['createdAt', 'DESC']], + limit: 5 }); const favoritesArray = favorites.map((favorite) => favorite.function); const comments = await Comments.findAll({ - limit: 10, where: { userId: user.id }, include: [ { model: Functions, attributes: { exclude: ["updatedAt", "utilizationForm", "article", "isOnline"] } } ], - order: [['createdAt', 'DESC']] + order: [['createdAt', 'DESC']], + limit: 5 }); const commentsArray = comments.map((commentObject) => { return { @@ -240,6 +243,14 @@ exports.getUserInfo = async (req, res, next) => { function: commentObject.function.dataValues }; }); + const quotesArray = await Quotes.findAll({ + where: { userId: user.id }, + attributes: { + exclude: ["updatedAt", "createdAt", "isValidated", "userId", "id"] + }, + order: [['createdAt', 'DESC']], + limit: 5, + }); const userObject = { // Si Public Email ... (user.isPublicEmail) && { email: user.email }, @@ -249,7 +260,8 @@ exports.getUserInfo = async (req, res, next) => { logo: user.logo, createdAt: user.createdAt, favoritesArray, - commentsArray + commentsArray, + quotesArray }; return res.status(200).json(userObject); } catch (error) { diff --git a/website/components/FunctionCard/FunctionCard.js b/website/components/FunctionCard/FunctionCard.js index b3575e5..2856bce 100644 --- a/website/components/FunctionCard/FunctionCard.js +++ b/website/components/FunctionCard/FunctionCard.js @@ -39,7 +39,7 @@ const FunctionCard = forwardRef((props, ref) => {
{props.title}

{props.title}

-

{props.description}

+

{props.description}

{props.categorie.name}

diff --git a/website/pages/admin/manageCategories.js b/website/pages/admin/manageCategories.js index 6e01c84..4d535fd 100644 --- a/website/pages/admin/manageCategories.js +++ b/website/pages/admin/manageCategories.js @@ -135,28 +135,28 @@ const manageCategories = (props) => {
-
- +
+
- - - - - - - + + + + + + + {categories.map((category) => { return ( - - - - - + + + + + diff --git a/website/pages/admin/manageQuotes.js b/website/pages/admin/manageQuotes.js index 997998d..5b8aefd 100644 --- a/website/pages/admin/manageQuotes.js +++ b/website/pages/admin/manageQuotes.js @@ -67,32 +67,32 @@ const manageQuotes = (props) => {
-
-
idnamecolorcreatedAtupdatedAtModifierSupprimeridnamecolorcreatedAtupdatedAtModifierSupprimer
{category.id}{category.name}{category.color}{date.format(new Date(category.createdAt), 'DD/MM/YYYY à HH:mm', true)}{date.format(new Date(category.updatedAt), 'DD/MM/YYYY à HH:mm', true)}{category.id}{category.name}{category.color}{date.format(new Date(category.createdAt), 'DD/MM/YYYY à HH:mm', true)}{date.format(new Date(category.updatedAt), 'DD/MM/YYYY à HH:mm', true)} handleEditCategory({ name: category.name, color: category.color, id: category.id })}>
+
+
- - - - - + + + + + {quotesData.rows.map((currentQuote, index) => { const quoteJSX = ( - - - + + - - diff --git a/website/pages/profile/[name].js b/website/pages/profile/[name].js index 609f363..0d1982f 100644 --- a/website/pages/profile/[name].js +++ b/website/pages/profile/[name].js @@ -160,7 +160,7 @@ const Profile = (props) => { {(props.favoritesArray.length > 0) &&
-

Fonctions en favoris :

+

Dernières fonctions ajoutées aux favoris :

@@ -177,7 +177,7 @@ const Profile = (props) => { {(props.commentsArray.length > 0) &&
-

Derniers commentaires :

+

Derniers commentaires :

{props.commentsArray.map((comment) => ( @@ -197,6 +197,35 @@ const Profile = (props) => {
} + + {(props.quotesArray.length > 0) && +
+
+

Dernières citations proposées (et validées) :

+

Citations pour la fonction Générateur de citations.

+
+
+
Citation/ProverbeAuteurProposée parValiderSupprimerCitation/ProverbeAuteurProposée parValiderSupprimer
{currentQuote.quote}{currentQuote.author} + {currentQuote.quote}{currentQuote.author} {currentQuote.user.name} handleValidationQuote(currentQuote.id, true)} className="Admin__table-row text-center" style={{ cursor: 'pointer' }}> + handleValidationQuote(currentQuote.id, true)} className="table-row text-center" style={{ cursor: 'pointer' }}> handleValidationQuote(currentQuote.id, false)} className="Admin__table-row text-center" style={{ cursor: 'pointer' }}> + handleValidationQuote(currentQuote.id, false)} className="table-row text-center" style={{ cursor: 'pointer' }}>
+ + + + + + + + {props.quotesArray.map((currentQuote, index) => { + return ( + + + + + ); + })} + +
Citation/ProverbeAuteur
{currentQuote.quote}{currentQuote.author}
+
+
+ }
} diff --git a/website/public/css/general.css b/website/public/css/general.css index 29883cf..b73a206 100644 --- a/website/public/css/general.css +++ b/website/public/css/general.css @@ -217,4 +217,14 @@ a, .important { height: 1rem; content: ""; background: no-repeat 50%/50% 50%; +} +.table-column { + display: grid; +} +.table, th, td { + border: 1px solid var(--text-color); + border-collapse: collapse; +} +.table-row { + padding: 15px; } \ No newline at end of file diff --git a/website/public/css/pages/FunctionComponent.css b/website/public/css/pages/FunctionComponent.css index d3cb12e..aeb5235 100644 --- a/website/public/css/pages/FunctionComponent.css +++ b/website/public/css/pages/FunctionComponent.css @@ -37,14 +37,4 @@ border-radius: 10px; overflow: auto; white-space: normal !important; -} -.table-column { - display: grid; -} -.table, th, td { - border: 1px solid var(--text-color); - border-collapse: collapse; -} -.table-row { - padding: 15px; } \ No newline at end of file diff --git a/website/public/css/pages/admin.css b/website/public/css/pages/admin.css index eeab827..fe7e810 100644 --- a/website/public/css/pages/admin.css +++ b/website/public/css/pages/admin.css @@ -20,16 +20,6 @@ .Admin__Modal-select-option { color: rgb(221, 220, 220); } -.Admin__table-column { - display: grid; -} -.Admin__table, th, td { - border: 1px solid var(--text-color); - border-collapse: collapse; -} -.Admin__table-row { - padding: 15px; -} .Admin__Function-slide { margin-top: 40px; }