From a4220e3acf5e2917bd0423b4ff22dde18aebfe1a Mon Sep 17 00:00:00 2001 From: AlbanSdl Date: Thu, 20 Jun 2024 17:29:28 +0200 Subject: [PATCH 1/4] fix(ues): design --- public/locales/fr/ues.json.ts | 24 ++- src/api/ue/ue.interface.ts | 2 +- src/app/ues/[code]/page.tsx | 220 +++++++++++++++++--------- src/app/ues/[code]/style.module.scss | 99 ++++++++++-- src/components/UI/Tooltip.module.scss | 3 + 5 files changed, 250 insertions(+), 98 deletions(-) diff --git a/public/locales/fr/ues.json.ts b/public/locales/fr/ues.json.ts index 7c172c5..15eda87 100644 --- a/public/locales/fr/ues.json.ts +++ b/public/locales/fr/ues.json.ts @@ -2,7 +2,7 @@ // For more information, check the common.json.ts file export default { - 'browser': 'Guide des UEs', + browser: 'Guide des UEs', 'filter.search': 'Recherche dans le guide des UEs', 'filter.search.title': 'Recherche dans le guide des UEs', 'filter.creditType.title': 'Type de crédits', @@ -12,20 +12,34 @@ export default { 'filter.semester.autumn': 'Automne', 'filter.semester.spring': 'Printemps', 'detailed.inscriptionCode': "Code d'inscription", - 'detailed.workTime': 'Temps de travail', - 'detailed.workTime.project': 'Projet', - 'detailed.semester': "Prochain semestre d'ouverture", + 'detailed.inscriptionCode.copy': 'Copier dans le presse-papier', + 'detailed.worktime.hour': 'h', + 'detailed.worktime.cm': 'CM', + 'detailed.worktime.cm.tooltip': 'Cours Magistral', + 'detailed.worktime.td': 'TD', + 'detailed.worktime.td.tooltip': 'Travaux dirigés', + 'detailed.worktime.tp': 'TP', + 'detailed.worktime.tp.tooltip': 'Travaux pratiques', + 'detailed.worktime.the': 'THE', + 'detailed.worktime.the.tooltip': 'Travail hors encadrement', + 'detailed.worktime.project': 'Projet', + 'detailed.semester': 'Ouvert en', 'detailed.semester.none': "Pas de semestre d'ouverture prévu", 'detailed.description': 'Description', 'detailed.program': 'Programme', 'detailed.objectives': 'Objectifs', - 'detailed.taughtIn': "Langue d'enseignement", + 'detailed.taughtIn': 'Langue', 'detailed.minors': 'Mineurs', + 'detailed.minors.none': 'Cette UE ne compte dans aucun mineur', 'detailed.credits': 'Crédits', 'detailed.noWorkingTimeInfo': 'Aucune information sur le temps de travail', + 'detailed.dfpdata': 'Inscription', 'detailed.branchOptions': 'Niveau', 'detailed.requirements': 'Pré-requis', 'detailed.requirements.none': 'Aucun pré-requis', + 'detailed.rates.title': 'Avis des étudiants', + 'detailed.rates.error': 'Une erreur est survenue lors du chargement des avis', + 'detailed.rates.delete': 'Supprimer mon avis', 'detailed.comments.loginRequired': 'Connexion requise pour voir les commentaires', 'detailed.comments.author.anonymous': 'Anonyme', 'detailed.comments.author.deleted': 'Utilisateur supprimé', diff --git a/src/api/ue/ue.interface.ts b/src/api/ue/ue.interface.ts index 9e487ec..59e2b5c 100644 --- a/src/api/ue/ue.interface.ts +++ b/src/api/ue/ue.interface.ts @@ -3,7 +3,7 @@ export interface UE { inscriptionCode: string; name: string; info: { - requirements: Array<{ code: string }>; + requirements: Array; comment: string; degree: string; languages: string; diff --git a/src/app/ues/[code]/page.tsx b/src/app/ues/[code]/page.tsx index 220bd47..223d651 100644 --- a/src/app/ues/[code]/page.tsx +++ b/src/app/ues/[code]/page.tsx @@ -14,7 +14,7 @@ import doUERate from '@/api/ueRate/doUERate'; import deleteUERate from '@/api/ueRate/deleteUERate'; import StarRating from '@/components/StarRating'; import TextArea from '@/components/UI/TextArea'; -import { useState } from 'react'; +import { ReactNode, useState } from 'react'; import sendComment from '@/api/comment/sendComment'; import { useAPI } from '@/api/api'; import { usePageSettings } from '@/module/pageSettings'; @@ -22,6 +22,8 @@ import useAnnals from '@/api/annals/fetchAnnals'; import useAnnalMetadata from '@/api/annals/fetchMetadata'; import ExamList from '@/components/ues/ExamList'; import ExamSender from '@/components/ues/ExamSender'; +import Tooltip from '@/components/UI/Tooltip'; +import Link from '@/components/UI/Link'; export default function UEDetailsPage() { usePageSettings({}); @@ -37,9 +39,7 @@ export default function UEDetailsPage() { const [isAnnalUploaderOpen, setAnnalUploaderOpen] = useState(false); const api = useAPI(); - if (!ue || !criteria || (!myRates && logged)) { - return false; - } + if (!ue) return false; const onRate = async (criterionId: string, hasAlreadyRated: boolean, rate: number) => { const newRate = await doUERate(api, params.code, criterionId as string, rate).toPromise(); @@ -62,60 +62,128 @@ export default function UEDetailsPage() { refreshUE(); }; + const clipboardCopy = (text: string) => { + navigator.clipboard.writeText(text); + }; + return (
-

