📦 NEW: Profil dernières citations proposées
This commit is contained in:
parent
43add978b6
commit
032ef566c7
@ -14,6 +14,7 @@ const Favorites = require('..
|
|||||||
const Functions = require('../models/functions');
|
const Functions = require('../models/functions');
|
||||||
const Categories = require('../models/categories');
|
const Categories = require('../models/categories');
|
||||||
const Comments = require('../models/comments');
|
const Comments = require('../models/comments');
|
||||||
|
const Quotes = require('../models/quotes');
|
||||||
const deleteFilesNameStartWith = require('../assets/utils/deleteFilesNameStartWith');
|
const deleteFilesNameStartWith = require('../assets/utils/deleteFilesNameStartWith');
|
||||||
|
|
||||||
async function handleEditUser(res, { name, email, biography, isPublicEmail }, userId, logoName) {
|
async function handleEditUser(res, { name, email, biography, isPublicEmail }, userId, logoName) {
|
||||||
@ -221,16 +222,18 @@ exports.getUserInfo = async (req, res, next) => {
|
|||||||
where: { userId: user.id },
|
where: { userId: user.id },
|
||||||
include: [
|
include: [
|
||||||
{ model: Functions, attributes: { exclude: ["updatedAt", "utilizationForm", "article", "isOnline"] }, include: { model: Categories, attributes: ["name", "color"] } }
|
{ 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 favoritesArray = favorites.map((favorite) => favorite.function);
|
||||||
const comments = await Comments.findAll({
|
const comments = await Comments.findAll({
|
||||||
limit: 10,
|
|
||||||
where: { userId: user.id },
|
where: { userId: user.id },
|
||||||
include: [
|
include: [
|
||||||
{ model: Functions, attributes: { exclude: ["updatedAt", "utilizationForm", "article", "isOnline"] } }
|
{ model: Functions, attributes: { exclude: ["updatedAt", "utilizationForm", "article", "isOnline"] } }
|
||||||
],
|
],
|
||||||
order: [['createdAt', 'DESC']]
|
order: [['createdAt', 'DESC']],
|
||||||
|
limit: 5
|
||||||
});
|
});
|
||||||
const commentsArray = comments.map((commentObject) => {
|
const commentsArray = comments.map((commentObject) => {
|
||||||
return {
|
return {
|
||||||
@ -240,6 +243,14 @@ exports.getUserInfo = async (req, res, next) => {
|
|||||||
function: commentObject.function.dataValues
|
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 = {
|
const userObject = {
|
||||||
// Si Public Email
|
// Si Public Email
|
||||||
... (user.isPublicEmail) && { email: user.email },
|
... (user.isPublicEmail) && { email: user.email },
|
||||||
@ -249,7 +260,8 @@ exports.getUserInfo = async (req, res, next) => {
|
|||||||
logo: user.logo,
|
logo: user.logo,
|
||||||
createdAt: user.createdAt,
|
createdAt: user.createdAt,
|
||||||
favoritesArray,
|
favoritesArray,
|
||||||
commentsArray
|
commentsArray,
|
||||||
|
quotesArray
|
||||||
};
|
};
|
||||||
return res.status(200).json(userObject);
|
return res.status(200).json(userObject);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -39,7 +39,7 @@ const FunctionCard = forwardRef((props, ref) => {
|
|||||||
<div className="FunctionCard__top">
|
<div className="FunctionCard__top">
|
||||||
<img onLoad={handleLoad} className="FunctionCard__image" alt={props.title} src={API_URL + props.image} />
|
<img onLoad={handleLoad} className="FunctionCard__image" alt={props.title} src={API_URL + props.image} />
|
||||||
<h2 className="FunctionCard__title">{props.title}</h2>
|
<h2 className="FunctionCard__title">{props.title}</h2>
|
||||||
<p className="FunctionCard__description">{props.description}</p>
|
<p className="FunctionCard__description text-center">{props.description}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="FunctionCard__info">
|
<div className="FunctionCard__info">
|
||||||
<p className="FunctionCard__category" style={{ backgroundColor: props.categorie.color }}>{props.categorie.name}</p>
|
<p className="FunctionCard__category" style={{ backgroundColor: props.categorie.color }}>{props.categorie.name}</p>
|
||||||
|
@ -135,28 +135,28 @@ const manageCategories = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="row justify-content-center">
|
<div className="row justify-content-center">
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
<div className="col-24 Admin__table-column">
|
<div className="col-24 table-column">
|
||||||
<table className="Admin__table">
|
<table className="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th className="Admin__table-row Admin__table-head-row" scope="col">id</th>
|
<th className="table-row" scope="col">id</th>
|
||||||
<th className="Admin__table-row Admin__table-head-row" scope="col">name</th>
|
<th className="table-row" scope="col">name</th>
|
||||||
<th className="Admin__table-row Admin__table-head-row" scope="col">color</th>
|
<th className="table-row" scope="col">color</th>
|
||||||
<th className="Admin__table-row Admin__table-head-row" scope="col">createdAt</th>
|
<th className="table-row" scope="col">createdAt</th>
|
||||||
<th className="Admin__table-row Admin__table-head-row" scope="col">updatedAt</th>
|
<th className="table-row" scope="col">updatedAt</th>
|
||||||
<th className="Admin__table-row Admin__table-head-row" scope="col">Modifier</th>
|
<th className="table-row" scope="col">Modifier</th>
|
||||||
<th className="Admin__table-row Admin__table-head-row" scope="col">Supprimer</th>
|
<th className="table-row" scope="col">Supprimer</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{categories.map((category) => {
|
{categories.map((category) => {
|
||||||
return (
|
return (
|
||||||
<tr key={category.id} style={{ backgroundColor: category.color }}>
|
<tr key={category.id} style={{ backgroundColor: category.color }}>
|
||||||
<td className="Admin__table-row">{category.id}</td>
|
<td className="table-row">{category.id}</td>
|
||||||
<td className="Admin__table-row">{category.name}</td>
|
<td className="table-row">{category.name}</td>
|
||||||
<td className="Admin__table-row">{category.color}</td>
|
<td className="table-row">{category.color}</td>
|
||||||
<td className="Admin__table-row">{date.format(new Date(category.createdAt), 'DD/MM/YYYY à HH:mm', true)}</td>
|
<td className="table-row">{date.format(new Date(category.createdAt), 'DD/MM/YYYY à HH:mm', true)}</td>
|
||||||
<td className="Admin__table-row">{date.format(new Date(category.updatedAt), 'DD/MM/YYYY à HH:mm', true)}</td>
|
<td className="table-row">{date.format(new Date(category.updatedAt), 'DD/MM/YYYY à HH:mm', true)}</td>
|
||||||
<td style={{ cursor: 'pointer' }} onClick={() => handleEditCategory({ name: category.name, color: category.color, id: category.id })}>
|
<td style={{ cursor: 'pointer' }} onClick={() => handleEditCategory({ name: category.name, color: category.color, id: category.id })}>
|
||||||
<FontAwesomeIcon icon={faPen} style={{ width: '1.5rem' }} />
|
<FontAwesomeIcon icon={faPen} style={{ width: '1.5rem' }} />
|
||||||
</td>
|
</td>
|
||||||
|
@ -67,32 +67,32 @@ const manageQuotes = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row" style={{ marginBottom: '30px' }}>
|
<div className="row" style={{ marginBottom: '30px' }}>
|
||||||
<div className="col-24 Admin__table-column">
|
<div className="col-24 table-column">
|
||||||
<table className="Admin__table">
|
<table className="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th className="Admin__table-row" scope="col">Citation/Proverbe</th>
|
<th className="table-row" scope="col">Citation/Proverbe</th>
|
||||||
<th className="Admin__table-row" scope="col">Auteur</th>
|
<th className="table-row" scope="col">Auteur</th>
|
||||||
<th className="Admin__table-row" scope="col">Proposée par</th>
|
<th className="table-row" scope="col">Proposée par</th>
|
||||||
<th className="Admin__table-row" scope="col">Valider</th>
|
<th className="table-row" scope="col">Valider</th>
|
||||||
<th className="Admin__table-row" scope="col">Supprimer</th>
|
<th className="table-row" scope="col">Supprimer</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{quotesData.rows.map((currentQuote, index) => {
|
{quotesData.rows.map((currentQuote, index) => {
|
||||||
const quoteJSX = (
|
const quoteJSX = (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<td className="Admin__table-row text-center">{currentQuote.quote}</td>
|
<td className="table-row text-center">{currentQuote.quote}</td>
|
||||||
<td className="Admin__table-row text-center">{currentQuote.author}</td>
|
<td className="table-row text-center">{currentQuote.author}</td>
|
||||||
<td className="Admin__table-row text-center">
|
<td className="table-row text-center">
|
||||||
<Link href={"/profile/[name]"} as={`/profile/${currentQuote.user.name}`}>
|
<Link href={"/profile/[name]"} as={`/profile/${currentQuote.user.name}`}>
|
||||||
<a>{currentQuote.user.name}</a>
|
<a>{currentQuote.user.name}</a>
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td onClick={() => handleValidationQuote(currentQuote.id, true)} className="Admin__table-row text-center" style={{ cursor: 'pointer' }}>
|
<td onClick={() => handleValidationQuote(currentQuote.id, true)} className="table-row text-center" style={{ cursor: 'pointer' }}>
|
||||||
<FontAwesomeIcon icon={faCheck} style={{ width: '1.5rem' }} />
|
<FontAwesomeIcon icon={faCheck} style={{ width: '1.5rem' }} />
|
||||||
</td>
|
</td>
|
||||||
<td onClick={() => handleValidationQuote(currentQuote.id, false)} className="Admin__table-row text-center" style={{ cursor: 'pointer' }}>
|
<td onClick={() => handleValidationQuote(currentQuote.id, false)} className="table-row text-center" style={{ cursor: 'pointer' }}>
|
||||||
<FontAwesomeIcon icon={faTrash} style={{ width: '1.5rem' }} />
|
<FontAwesomeIcon icon={faTrash} style={{ width: '1.5rem' }} />
|
||||||
</td>
|
</td>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
@ -160,7 +160,7 @@ const Profile = (props) => {
|
|||||||
{(props.favoritesArray.length > 0) &&
|
{(props.favoritesArray.length > 0) &&
|
||||||
<div className="row justify-content-center">
|
<div className="row justify-content-center">
|
||||||
<div className="col-24 text-center">
|
<div className="col-24 text-center">
|
||||||
<h2>Fonctions en <span className="important">favoris :</span></h2>
|
<h2>Dernières fonctions ajoutées aux <span className="important">favoris</span> :</h2>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-24">
|
<div className="col-24">
|
||||||
<div className="row justify-content-center">
|
<div className="row justify-content-center">
|
||||||
@ -177,7 +177,7 @@ const Profile = (props) => {
|
|||||||
{(props.commentsArray.length > 0) &&
|
{(props.commentsArray.length > 0) &&
|
||||||
<div className="row justify-content-center">
|
<div className="row justify-content-center">
|
||||||
<div className="col-24 text-center">
|
<div className="col-24 text-center">
|
||||||
<h2>Derniers <span className="important">commentaires :</span></h2>
|
<h2>Derniers <span className="important">commentaires</span> :</h2>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-24 text-center">
|
<div className="col-24 text-center">
|
||||||
{props.commentsArray.map((comment) => (
|
{props.commentsArray.map((comment) => (
|
||||||
@ -197,6 +197,35 @@ const Profile = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{(props.quotesArray.length > 0) &&
|
||||||
|
<div className="row justify-content-center">
|
||||||
|
<div className="col-24 text-center">
|
||||||
|
<h2>Dernières <span className="important">citations</span> proposées (et validées) :</h2>
|
||||||
|
<p>Citations pour la fonction <Link href="/functions/randomQuote"><a>Générateur de citations</a></Link>.</p>
|
||||||
|
</div>
|
||||||
|
<div className="col-24 table-column">
|
||||||
|
<table style={{ marginBottom: '50px' }}>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th className="table-row" scope="col">Citation/Proverbe</th>
|
||||||
|
<th className="table-row" scope="col">Auteur</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{props.quotesArray.map((currentQuote, index) => {
|
||||||
|
return (
|
||||||
|
<tr key={index}>
|
||||||
|
<td className="table-row text-center">{currentQuote.quote}</td>
|
||||||
|
<td className="table-row text-center">{currentQuote.author}</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,4 +217,14 @@ a, .important {
|
|||||||
height: 1rem;
|
height: 1rem;
|
||||||
content: "";
|
content: "";
|
||||||
background: no-repeat 50%/50% 50%;
|
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;
|
||||||
}
|
}
|
@ -37,14 +37,4 @@
|
|||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
white-space: normal !important;
|
white-space: normal !important;
|
||||||
}
|
|
||||||
.table-column {
|
|
||||||
display: grid;
|
|
||||||
}
|
|
||||||
.table, th, td {
|
|
||||||
border: 1px solid var(--text-color);
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
.table-row {
|
|
||||||
padding: 15px;
|
|
||||||
}
|
}
|
@ -20,16 +20,6 @@
|
|||||||
.Admin__Modal-select-option {
|
.Admin__Modal-select-option {
|
||||||
color: rgb(221, 220, 220);
|
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 {
|
.Admin__Function-slide {
|
||||||
margin-top: 40px;
|
margin-top: 40px;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user