From 043033075bf3bda0686c6831fce9f2cb7d99a765 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Guhur Date: Wed, 4 Jan 2023 19:23:03 +0100 Subject: [PATCH] fix: ballot --- components/PatternedBackground.tsx | 8 +- components/WaitingBallot.tsx | 139 +++++++++++++++-------------- pages/vote/[pid]/[[...tid]].tsx | 5 +- services/routes.ts | 2 +- styles/scss/_homePage.scss | 2 +- 5 files changed, 79 insertions(+), 77 deletions(-) diff --git a/components/PatternedBackground.tsx b/components/PatternedBackground.tsx index b2a1570..3cce881 100644 --- a/components/PatternedBackground.tsx +++ b/components/PatternedBackground.tsx @@ -1,5 +1,3 @@ - - -export default ({children}) => { - return
{children}
-} +export default ({ children }) => { + return
{children}
; +}; diff --git a/components/WaitingBallot.tsx b/components/WaitingBallot.tsx index 618ae3b..64cff9c 100644 --- a/components/WaitingBallot.tsx +++ b/components/WaitingBallot.tsx @@ -31,9 +31,16 @@ const ButtonResults = ({ election }) => { if (!election.hideResults || isEnded(election.date_end)) { return ( - +
+ +
); } else { @@ -99,13 +106,18 @@ const Thanks = () => { ); }; -interface InfoInterface extends WaitingBallotInterface { - display: string; -} - -const Info = ({ ballot, error, display }: InfoInterface) => { +const Info = ({ ballot, error }: WaitingBallotInterface) => { const { t } = useTranslation(); + const [ballotProperties, setBallot] = useState({ + display: 'none', + }); + + useEffect(() => { + setTimeout(() => { + setBallot({ display: 'grid' }); + }, 4500); + }, []); if (!ballot) return null; if (error) { @@ -115,28 +127,27 @@ const Info = ({ ballot, error, display }: InfoInterface) => { return (
-
+

{t('vote.success-ballot')}

- - - - - - - - -
+ + + + + + +
); }; -export default ({ ballot, error }: WaitingBallotInterface) => { +const AnimationBallot = () => { const [_, dispatch] = useAppContext(); const [urneProperties, setUrne] = useState({ @@ -153,9 +164,6 @@ export default ({ ballot, error }: WaitingBallotInterface) => { const [urneContainerProperties, setUrneContainer] = useState({ height: '100vh', }); - const [ballotProperties, setBallot] = useState({ - display: 'none', - }); useEffect(() => { dispatch({ type: AppTypes.FULLPAGE, value: true }); @@ -166,27 +174,26 @@ export default ({ ballot, error }: WaitingBallotInterface) => { height: 300, })); - const timer = setTimeout(() => { + setTimeout(() => { setStar((star) => ({ ...star, width: 150, height: 150, - marginLeft: 150, + marginLeft: -150, marginBottom: 300, })); }, 1000); - const timer2 = setTimeout(() => { - // setBallot({display: "block"}); + setTimeout(() => { setUrneContainer((urneContainer) => ({ ...urneContainer, - height: '50vh', + height: 250, })); setStar((star) => ({ ...star, width: 100, height: 100, - marginLeft: 100, + marginLeft: -100, marginBottom: 200, })); setUrne((urne) => ({ @@ -195,53 +202,49 @@ export default ({ ballot, error }: WaitingBallotInterface) => { height: 200, })); }, 3000); - - const timer3 = setTimeout(() => { - setBallot({ display: 'grid' }); - }, 4500); - - return () => { - clearTimeout(timer); - clearTimeout(timer2); - clearTimeout(timer3); - }; }, []); return ( - +
-
- urne -
-
- urne -
+ urne +
+
+ urne
- +
+ ); +}; + +export default ({ ballot, error }: WaitingBallotInterface) => { + return ( + + + ); }; diff --git a/pages/vote/[pid]/[[...tid]].tsx b/pages/vote/[pid]/[[...tid]].tsx index 6570a49..069c3cd 100644 --- a/pages/vote/[pid]/[[...tid]].tsx +++ b/pages/vote/[pid]/[[...tid]].tsx @@ -11,6 +11,7 @@ import Logo from '@components/Logo'; import { getUrl, RouteTypes } from '@services/routes'; import { faArrowRight } from '@fortawesome/free-solid-svg-icons'; import { displayRef, getLocaleShort } from '@services/utils'; +import { MAJORITY_JUDGMENT_LINK } from '@services/constants'; export async function getServerSideProps({ query: { pid, tid }, locale }) { return { @@ -63,7 +64,7 @@ const GoToBallotConfirmDesktop = ({ electionRef, token }) => {

{t('home.noAds')}

- + @@ -109,7 +110,7 @@ const GoToBallotConfirmMobile = ({ electionRef, token }) => {

{t('home.noAds')}

- + diff --git a/services/routes.ts b/services/routes.ts index db57538..39ad9b5 100644 --- a/services/routes.ts +++ b/services/routes.ts @@ -27,7 +27,7 @@ export const getUrl = ( const path = `/${locale}/${type}/${displayRef(ref)}/${token}`; return new URL(path, getWindowUrl()); } - const path = `/${locale}/${type}/${ref}`; + const path = `/${locale}/${type}/${displayRef(ref)}`; return new URL(path, getWindowUrl()); } const path = `/${locale}/${type}`; diff --git a/styles/scss/_homePage.scss b/styles/scss/_homePage.scss index 8b01be7..b61ea37 100644 --- a/styles/scss/_homePage.scss +++ b/styles/scss/_homePage.scss @@ -93,7 +93,7 @@ $desktop: 1680px; width: 100%; text-align: center; justify-content: center; - margin-top: 20%; + margin-top: 3em; } .sharing p { margin-right: 15px;