From ad11fe595c63d67ffb9de7f37215aaabea73fa00 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Guhur Date: Fri, 18 Nov 2022 11:32:12 +0100 Subject: [PATCH] fix: can submit --- components/admin/ConfirmField.tsx | 3 ++- components/admin/Grades.tsx | 20 +++++++++++--------- pages/admin/new.tsx | 11 ++++++----- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/components/admin/ConfirmField.tsx b/components/admin/ConfirmField.tsx index 48526ef..fca3eec 100644 --- a/components/admin/ConfirmField.tsx +++ b/components/admin/ConfirmField.tsx @@ -50,6 +50,7 @@ const TitleField = () => { const CandidatesField = () => { const {t} = useTranslation(); const election = useElection(); + return ( @@ -101,7 +102,7 @@ const submitElection = (election: ElectionContextInterface, callback) => { urlResult, ); } - callback(); + callback(payload); } ) } diff --git a/components/admin/Grades.tsx b/components/admin/Grades.tsx index 9bbdb3d..1a1917b 100644 --- a/components/admin/Grades.tsx +++ b/components/admin/Grades.tsx @@ -51,15 +51,17 @@ const Grades = () => { const [endDate, setEndDate] = useState(defaultEndDate); useEffect(() => { - dispatch({ - type: 'set', - field: 'grades', - value: DEFAULT_GRADES.map((g, i) => ({ - name: t(g), - value: i, - active: true, - })), - }); + if (election.grades.length < 2) { + dispatch({ + type: 'set', + field: 'grades', + value: DEFAULT_GRADES.map((g, i) => ({ + name: t(g), + value: i, + active: true, + })), + }); + } }, []); const election = useElection(); diff --git a/pages/admin/new.tsx b/pages/admin/new.tsx index e62997c..0402103 100644 --- a/pages/admin/new.tsx +++ b/pages/admin/new.tsx @@ -34,11 +34,6 @@ const CreateElectionForm = () => { } }; - if (wait) { - return - - - } // at which creation step are we? const [stepId, setStepId] = useState(0); @@ -62,6 +57,12 @@ const CreateElectionForm = () => { throw Error(`Unknown step ${step}`); } + if (wait) { + return + + + } + return (