From d65056fb2d967f5b64444da234be2cd2e4a08f7a Mon Sep 17 00:00:00 2001 From: Pierre-Louis Guhur Date: Sat, 26 Nov 2022 15:13:25 +0100 Subject: [PATCH] fix: ballot pages --- components/Advantages.tsx | 48 +++ components/CandidateModal.tsx | 165 ++++++++ components/Experience.tsx | 47 +++ pages/admin/confirm/[pid].tsx | 247 ----------- pages/ballot/[pid]/[[...tid]].tsx | 321 +++++++++++++++ pages/ballot/[pid]/confirm.tsx | 192 +++++++++ pages/index.tsx | 83 +--- pages/vote/[pid]/[[...tid]].tsx | 652 +++--------------------------- public/locales/en/resource.json | 9 +- public/locales/fr/resource.json | 7 +- services/api.ts | 29 +- services/routes.ts | 9 +- 12 files changed, 871 insertions(+), 938 deletions(-) create mode 100644 components/Advantages.tsx create mode 100644 components/CandidateModal.tsx create mode 100644 components/Experience.tsx delete mode 100644 pages/admin/confirm/[pid].tsx create mode 100644 pages/ballot/[pid]/[[...tid]].tsx create mode 100644 pages/ballot/[pid]/confirm.tsx diff --git a/components/Advantages.tsx b/components/Advantages.tsx new file mode 100644 index 0000000..fe6e1c8 --- /dev/null +++ b/components/Advantages.tsx @@ -0,0 +1,48 @@ +import {useTranslation} from 'next-i18next'; +import Image from 'next/image'; +import {Row, Col} from 'reactstrap'; +import ballotBox from '../public/urne.svg'; +import email from '../public/email.svg'; +import respect from '../public/respect.svg'; + +const AdvantagesRow = () => { + const {t} = useTranslation('resource'); + const resources = [ + { + src: ballotBox, + alt: t('home.alt-icon-ballot-box'), + name: t('home.advantage-1-name'), + desc: t('home.advantage-1-desc'), + }, + { + src: email, + alt: t('home.alt-icon-envelop'), + name: t('home.advantage-2-name'), + desc: t('home.advantage-2-desc'), + }, + { + src: respect, + alt: t('home.alt-icon-respect'), + name: t('home.advantage-3-name'), + desc: t('home.advantage-3-desc'), + }, + ]; + return ( + + {resources.map((item, i) => ( + + {item.alt} +

{item.name}

+

{item.desc}

+ + ))} +
+ ); +}; + +export default AdvantagesRow diff --git a/components/CandidateModal.tsx b/components/CandidateModal.tsx new file mode 100644 index 0000000..f67b338 --- /dev/null +++ b/components/CandidateModal.tsx @@ -0,0 +1,165 @@ +/** + * A modal to details a candidate + */ +import {ElectionPayload} from '@services/api'; +import { + Button, + Col, + Container, + Row, + Modal, + ModalHeader, + ModalBody, +} from 'reactstrap'; + +interface CandidateModal { + isOpen: boolean; + toggle: Function; + election: ElectionPayload; +} + +const CandidateModal = ({isOpen, toggle, election}) => +( + < Modal + isOpen={isOpen} + toggle={toggle} + keyboard={true} + className="modalVote voteDesktop" + > +
+ {election.name} + +
+ {election.candidates.map((candidate, candidateId) => { + return ( + + +
{candidate.name}
+
{candidate.description}
+ + + {election.grades.map((grade, gradeId) => { + console.assert(gradeId < numGrades); + const gradeValue = grade.value; + const color = getGradeColor(gradeId, numGrades); + return ( + + + + ); + })} + +
+ ); + })} + + + + {judgments.length !== election.candidates.length ? ( + + ) : ( + + )} + + +
+
+
+