{ue.code}

-

{ue.name}

+
+
+

{ue.code}

+

{ue.name}

+
+
+ {ue.workTime ? ( + <> + {ue.workTime.cm && ( +
+
+ {ue.workTime.cm} + {t('ues:detailed.worktime.hour')} +
+ +
{t('ues:detailed.worktime.cm')}
+
+
+ )} + {ue.workTime.td && ( +
+
+ {ue.workTime.td} + {t('ues:detailed.worktime.hour')} +
+ +
{t('ues:detailed.worktime.td')}
+
+
+ )} + {ue.workTime.tp && ( +
+
+ {ue.workTime.tp} + {t('ues:detailed.worktime.hour')} +
+ +
{t('ues:detailed.worktime.tp')}
+
+
+ )} + {ue.workTime.project && ( +
+
+ {ue.workTime.project} + {t('ues:detailed.worktime.hour')} +
+
{t('ues:detailed.worktime.project')}
+
+ )} + {ue.workTime.the && ( +
+
+ {ue.workTime.the} + {t('ues:detailed.worktime.hour')} +
+ +
{t('ues:detailed.worktime.the')}
+
+
+ )} + + ) : ( + t('ues:detailed.noWorkingTimeInfo') + )} +
+
{!isAnnalUploaderOpen ? ( <>
-
-

Informations générales

-

- {t('ues:detailed.description')} : {ue.info.comment} -
- {t('ues:detailed.program')} : {ue.info.program} -
- {t('ues:detailed.objectives')} : {ue.info.objectives} -
- {t('ues:detailed.taughtIn')} : {ue.info.languages} -
- {t('ues:detailed.minors')} : {ue.info.minors} -
- {t('ues:detailed.credits')} :{' '} - {ue.credits.map((credits) => `${credits.credits}${credits.category.code}`).join(', ')} -

-
-
-

{t('ues:detailed.workTime')}

- {ue.workTime ? ( - <> -

CM : {ue.workTime.cm}

-

TD : {ue.workTime.td}

-

TP : {ue.workTime.tp}

-

- {t('ues:detailed.workTime.project')} : {ue.workTime.project} -

-

THE : {ue.workTime.the}

- - ) : ( - t('ues:detailed.noWorkingTimeInfo') - )} +
{t('ues:detailed.description')}
+
{ue.info.comment}
+
{t('ues:detailed.program')}
+
{ue.info.program}
+
{t('ues:detailed.objectives')}
+
{ue.info.objectives}
+
{t('ues:detailed.taughtIn')}
+
{ue.info.languages}
+
{t('ues:detailed.minors')}
+
+ {ue.info.minors || t('ues:detailed.minors.none')}
-
-

Information pour faire l'UE

- {t('ues:detailed.semester')} :{' '} - {ue.openSemester.find((semester) => new Date(semester.start).getTime() > Date.now())?.code ?? - t('ues:detailed.semester.none')}{' '} -
- {t('ues:detailed.inscriptionCode')} : {ue.inscriptionCode}
- {t('ues:detailed.branchOptions')} : {ue.branchOption.map((branchOption) => branchOption.code).toString()}{' '} -
- {t('ues:detailed.requirements')} :{' '} - {ue.info.requirements.length === 0 - ? t('ues:detailed.requirements.none') - : ue.info.requirements.toString()} +
{t('ues:detailed.credits')}
+
{ue.credits.map((credits) => `${credits.credits}${credits.category.code}`).join(', ')}
+
+
+

{t('ues:detailed.dfpdata')}

+
+
{t('ues:detailed.semester')}
+
+ {ue.openSemester.find((semester) => new Date(semester.start).getTime() > Date.now())?.code ?? + t('ues:detailed.semester.none')}{' '} +
+
{t('ues:detailed.inscriptionCode')}
+
+ + clipboardCopy(ue.inscriptionCode)}> + {ue.inscriptionCode} + + +
+
{t('ues:detailed.branchOptions')}
+
{ue.branchOption.map((branchOption) => branchOption.code).join(', ')}
+
{t('ues:detailed.requirements')}
+
+ {ue.info.requirements.length === 0 + ? t('ues:detailed.requirements.none') + : ue.info.requirements + .map((req) => ( + + {req} + + )) + .reduce((prev, curr) => (prev.length ? [...prev, ', ', curr] : [curr]), [] as ReactNode[])} +
-

Avis des étudiants

-
- {Object.entries(ue.starVotes).map(([id, value]) => { - const myRate = myRates?.find((rate) => rate.criterionId === id); - return ( -
-

{criteria.find((criterion): criterion is UERateCriterion => criterion.id === id)?.name}

- - {myRates && ( - <> - onRate(id as string, !!myRate, rate)} - /> - {myRate && ( - +

{t('ues:detailed.rates.title')}

+
c).join(' ')}> + {criteria + ? Object.entries(ue.starVotes).map(([id, value]) => { + const myRate = myRates?.find((rate) => rate.criterionId === id); + return ( +
+

{criteria.find((criterion): criterion is UERateCriterion => criterion.id === id)?.name}

+ + {myRates && ( + <> + onRate(id as string, !!myRate, rate)} + /> + {myRate && ( + + )} + )} - - )} -
- ); - })} +
+ ); + }) + : t('ues:detailed.rates.error')}
{logged ? ( <> diff --git a/src/app/ues/[code]/style.module.scss b/src/app/ues/[code]/style.module.scss index 7438273..79af566 100644 --- a/src/app/ues/[code]/style.module.scss +++ b/src/app/ues/[code]/style.module.scss @@ -1,6 +1,47 @@ @import '@/variables'; .page { + .header { + display: flex; + flex-flow: row nowrap; + gap: 1em; + justify-content: space-between; + + .worktime { + display: flex; + flex-flow: row nowrap; + gap: 0.5rem; + + & > * { + width: 4rem; + display: flex; + flex-flow: column nowrap; + justify-content: center; + align-items: center; + font-weight: bold; + + & > :nth-child(1) { + font-size: 2em; + + span { + font-size: 0.5em; + } + } + + & > :nth-child(2) { + text-transform: uppercase; + color: $ung-light-grey; + } + } + + .noWorkingTimeInfo { + width: auto; + font-style: italic; + color: $ung-light-grey; + } + } + } + h1 { color: $ung-light-blue; font-size: 2.5rem; @@ -20,28 +61,46 @@ margin-top: 10px; } + .info, + .takeUEInfo { + padding: 1rem 0; + } + + .takeUEInfo .info { + grid-template-columns: 20ch 1fr; + + .clipboardCopy { + cursor: pointer; + display: inline-block; + } + } + .info { - display: flex; - gap: 2rem; - justify-content: center; - flex-wrap: wrap; - margin: 5rem 0; - - .generalInfo, - .workTime, - .takeUEInfo { - border: $ung-dark-grey 3px solid; - border-radius: 20px; - padding: 3rem; - - & > h2 { - text-align: center; - margin-bottom: 0.5rem; - } + display: grid; + grid-template-columns: 15ch 1fr; + gap: 8px; + + .empty { + color: $ung-light-grey; + font-style: italic; + } + + & > :nth-child(2n + 1) { + font-weight: bold; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + } + + & > :nth-child(2n) { + text-align: justify; } } .thoughts { + position: relative; + padding: 2rem 0; + & > h2 { margin-bottom: 1rem; color: $ung-light-blue; @@ -53,6 +112,12 @@ gap: 10%; justify-content: center; + &.error { + display: block; + font-style: italic; + color: $ung-light-grey; + } + .criterion { margin-top: 30px; diff --git a/src/components/UI/Tooltip.module.scss b/src/components/UI/Tooltip.module.scss index 83267a7..36fa1f0 100644 --- a/src/components/UI/Tooltip.module.scss +++ b/src/components/UI/Tooltip.module.scss @@ -3,6 +3,7 @@ .tooltipContainer { position: relative; display: inline-block; + cursor: help; & > .tooltip { display: none; @@ -18,6 +19,8 @@ font-weight: bold; color: $light-gray; text-wrap: nowrap; + z-index: 100; + pointer-events: none; &::before { content: ''; From c806c12aa7b79e011d9a0ca227134de1bbb5780c Mon Sep 17 00:00:00 2001 From: AlbanSdl Date: Thu, 20 Jun 2024 22:25:03 +0200 Subject: [PATCH 2/4] fix(ue): add style on replies --- .../ues/[code]/comments/[commentId]/page.tsx | 58 +++++++------- .../comments/[commentId]/style.module.scss | 77 ++++++++++--------- src/icons/Enter.tsx | 14 ++++ src/icons/index.ts | 2 + 4 files changed, 89 insertions(+), 62 deletions(-) create mode 100644 src/icons/Enter.tsx diff --git a/src/app/ues/[code]/comments/[commentId]/page.tsx b/src/app/ues/[code]/comments/[commentId]/page.tsx index aafdd31..a8f436a 100644 --- a/src/app/ues/[code]/comments/[commentId]/page.tsx +++ b/src/app/ues/[code]/comments/[commentId]/page.tsx @@ -14,6 +14,7 @@ import { editCommentReply } from '@/api/commentReply/editCommentReply'; import { useAPI } from '@/api/api'; import { sendCommentReply } from '@/api/commentReply/sendCommentReply'; import { usePageSettings } from '@/module/pageSettings'; +import Enter from '@/icons/Enter'; function CommentEditorFooter(originalComment: string, onUpdate: (text: string) => void, t: TFunction) { return function CommentEditorFooter({ text, disable }: { text: string; disable: () => void }) { @@ -69,32 +70,37 @@ export default function CommentDetailsPage() {
{comment.answers.map((answer, i) => (
-

- {answer.author - ? `${answer.author.firstName} ${answer.author.lastName}` - : t('ues:detailed.comments.author.deleted')} -

-

- {t('ues:detailed.comments.writtenDate', { date: answer.createdAt.toLocaleDateString() })} -

- { - const newAnswer = await editCommentReply(api, answer.id, body).toPromise(); - if (!newAnswer) return false; - setComment({ - ...comment, - answers: [...comment.answers.slice(0, i), newAnswer, ...comment.answers.slice(i + 1)], - }); - return true; - }, - t, - )} - enabled={answer.author.id === user.id} - /> +
+ +
+
+

+ {answer.author + ? `${answer.author.firstName} ${answer.author.lastName}` + : t('ues:detailed.comments.author.deleted')} +

+

+ {t('ues:detailed.comments.writtenDate', { date: answer.createdAt.toLocaleDateString() })} +

+ { + const newAnswer = await editCommentReply(api, answer.id, body).toPromise(); + if (!newAnswer) return false; + setComment({ + ...comment, + answers: [...comment.answers.slice(0, i), newAnswer, ...comment.answers.slice(i + 1)], + }); + return true; + }, + t, + )} + enabled={answer.author.id === user.id} + /> +
))}
diff --git a/src/app/ues/[code]/comments/[commentId]/style.module.scss b/src/app/ues/[code]/comments/[commentId]/style.module.scss index 385db2c..2cffb3f 100644 --- a/src/app/ues/[code]/comments/[commentId]/style.module.scss +++ b/src/app/ues/[code]/comments/[commentId]/style.module.scss @@ -19,56 +19,61 @@ margin-top: 0.3rem; } - .thoughts { + .answerTitle { + margin-top: 3rem; + margin-bottom: 1rem; + color: $ung-dark-grey; + } + + p.body { + text-align: justify; + } + + .comments { + display: flex; + flex-flow: column nowrap; + gap: 1rem; + padding: 1rem 0; + .comment { - margin: 30px 0; + display: flex; + flex-flow: row nowrap; + gap: 1em; + padding: 0 1em; + + .sideIcon { + width: 12px; + height: 12px; + margin-top: 0.5em; + padding: 5px; + box-sizing: content-box; + border-radius: 50%; + border: 1px solid $navigation-item-tooltip-color; + + .answerIcon { + width: 12px; + height: 12px; + color: $ung-light-grey; + transform: scaleY(-1) translateY(25%); + } + } .author { + color: $ung-light-blue; font-weight: bold; - font-size: 1.2rem; - color: $ung-dark-grey; - margin-bottom: 0.2rem; } .date { - font-weight: bold; + font-style: italic; color: $ung-light-grey; } .body { - margin-left: 1rem; - margin-top: 0.5rem; - padding-left: 0.7rem; - position: relative; - - &:after { - content: ''; - position: absolute; - left: 0; - top: 0; - height: 100%; - width: 3px; - background: linear-gradient(90deg, $ung-dark-grey, rgba($ung-dark-grey, 0.5)); - } - - .button { - right: 0; - } - } - - &:last-child { - margin-bottom: 0; - //background-color: red; + text-align: justify; } } } - .answerTitle { - margin-top: 3rem; - margin-bottom: 1rem; - color: $ung-dark-grey; - } - .input { width: 100%; flex-grow: 1; @@ -84,4 +89,4 @@ position: relative; } } -} \ No newline at end of file +} diff --git a/src/icons/Enter.tsx b/src/icons/Enter.tsx new file mode 100644 index 0000000..c70f07d --- /dev/null +++ b/src/icons/Enter.tsx @@ -0,0 +1,14 @@ +export default function Enter({ className }: { className?: string }) { + return ( + + + + + ); +} diff --git a/src/icons/index.ts b/src/icons/index.ts index 559fcdf..69b0a6a 100644 --- a/src/icons/index.ts +++ b/src/icons/index.ts @@ -21,6 +21,7 @@ import CircleCheck from './CircleCheck'; import CircleWarning from './CircleWarning'; import Clock from './Clock'; import Rotate from './Rotate'; +import Enter from './Enter'; const Icons = { Book, @@ -29,6 +30,7 @@ const Icons = { CircleWarning, Clock, Collapse, + Enter, Home, Language, LeftArrow, From 750c9c678278d3cbbfd233a9c882a9518e243cb8 Mon Sep 17 00:00:00 2001 From: AlbanSdl Date: Fri, 21 Jun 2024 00:33:34 +0200 Subject: [PATCH 3/4] fix(ue): update design of answer title --- public/locales/fr/ues.json.ts | 5 +- .../ues/[code]/comments/[commentId]/page.tsx | 58 ++++++++++++------- .../comments/[commentId]/style.module.scss | 15 ++++- src/icons/Comment.tsx | 9 +++ src/icons/index.ts | 2 + 5 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 src/icons/Comment.tsx diff --git a/public/locales/fr/ues.json.ts b/public/locales/fr/ues.json.ts index 15eda87..50b2f1a 100644 --- a/public/locales/fr/ues.json.ts +++ b/public/locales/fr/ues.json.ts @@ -46,10 +46,9 @@ export default { 'detailed.comments.writtenDate': 'Écrit le {{date}}', 'detailed.comments.conversation.see': 'Voir la conversation ({{responseCount}} réponses)', 'detailed.comments.conversation.see.empty': 'Répondre', - 'detailed.comments.resume': - "Commentaire de {{authorFirstName}} {{authorLastName}} sur l'UE {{ue}} au semestre {{semester}} ({{date}})", + 'detailed.comments.resume': "Commentaire sur l'UE {{ue}}", + 'detailed.comments.semester': 'Semestre {{semester}}', 'detailed.comments.updatedAt': 'Mis à jour le {{date}}', - 'detailed.comments.resume.anonymous': "Commentaire anonyme sur l'UE {{ue}} au semestre {{semester}} ({{date}})", 'detailed.comments.answers.answerTitle': 'Répondre dans ce fil de discussion', 'detailed.comments.answers.answerButton': 'Envoyer', 'detailed.comments.answers.answerEntry': 'Tapez votre réponse ici', diff --git a/src/app/ues/[code]/comments/[commentId]/page.tsx b/src/app/ues/[code]/comments/[commentId]/page.tsx index a8f436a..548b2e3 100644 --- a/src/app/ues/[code]/comments/[commentId]/page.tsx +++ b/src/app/ues/[code]/comments/[commentId]/page.tsx @@ -15,6 +15,10 @@ import { useAPI } from '@/api/api'; import { sendCommentReply } from '@/api/commentReply/sendCommentReply'; import { usePageSettings } from '@/module/pageSettings'; import Enter from '@/icons/Enter'; +import User from '@/icons/User'; +import Comment from '@/icons/Comment'; +import Clock from '@/icons/Clock'; +import Link from '@/components/UI/Link'; function CommentEditorFooter(originalComment: string, onUpdate: (text: string) => void, t: TFunction) { return function CommentEditorFooter({ text, disable }: { text: string; disable: () => void }) { @@ -47,25 +51,33 @@ export default function CommentDetailsPage() { return (

- {comment.isAnonymous - ? t('ues:detailed.comments.resume.anonymous', { - ue: ue.code, - semester: comment.semester.code, - date: comment.createdAt.toLocaleDateString(), - }) - : t('ues:detailed.comments.resume', { - authorFirstName: comment.author.firstName, - authorLastName: comment.author.lastName, - ue: ue.code, - semester: comment.semester.code, - date: comment.createdAt.toLocaleDateString(), - })} + {t('ues:detailed.comments.resume', { + ue: ue.code, + })}

- {comment.updatedAt && ( -

- {t('ues:detailed.comments.updatedAt', { date: comment.updatedAt.toLocaleDateString() })} -

- )} +
+ {!comment.isAnonymous && ( +
+ + + {comment.author.firstName} {comment.author.lastName} + +
+ )} +
+ + {t('ues:detailed.comments.semester', { semester: comment.semester.code })} +
+
+ +
+
{t('ues:detailed.comments.writtenDate', { date: comment.createdAt.toLocaleDateString() })}
+ {comment.updatedAt && ( +
{t('ues:detailed.comments.updatedAt', { date: comment.updatedAt.toLocaleDateString() })}
+ )} +
+
+

{comment.body}

{comment.answers.map((answer, i) => ( @@ -75,9 +87,13 @@ export default function CommentDetailsPage() {

- {answer.author - ? `${answer.author.firstName} ${answer.author.lastName}` - : t('ues:detailed.comments.author.deleted')} + {answer.author ? ( + + {answer.author.firstName} {answer.author.lastName} + + ) : ( + t('ues:detailed.comments.author.deleted') + )}

{t('ues:detailed.comments.writtenDate', { date: answer.createdAt.toLocaleDateString() })} diff --git a/src/app/ues/[code]/comments/[commentId]/style.module.scss b/src/app/ues/[code]/comments/[commentId]/style.module.scss index 2cffb3f..71b5401 100644 --- a/src/app/ues/[code]/comments/[commentId]/style.module.scss +++ b/src/app/ues/[code]/comments/[commentId]/style.module.scss @@ -9,8 +9,19 @@ color: $ung-light-blue; } - & > .body { - margin-top: 1.5rem; + .meta { + margin: 1rem 0; + + svg { + width: 1em; + height: 1.1em; + vertical-align: bottom; + } + & > * { + display: flex; + flex-flow: row nowrap; + gap: 5px; + } } .updateDate { diff --git a/src/icons/Comment.tsx b/src/icons/Comment.tsx new file mode 100644 index 0000000..b670680 --- /dev/null +++ b/src/icons/Comment.tsx @@ -0,0 +1,9 @@ +import React from 'react'; + +export default function Comment() { + return ( + + + + ); +} diff --git a/src/icons/index.ts b/src/icons/index.ts index 69b0a6a..e9a0277 100644 --- a/src/icons/index.ts +++ b/src/icons/index.ts @@ -22,6 +22,7 @@ import CircleWarning from './CircleWarning'; import Clock from './Clock'; import Rotate from './Rotate'; import Enter from './Enter'; +import Comment from './Comment'; const Icons = { Book, @@ -30,6 +31,7 @@ const Icons = { CircleWarning, Clock, Collapse, + Comment, Enter, Home, Language, From 2a325dbaf7a19a54fb658e86e7c6f997996960c2 Mon Sep 17 00:00:00 2001 From: AlbanSdl Date: Fri, 21 Jun 2024 00:47:53 +0200 Subject: [PATCH 4/4] fix(ue): hide rating section when user has no rights --- src/app/ues/[code]/page.tsx | 92 ++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/src/app/ues/[code]/page.tsx b/src/app/ues/[code]/page.tsx index 223d651..04c2824 100644 --- a/src/app/ues/[code]/page.tsx +++ b/src/app/ues/[code]/page.tsx @@ -24,12 +24,14 @@ import ExamList from '@/components/ues/ExamList'; import ExamSender from '@/components/ues/ExamSender'; import Tooltip from '@/components/UI/Tooltip'; import Link from '@/components/UI/Link'; +import { UserType } from '@/module/user'; export default function UEDetailsPage() { usePageSettings({}); const params = useParams<{ code: string }>(); const { t } = useAppTranslation(); const logged = useAppSelector((state) => state.session.logged); + const type = useAppSelector((state) => state.user?.type); const [ue, refreshUE] = useUE(params.code as string); const criteria = useUERateCriteria(); const [myRates, setMyRates] = useGetRate(params.code); @@ -192,50 +194,54 @@ export default function UEDetailsPage() { annalSemesters={annalSemesters} annalTypes={annalTypes} /> -

-

{t('ues:detailed.rates.title')}

-
c).join(' ')}> - {criteria - ? Object.entries(ue.starVotes).map(([id, value]) => { - const myRate = myRates?.find((rate) => rate.criterionId === id); - return ( -
-

{criteria.find((criterion): criterion is UERateCriterion => criterion.id === id)?.name}

- - {myRates && ( - <> - onRate(id as string, !!myRate, rate)} - /> - {myRate && ( - - )} - - )} -
- ); - }) - : t('ues:detailed.rates.error')} + {logged && (type === UserType.STUDENT || type === UserType.FORMER_STUDENT) && ( +
+

{t('ues:detailed.rates.title')}

+
c).join(' ')}> + {criteria && ue.starVotes + ? Object.entries(ue.starVotes).map(([id, value]) => { + const myRate = myRates?.find((rate) => rate.criterionId === id); + return ( +
+

+ {criteria.find((criterion): criterion is UERateCriterion => criterion.id === id)?.name} +

+ + {myRates && ( + <> + onRate(id as string, !!myRate, rate)} + /> + {myRate && ( + + )} + + )} +
+ ); + }) + : t('ues:detailed.rates.error')} +
+ {logged && (type === UserType.STUDENT || type === UserType.FORMER_STUDENT) ? ( + <> +
+ {t('ues:detailed.comments.write')} +