fix: ended election bug

pull/100/head
Pierre-Louis Guhur 1 year ago
parent de08bfa8ef
commit eb5a1b2cc1

@ -1,22 +1,24 @@
import Image from 'next/image';
import Link from 'next/link';
import { useTranslation } from 'next-i18next';
import { getUrl, RouteTypes } from '@services/routes';
import {useTranslation} from 'next-i18next';
import {getUrl, RouteTypes} from '@services/routes';
import logoWithText from '../public/logos/logo.svg';
import logo from '../public/logos/logo-footer.svg';
import { useRouter } from 'next/router';
import {useRouter} from 'next/router';
import {getLocaleShort} from '@services/utils';
interface LogoProps {
title?: boolean;
[props: string]: any;
}
const Logo = ({ title = true, ...props }: LogoProps) => {
const { t } = useTranslation();
const Logo = ({title = true, ...props}: LogoProps) => {
const {t} = useTranslation();
const router = useRouter();
const locale = getLocaleShort(router);
const src = title ? logoWithText : logo;
return (
<Link href={getUrl(RouteTypes.HOME, router).toString()}>
<Link href={getUrl(RouteTypes.HOME, locale).toString()}>
<Image src={src} alt={t('logo.alt')} className="d-block" {...props} />
</Link>
);

@ -1,36 +1,37 @@
import Image from 'next/image';
import { useTranslation } from 'next-i18next';
import { CSSProperties, useEffect, useState } from 'react';
import { faArrowRight } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Col, Container, Row } from 'reactstrap';
import {useTranslation} from 'next-i18next';
import {CSSProperties, useEffect, useState} from 'react';
import {faArrowRight} from '@fortawesome/free-solid-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {Col, Container, Row} from 'reactstrap';
import Button from '@components/Button';
import Share from '@components/Share';
import ErrorMessage from '@components/Error';
import { BallotPayload, ErrorPayload } from '@services/api';
import { AppTypes, useAppContext } from '@services/context';
import { displayRef, isEnded } from '@services/utils';
import { getUrl, RouteTypes } from '@services/routes';
import {BallotPayload, ErrorPayload} from '@services/api';
import {AppTypes, useAppContext} from '@services/context';
import {displayRef, getLocaleShort, isEnded} from '@services/utils';
import {getUrl, RouteTypes} from '@services/routes';
import Logo from './Logo';
import { FORM_FEEDBACK, MAJORITY_JUDGMENT_LINK } from '@services/constants';
import {FORM_FEEDBACK, MAJORITY_JUDGMENT_LINK} from '@services/constants';
import urne from '../public/urne.svg';
import star from '../public/star.svg';
import logo from '../public/logo-red-blue.svg';
import Link from 'next/link';
import { useRouter } from 'next/router';
import {useRouter} from 'next/router';
export interface WaitingBallotInterface {
ballot?: BallotPayload;
error?: ErrorPayload;
}
const ButtonResults = ({ election }) => {
const { t } = useTranslation();
const ButtonResults = ({election}) => {
const {t} = useTranslation();
const router = useRouter();
const locale = getLocaleShort(router);
if (!election.hideResults || isEnded(election.date_end)) {
return (
<Link href={getUrl(RouteTypes.RESULTS, router, election.ref)}>
<Link href={getUrl(RouteTypes.RESULTS, locale, election.ref)}>
<div className="w-100 d-grid">
<Button
color="light"
@ -49,7 +50,7 @@ const ButtonResults = ({ election }) => {
};
const DiscoverMajorityJudgment = () => {
const { t } = useTranslation();
const {t} = useTranslation();
return (
<Col className="d-flex flex-column justify-content-between bg-secondary p-4 text-white">
<div>
@ -71,7 +72,7 @@ const DiscoverMajorityJudgment = () => {
};
const SupportBetterVote = () => {
const { t } = useTranslation();
const {t} = useTranslation();
return (
<Col className="d-flex flex-column justify-content-between text-secondary p-4 bg-white">
<div>
@ -92,7 +93,7 @@ const SupportBetterVote = () => {
};
const Thanks = () => {
const { t } = useTranslation();
const {t} = useTranslation();
return (
<>
<h5>{t('vote.thanks')}</h5>
@ -106,8 +107,8 @@ const Thanks = () => {
);
};
const Info = ({ ballot, error }: WaitingBallotInterface) => {
const { t } = useTranslation();
const Info = ({ballot, error}: WaitingBallotInterface) => {
const {t} = useTranslation();
const [ballotProperties, setBallot] = useState<CSSProperties>({
display: 'none',
@ -115,7 +116,7 @@ const Info = ({ ballot, error }: WaitingBallotInterface) => {
useEffect(() => {
setTimeout(() => {
setBallot({ display: 'grid' });
setBallot({display: 'grid'});
}, 4500);
}, []);
if (!ballot) return null;
@ -166,7 +167,7 @@ const AnimationBallot = () => {
});
useEffect(() => {
dispatch({ type: AppTypes.FULLPAGE, value: true });
dispatch({type: AppTypes.FULLPAGE, value: true});
setUrne((urne) => ({
...urne,
@ -240,7 +241,7 @@ const AnimationBallot = () => {
);
};
export default ({ ballot, error }: WaitingBallotInterface) => {
export default ({ballot, error}: WaitingBallotInterface) => {
return (
<Container className="d-flex min-vh-100 min-vw-100 align-items-between justify-content-center flex-column pb-5">
<AnimationBallot />

@ -1,21 +1,21 @@
import Image from 'next/image';
import { useTranslation } from 'next-i18next';
import { CSSProperties, useEffect, useState } from 'react';
import { faArrowRight } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {useTranslation} from 'next-i18next';
import {CSSProperties, useEffect, useState} from 'react';
import {faArrowRight} from '@fortawesome/free-solid-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import Button from '@components/Button';
import ButtonCopy from '@components/ButtonCopy';
import Share from '@components/Share';
import ErrorMessage from '@components/Error';
import AdminModalEmail from '@components/admin/AdminModalEmail';
import { ElectionCreatedPayload, ErrorPayload } from '@services/api';
import { AppTypes, useAppContext } from '@services/context';
import { getUrl, RouteTypes } from '@services/routes';
import {ElectionCreatedPayload, ErrorPayload} from '@services/api';
import {AppTypes, useAppContext} from '@services/context';
import {getUrl, RouteTypes} from '@services/routes';
import urne from '../public/urne.svg';
import star from '../public/star.svg';
import { Container } from 'reactstrap';
import { useRouter } from 'next/router';
import { getLocaleShort } from '@services/utils';
import {Container} from 'reactstrap';
import {useRouter} from 'next/router';
import {getLocaleShort} from '@services/utils';
export interface WaitingBallotInterface {
election?: ElectionCreatedPayload;
@ -26,8 +26,8 @@ interface InfoElectionInterface extends WaitingBallotInterface {
display: string;
}
const InfoElection = ({ election, error, display }: InfoElectionInterface) => {
const { t } = useTranslation();
const InfoElection = ({election, error, display}: InfoElectionInterface) => {
const {t} = useTranslation();
const router = useRouter();
const [modal, setModal] = useState(false);
@ -35,8 +35,9 @@ const InfoElection = ({ election, error, display }: InfoElectionInterface) => {
if (!election) return null;
const urlVote = getUrl(RouteTypes.VOTE, router, election.ref);
const urlResults = getUrl(RouteTypes.RESULTS, router, election.ref);
const locale = getLocaleShort(router);
const urlVote = getUrl(RouteTypes.VOTE, locale, election.ref);
const urlResults = getUrl(RouteTypes.RESULTS, locale, election.ref);
return (
<div
@ -94,7 +95,7 @@ const InfoElection = ({ election, error, display }: InfoElectionInterface) => {
);
};
export default ({ election, error }: WaitingBallotInterface) => {
export default ({election, error}: WaitingBallotInterface) => {
const [_, dispatch] = useAppContext();
const [urneProperties, setUrne] = useState<CSSProperties>({
@ -116,7 +117,7 @@ export default ({ election, error }: WaitingBallotInterface) => {
});
useEffect(() => {
dispatch({ type: AppTypes.FULLPAGE, value: true });
dispatch({type: AppTypes.FULLPAGE, value: true});
setUrne((urne) => ({
...urne,
@ -155,7 +156,7 @@ export default ({ election, error }: WaitingBallotInterface) => {
}, 3000);
const timer3 = setTimeout(() => {
setElection({ display: 'grid' });
setElection({display: 'grid'});
}, 4500);
return () => {

@ -1,14 +1,14 @@
import { useState } from 'react';
import { Input, Modal, ModalBody, Form } from 'reactstrap';
import { faArrowLeft, faCheck } from '@fortawesome/free-solid-svg-icons';
import { useTranslation } from 'next-i18next';
import {useState} from 'react';
import {Input, Modal, ModalBody, Form} from 'reactstrap';
import {faArrowLeft, faCheck} from '@fortawesome/free-solid-svg-icons';
import {useTranslation} from 'next-i18next';
import Button from '@components/Button';
import ButtonCopy from '@components/ButtonCopy';
import { sendAdminMail, validateMail } from '@services/mail';
import { getUrl, RouteTypes } from '@services/routes';
import { useElection } from '@services/ElectionContext';
import { getLocaleShort } from '@services/utils';
import { useRouter } from 'next/router';
import {sendAdminMail, validateMail} from '@services/mail';
import {getUrl, RouteTypes} from '@services/routes';
import {useElection} from '@services/ElectionContext';
import {getLocaleShort} from '@services/utils';
import {useRouter} from 'next/router';
interface AdminModalEmailInterface {
isOpen: boolean;
@ -23,14 +23,15 @@ const AdminModalEmail = ({
electionRef,
adminToken,
}: AdminModalEmailInterface) => {
const { t } = useTranslation();
const {t} = useTranslation();
const router = useRouter();
const [email, setEmail] = useState(undefined);
const [election, _] = useElection();
const locale = getLocaleShort(router);
const adminUrl =
electionRef && adminToken
? getUrl(RouteTypes.ADMIN, router, electionRef, adminToken)
? getUrl(RouteTypes.ADMIN, locale, electionRef, adminToken)
: null;
const handleEmail = (e) => {

@ -23,6 +23,7 @@ import {GradeItem, CandidateItem} from '@services/type';
import {sendInviteMails} from '@services/mail';
import {AppTypes, useAppContext} from '@services/context';
import {useEffect} from 'react';
import {getLocaleShort} from '@services/utils';
const submitElection = (
election: ElectionContextInterface,
@ -66,10 +67,12 @@ const submitElection = (
) {
throw new Error('Can not send invite emails');
}
const locale = getLocaleShort(router);
const urlVotes = payload.invites.map((token: string) =>
getUrl(RouteTypes.VOTE, router, payload.ref, token)
getUrl(RouteTypes.VOTE, locale, payload.ref, token)
);
const urlResult = getUrl(RouteTypes.RESULTS, router, payload.ref);
const urlResult = getUrl(RouteTypes.RESULTS, locale, payload.ref);
await sendInviteMails(
election.emails,
election.name,

@ -1,21 +1,23 @@
import Link from 'next/link';
import { useRouter } from 'next/router';
import { useTranslation } from 'next-i18next';
import { Button, Row, Col } from 'reactstrap';
import {useRouter} from 'next/router';
import {useTranslation} from 'next-i18next';
import {Button, Row, Col} from 'reactstrap';
import Logo from '@components/Logo';
import LanguageSelector from '@components/layouts/LanguageSelector';
import { useAppContext } from '@services/context';
import {useAppContext} from '@services/context';
import {
MAJORITY_JUDGMENT_LINK,
NEWS_LINK,
PAYPAL,
WHO_WE_ARE_LINK,
} from '@services/constants';
import { getUrl, RouteTypes } from '@services/routes';
import {getUrl, RouteTypes} from '@services/routes';
import {getLocaleShort} from '@services/utils';
const Footer = () => {
const { t } = useTranslation();
const {t} = useTranslation();
const router = useRouter();
const locale = getLocaleShort(router);
const [app, _] = useAppContext();
if (app.fullPage) {
@ -46,7 +48,7 @@ const Footer = () => {
},
{
component: (
<Link href={getUrl(RouteTypes.FAQ, router)}>{t('menu.faq')}</Link>
<Link href={getUrl(RouteTypes.FAQ, locale)}>{t('menu.faq')}</Link>
),
},
{

@ -1,14 +1,14 @@
/* eslint react/prop-types: 0 */
import { useState } from 'react';
import { Collapse, Nav, NavItem, Button } from 'reactstrap';
import {useState} from 'react';
import {Collapse, Nav, NavItem, Button} from 'reactstrap';
import Link from 'next/link';
import Image from 'next/image';
import { useTranslation } from 'next-i18next';
import { useAppContext } from '@services/context';
import {useTranslation} from 'next-i18next';
import {useAppContext} from '@services/context';
import LanguageSelector from './LanguageSelector';
import openMenuIcon from '../../public/open-menu-icon.svg';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faXmark } from '@fortawesome/free-solid-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faXmark} from '@fortawesome/free-solid-svg-icons';
import {
CONTACT_MAIL,
MAJORITY_JUDGMENT_LINK,
@ -17,14 +17,16 @@ import {
WHO_WE_ARE_LINK,
} from '@services/constants';
import ShareRow from '@components/Share';
import { getUrl, RouteTypes } from '@services/routes';
import { useRouter } from 'next/router';
import {getUrl, RouteTypes} from '@services/routes';
import {useRouter} from 'next/router';
import Logo from '@components/Logo';
import {getLocaleShort} from '@services/utils';
const Header = () => {
const [isOpen, setOpen] = useState(false);
const router = useRouter();
const { t } = useTranslation();
const locale = getLocaleShort(router);
const {t} = useTranslation();
const [app, _] = useAppContext();
const toggle = () => setOpen(!isOpen);
@ -61,7 +63,7 @@ const Header = () => {
{
component: (
<Link
href={getUrl(RouteTypes.FAQ, router)}
href={getUrl(RouteTypes.FAQ, locale)}
className="navbar-my-link nav-link"
>
{t('menu.faq')}

@ -1,11 +1,14 @@
const { i18n } = require('./next-i18next.config.js');
// const {i18n} = require('./next-i18next.config.js');
const remoteImage = process.env.IMGPUSH_URL
? process.env.IMGPUSH_URL.split('/')[-1]
: 'imgpush.mieuxvoter.fr';
module.exports = {
i18n,
i18n: {
locales: ['en', 'fr'],
defaultLocale: 'en',
},
images: {
remotePatterns: [
{

258
package-lock.json generated

@ -750,9 +750,9 @@
}
},
"node_modules/@next/env": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.0.5.tgz",
"integrity": "sha512-F3KLtiDrUslAZhTYTh8Zk5ZaavbYwLUn3NYPBnOjAXU8hWm0QVGVzKIOuURQ098ofRU4e9oglf3Sj9pFx5nI5w=="
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.2.4.tgz",
"integrity": "sha512-+Mq3TtpkeeKFZanPturjcXt+KHfKYnLlX6jMLyCrmpq6OOs4i1GqBOAauSkii9QeKCMTYzGppar21JU57b/GEA=="
},
"node_modules/@next/eslint-plugin-next": {
"version": "13.0.1",
@ -763,9 +763,9 @@
}
},
"node_modules/@next/swc-android-arm-eabi": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.0.5.tgz",
"integrity": "sha512-YO691dxHlviy6H0eghgwqn+5kU9J3iQnKERHTDSppqjjGDBl6ab4wz9XfI5AhljjkaTg3TknHoIEWFDoZ4Ve8g==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.2.4.tgz",
"integrity": "sha512-DWlalTSkLjDU11MY11jg17O1gGQzpRccM9Oes2yTqj2DpHndajrXHGxj9HGtJ+idq2k7ImUdJVWS2h2l/EDJOw==",
"cpu": [
"arm"
],
@ -778,9 +778,9 @@
}
},
"node_modules/@next/swc-android-arm64": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.0.5.tgz",
"integrity": "sha512-ugbwffkUmp8cd2afehDC8LtQeFUxElRUBBngfB5UYSWBx18HW4OgzkPFIY8jUBH16zifvGZWXbICXJWDHrOLtw==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.2.4.tgz",
"integrity": "sha512-sRavmUImUCf332Gy+PjIfLkMhiRX1Ez4SI+3vFDRs1N5eXp+uNzjFUK/oLMMOzk6KFSkbiK/3Wt8+dHQR/flNg==",
"cpu": [
"arm64"
],
@ -793,9 +793,9 @@
}
},
"node_modules/@next/swc-darwin-arm64": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.0.5.tgz",
"integrity": "sha512-mshlh8QOtOalfZbc17uNAftWgqHTKnrv6QUwBe+mpGz04eqsSUzVz1JGZEdIkmuDxOz00cK2NPoc+VHDXh99IQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.2.4.tgz",
"integrity": "sha512-S6vBl+OrInP47TM3LlYx65betocKUUlTZDDKzTiRDbsRESeyIkBtZ6Qi5uT2zQs4imqllJznVjFd1bXLx3Aa6A==",
"cpu": [
"arm64"
],
@ -808,9 +808,9 @@
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.0.5.tgz",
"integrity": "sha512-SfigOKW4Z2UB3ruUPyvrlDIkcJq1hiw1wvYApWugD+tQsAkYZKEoz+/8emCmeYZ6Gwgi1WHV+z52Oj8u7bEHPg==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.2.4.tgz",
"integrity": "sha512-a6LBuoYGcFOPGd4o8TPo7wmv5FnMr+Prz+vYHopEDuhDoMSHOnC+v+Ab4D7F0NMZkvQjEJQdJS3rqgFhlZmKlw==",
"cpu": [
"x64"
],
@ -823,9 +823,9 @@
}
},
"node_modules/@next/swc-freebsd-x64": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.0.5.tgz",
"integrity": "sha512-0NJg8HZr4yG8ynmMGFXQf+Mahvq4ZgBmUwSlLXXymgxEQgH17erH/LoR69uITtW+KTsALgk9axEt5AAabM4ucg==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.2.4.tgz",
"integrity": "sha512-kkbzKVZGPaXRBPisoAQkh3xh22r+TD+5HwoC5bOkALraJ0dsOQgSMAvzMXKsN3tMzJUPS0tjtRf1cTzrQ0I5vQ==",
"cpu": [
"x64"
],
@ -838,9 +838,9 @@
}
},
"node_modules/@next/swc-linux-arm-gnueabihf": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.0.5.tgz",
"integrity": "sha512-Cye+h3oDT3NDWjACMlRaolL8fokpKie34FlPj9nfoW7bYKmoMBY1d4IO/GgBF+5xEl7HkH0Ny/qex63vQ0pN+A==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.2.4.tgz",
"integrity": "sha512-7qA1++UY0fjprqtjBZaOA6cas/7GekpjVsZn/0uHvquuITFCdKGFCsKNBx3S0Rpxmx6WYo0GcmhNRM9ru08BGg==",
"cpu": [
"arm"
],
@ -853,9 +853,9 @@
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.0.5.tgz",
"integrity": "sha512-5BfDS/VoRDR5QUGG9oedOCEZGmV2zxUVFYLUJVPMSMeIgqkjxWQBiG2BUHZI6/LGk9yvHmjx7BTvtBCLtRg6IQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.2.4.tgz",
"integrity": "sha512-xzYZdAeq883MwXgcwc72hqo/F/dwUxCukpDOkx/j1HTq/J0wJthMGjinN9wH5bPR98Mfeh1MZJ91WWPnZOedOg==",
"cpu": [
"arm64"
],
@ -868,9 +868,9 @@
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.0.5.tgz",
"integrity": "sha512-xenvqlXz+KxVKAB1YR723gnVNszpsCvKZkiFFaAYqDGJ502YuqU2fwLsaSm/ASRizNcBYeo9HPLTyc3r/9cdMQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.2.4.tgz",
"integrity": "sha512-8rXr3WfmqSiYkb71qzuDP6I6R2T2tpkmf83elDN8z783N9nvTJf2E7eLx86wu2OJCi4T05nuxCsh4IOU3LQ5xw==",
"cpu": [
"arm64"
],
@ -883,9 +883,9 @@
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.0.5.tgz",
"integrity": "sha512-9Ahi1bbdXwhrWQmOyoTod23/hhK05da/FzodiNqd6drrMl1y7+RujoEcU8Dtw3H1mGWB+yuTlWo8B4Iba8hqiQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.2.4.tgz",
"integrity": "sha512-Ngxh51zGSlYJ4EfpKG4LI6WfquulNdtmHg1yuOYlaAr33KyPJp4HeN/tivBnAHcZkoNy0hh/SbwDyCnz5PFJQQ==",
"cpu": [
"x64"
],
@ -898,9 +898,9 @@
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.0.5.tgz",
"integrity": "sha512-V+1mnh49qmS9fOZxVRbzjhBEz9IUGJ7AQ80JPWAYQM5LI4TxfdiF4APLPvJ52rOmNeTqnVz1bbKtVOso+7EZ4w==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.2.4.tgz",
"integrity": "sha512-gOvwIYoSxd+j14LOcvJr+ekd9fwYT1RyMAHOp7znA10+l40wkFiMONPLWiZuHxfRk+Dy7YdNdDh3ImumvL6VwA==",
"cpu": [
"x64"
],
@ -913,9 +913,9 @@
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.0.5.tgz",
"integrity": "sha512-wRE9rkp7I+/3Jf2T9PFIJOKq3adMWYEFkPOA7XAkUfYbQHlDJm/U5cVCWUsKByyQq5RThwufI91sgd19MfxRxg==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.2.4.tgz",
"integrity": "sha512-q3NJzcfClgBm4HvdcnoEncmztxrA5GXqKeiZ/hADvC56pwNALt3ngDC6t6qr1YW9V/EPDxCYeaX4zYxHciW4Dw==",
"cpu": [
"arm64"
],
@ -928,9 +928,9 @@
}
},
"node_modules/@next/swc-win32-ia32-msvc": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.0.5.tgz",
"integrity": "sha512-Q1XQSLEhFuFhkKFdJIGt7cYQ4T3u6P5wrtUNreg5M+7P+fjSiC8+X+Vjcw+oebaacsdl0pWZlK+oACGafush1w==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.2.4.tgz",
"integrity": "sha512-/eZ5ncmHUYtD2fc6EUmAIZlAJnVT2YmxDsKs1Ourx0ttTtvtma/WKlMV5NoUsyOez0f9ExLyOpeCoz5aj+MPXw==",
"cpu": [
"ia32"
],
@ -943,9 +943,9 @@
}
},
"node_modules/@next/swc-win32-x64-msvc": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.0.5.tgz",
"integrity": "sha512-t5gRblrwwiNZP6cT7NkxlgxrFgHWtv9ei5vUraCLgBqzvIsa7X+PnarZUeQCXqz6Jg9JSGGT9j8lvzD97UqeJQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.2.4.tgz",
"integrity": "sha512-0MffFmyv7tBLlji01qc0IaPP/LVExzvj7/R5x1Jph1bTAIj4Vu81yFQWHHQAP6r4ff9Ukj1mBK6MDNVXm7Tcvw==",
"cpu": [
"x64"
],
@ -3575,15 +3575,15 @@
"dev": true
},
"node_modules/next": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/next/-/next-13.0.5.tgz",
"integrity": "sha512-awpc3DkphyKydwCotcBnuKwh6hMqkT5xdiBK4OatJtOZurDPBYLP62jtM2be/4OunpmwIbsS0Eyv+ZGU97ciEg==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/next/-/next-13.2.4.tgz",
"integrity": "sha512-g1I30317cThkEpvzfXujf0O4wtaQHtDCLhlivwlTJ885Ld+eOgcz7r3TGQzeU+cSRoNHtD8tsJgzxVdYojFssw==",
"dependencies": {
"@next/env": "13.0.5",
"@next/env": "13.2.4",
"@swc/helpers": "0.4.14",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
"styled-jsx": "5.1.0"
"styled-jsx": "5.1.1"
},
"bin": {
"next": "dist/bin/next"
@ -3592,21 +3592,22 @@
"node": ">=14.6.0"
},
"optionalDependencies": {
"@next/swc-android-arm-eabi": "13.0.5",
"@next/swc-android-arm64": "13.0.5",
"@next/swc-darwin-arm64": "13.0.5",
"@next/swc-darwin-x64": "13.0.5",
"@next/swc-freebsd-x64": "13.0.5",
"@next/swc-linux-arm-gnueabihf": "13.0.5",
"@next/swc-linux-arm64-gnu": "13.0.5",
"@next/swc-linux-arm64-musl": "13.0.5",
"@next/swc-linux-x64-gnu": "13.0.5",
"@next/swc-linux-x64-musl": "13.0.5",
"@next/swc-win32-arm64-msvc": "13.0.5",
"@next/swc-win32-ia32-msvc": "13.0.5",
"@next/swc-win32-x64-msvc": "13.0.5"
"@next/swc-android-arm-eabi": "13.2.4",
"@next/swc-android-arm64": "13.2.4",
"@next/swc-darwin-arm64": "13.2.4",
"@next/swc-darwin-x64": "13.2.4",
"@next/swc-freebsd-x64": "13.2.4",
"@next/swc-linux-arm-gnueabihf": "13.2.4",
"@next/swc-linux-arm64-gnu": "13.2.4",
"@next/swc-linux-arm64-musl": "13.2.4",
"@next/swc-linux-x64-gnu": "13.2.4",
"@next/swc-linux-x64-musl": "13.2.4",
"@next/swc-win32-arm64-msvc": "13.2.4",
"@next/swc-win32-ia32-msvc": "13.2.4",
"@next/swc-win32-x64-msvc": "13.2.4"
},
"peerDependencies": {
"@opentelemetry/api": "^1.4.0",
"fibers": ">= 3.1.0",
"node-sass": "^6.0.0 || ^7.0.0",
"react": "^18.2.0",
@ -3614,6 +3615,9 @@
"sass": "^1.3.0"
},
"peerDependenciesMeta": {
"@opentelemetry/api": {
"optional": true
},
"fibers": {
"optional": true
},
@ -4516,9 +4520,9 @@
}
},
"node_modules/styled-jsx": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.0.tgz",
"integrity": "sha512-/iHaRJt9U7T+5tp6TRelLnqBqiaIT0HsO0+vgyj8hK2KUk7aejFqRrumqPUlAqDwAj8IbS/1hk3IhBAAK/FCUQ==",
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz",
"integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==",
"dependencies": {
"client-only": "0.0.1"
},
@ -5407,9 +5411,9 @@
}
},
"@next/env": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.0.5.tgz",
"integrity": "sha512-F3KLtiDrUslAZhTYTh8Zk5ZaavbYwLUn3NYPBnOjAXU8hWm0QVGVzKIOuURQ098ofRU4e9oglf3Sj9pFx5nI5w=="
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.2.4.tgz",
"integrity": "sha512-+Mq3TtpkeeKFZanPturjcXt+KHfKYnLlX6jMLyCrmpq6OOs4i1GqBOAauSkii9QeKCMTYzGppar21JU57b/GEA=="
},
"@next/eslint-plugin-next": {
"version": "13.0.1",
@ -5420,81 +5424,81 @@
}
},
"@next/swc-android-arm-eabi": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.0.5.tgz",
"integrity": "sha512-YO691dxHlviy6H0eghgwqn+5kU9J3iQnKERHTDSppqjjGDBl6ab4wz9XfI5AhljjkaTg3TknHoIEWFDoZ4Ve8g==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.2.4.tgz",
"integrity": "sha512-DWlalTSkLjDU11MY11jg17O1gGQzpRccM9Oes2yTqj2DpHndajrXHGxj9HGtJ+idq2k7ImUdJVWS2h2l/EDJOw==",
"optional": true
},
"@next/swc-android-arm64": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.0.5.tgz",
"integrity": "sha512-ugbwffkUmp8cd2afehDC8LtQeFUxElRUBBngfB5UYSWBx18HW4OgzkPFIY8jUBH16zifvGZWXbICXJWDHrOLtw==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.2.4.tgz",
"integrity": "sha512-sRavmUImUCf332Gy+PjIfLkMhiRX1Ez4SI+3vFDRs1N5eXp+uNzjFUK/oLMMOzk6KFSkbiK/3Wt8+dHQR/flNg==",
"optional": true
},
"@next/swc-darwin-arm64": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.0.5.tgz",
"integrity": "sha512-mshlh8QOtOalfZbc17uNAftWgqHTKnrv6QUwBe+mpGz04eqsSUzVz1JGZEdIkmuDxOz00cK2NPoc+VHDXh99IQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.2.4.tgz",
"integrity": "sha512-S6vBl+OrInP47TM3LlYx65betocKUUlTZDDKzTiRDbsRESeyIkBtZ6Qi5uT2zQs4imqllJznVjFd1bXLx3Aa6A==",
"optional": true
},
"@next/swc-darwin-x64": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.0.5.tgz",
"integrity": "sha512-SfigOKW4Z2UB3ruUPyvrlDIkcJq1hiw1wvYApWugD+tQsAkYZKEoz+/8emCmeYZ6Gwgi1WHV+z52Oj8u7bEHPg==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.2.4.tgz",
"integrity": "sha512-a6LBuoYGcFOPGd4o8TPo7wmv5FnMr+Prz+vYHopEDuhDoMSHOnC+v+Ab4D7F0NMZkvQjEJQdJS3rqgFhlZmKlw==",
"optional": true
},
"@next/swc-freebsd-x64": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.0.5.tgz",
"integrity": "sha512-0NJg8HZr4yG8ynmMGFXQf+Mahvq4ZgBmUwSlLXXymgxEQgH17erH/LoR69uITtW+KTsALgk9axEt5AAabM4ucg==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.2.4.tgz",
"integrity": "sha512-kkbzKVZGPaXRBPisoAQkh3xh22r+TD+5HwoC5bOkALraJ0dsOQgSMAvzMXKsN3tMzJUPS0tjtRf1cTzrQ0I5vQ==",
"optional": true
},
"@next/swc-linux-arm-gnueabihf": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.0.5.tgz",
"integrity": "sha512-Cye+h3oDT3NDWjACMlRaolL8fokpKie34FlPj9nfoW7bYKmoMBY1d4IO/GgBF+5xEl7HkH0Ny/qex63vQ0pN+A==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.2.4.tgz",
"integrity": "sha512-7qA1++UY0fjprqtjBZaOA6cas/7GekpjVsZn/0uHvquuITFCdKGFCsKNBx3S0Rpxmx6WYo0GcmhNRM9ru08BGg==",
"optional": true
},
"@next/swc-linux-arm64-gnu": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.0.5.tgz",
"integrity": "sha512-5BfDS/VoRDR5QUGG9oedOCEZGmV2zxUVFYLUJVPMSMeIgqkjxWQBiG2BUHZI6/LGk9yvHmjx7BTvtBCLtRg6IQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.2.4.tgz",
"integrity": "sha512-xzYZdAeq883MwXgcwc72hqo/F/dwUxCukpDOkx/j1HTq/J0wJthMGjinN9wH5bPR98Mfeh1MZJ91WWPnZOedOg==",
"optional": true
},
"@next/swc-linux-arm64-musl": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.0.5.tgz",
"integrity": "sha512-xenvqlXz+KxVKAB1YR723gnVNszpsCvKZkiFFaAYqDGJ502YuqU2fwLsaSm/ASRizNcBYeo9HPLTyc3r/9cdMQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.2.4.tgz",
"integrity": "sha512-8rXr3WfmqSiYkb71qzuDP6I6R2T2tpkmf83elDN8z783N9nvTJf2E7eLx86wu2OJCi4T05nuxCsh4IOU3LQ5xw==",
"optional": true
},
"@next/swc-linux-x64-gnu": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.0.5.tgz",
"integrity": "sha512-9Ahi1bbdXwhrWQmOyoTod23/hhK05da/FzodiNqd6drrMl1y7+RujoEcU8Dtw3H1mGWB+yuTlWo8B4Iba8hqiQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.2.4.tgz",
"integrity": "sha512-Ngxh51zGSlYJ4EfpKG4LI6WfquulNdtmHg1yuOYlaAr33KyPJp4HeN/tivBnAHcZkoNy0hh/SbwDyCnz5PFJQQ==",
"optional": true
},
"@next/swc-linux-x64-musl": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.0.5.tgz",
"integrity": "sha512-V+1mnh49qmS9fOZxVRbzjhBEz9IUGJ7AQ80JPWAYQM5LI4TxfdiF4APLPvJ52rOmNeTqnVz1bbKtVOso+7EZ4w==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.2.4.tgz",
"integrity": "sha512-gOvwIYoSxd+j14LOcvJr+ekd9fwYT1RyMAHOp7znA10+l40wkFiMONPLWiZuHxfRk+Dy7YdNdDh3ImumvL6VwA==",
"optional": true
},
"@next/swc-win32-arm64-msvc": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.0.5.tgz",
"integrity": "sha512-wRE9rkp7I+/3Jf2T9PFIJOKq3adMWYEFkPOA7XAkUfYbQHlDJm/U5cVCWUsKByyQq5RThwufI91sgd19MfxRxg==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.2.4.tgz",
"integrity": "sha512-q3NJzcfClgBm4HvdcnoEncmztxrA5GXqKeiZ/hADvC56pwNALt3ngDC6t6qr1YW9V/EPDxCYeaX4zYxHciW4Dw==",
"optional": true
},
"@next/swc-win32-ia32-msvc": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.0.5.tgz",
"integrity": "sha512-Q1XQSLEhFuFhkKFdJIGt7cYQ4T3u6P5wrtUNreg5M+7P+fjSiC8+X+Vjcw+oebaacsdl0pWZlK+oACGafush1w==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.2.4.tgz",
"integrity": "sha512-/eZ5ncmHUYtD2fc6EUmAIZlAJnVT2YmxDsKs1Ourx0ttTtvtma/WKlMV5NoUsyOez0f9ExLyOpeCoz5aj+MPXw==",
"optional": true
},
"@next/swc-win32-x64-msvc": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.0.5.tgz",
"integrity": "sha512-t5gRblrwwiNZP6cT7NkxlgxrFgHWtv9ei5vUraCLgBqzvIsa7X+PnarZUeQCXqz6Jg9JSGGT9j8lvzD97UqeJQ==",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.2.4.tgz",
"integrity": "sha512-0MffFmyv7tBLlji01qc0IaPP/LVExzvj7/R5x1Jph1bTAIj4Vu81yFQWHHQAP6r4ff9Ukj1mBK6MDNVXm7Tcvw==",
"optional": true
},
"@nicolo-ribaudo/eslint-scope-5-internals": {
@ -7384,28 +7388,28 @@
"dev": true
},
"next": {
"version": "13.0.5",
"resolved": "https://registry.npmjs.org/next/-/next-13.0.5.tgz",
"integrity": "sha512-awpc3DkphyKydwCotcBnuKwh6hMqkT5xdiBK4OatJtOZurDPBYLP62jtM2be/4OunpmwIbsS0Eyv+ZGU97ciEg==",
"requires": {
"@next/env": "13.0.5",
"@next/swc-android-arm-eabi": "13.0.5",
"@next/swc-android-arm64": "13.0.5",
"@next/swc-darwin-arm64": "13.0.5",
"@next/swc-darwin-x64": "13.0.5",
"@next/swc-freebsd-x64": "13.0.5",
"@next/swc-linux-arm-gnueabihf": "13.0.5",
"@next/swc-linux-arm64-gnu": "13.0.5",
"@next/swc-linux-arm64-musl": "13.0.5",
"@next/swc-linux-x64-gnu": "13.0.5",
"@next/swc-linux-x64-musl": "13.0.5",
"@next/swc-win32-arm64-msvc": "13.0.5",
"@next/swc-win32-ia32-msvc": "13.0.5",
"@next/swc-win32-x64-msvc": "13.0.5",
"version": "13.2.4",
"resolved": "https://registry.npmjs.org/next/-/next-13.2.4.tgz",
"integrity": "sha512-g1I30317cThkEpvzfXujf0O4wtaQHtDCLhlivwlTJ885Ld+eOgcz7r3TGQzeU+cSRoNHtD8tsJgzxVdYojFssw==",
"requires": {
"@next/env": "13.2.4",
"@next/swc-android-arm-eabi": "13.2.4",
"@next/swc-android-arm64": "13.2.4",
"@next/swc-darwin-arm64": "13.2.4",
"@next/swc-darwin-x64": "13.2.4",
"@next/swc-freebsd-x64": "13.2.4",
"@next/swc-linux-arm-gnueabihf": "13.2.4",
"@next/swc-linux-arm64-gnu": "13.2.4",
"@next/swc-linux-arm64-musl": "13.2.4",
"@next/swc-linux-x64-gnu": "13.2.4",
"@next/swc-linux-x64-musl": "13.2.4",
"@next/swc-win32-arm64-msvc": "13.2.4",
"@next/swc-win32-ia32-msvc": "13.2.4",
"@next/swc-win32-x64-msvc": "13.2.4",
"@swc/helpers": "0.4.14",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
"styled-jsx": "5.1.0"
"styled-jsx": "5.1.1"
}
},
"next-i18next": {
@ -7997,9 +8001,9 @@
}
},
"styled-jsx": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.0.tgz",
"integrity": "sha512-/iHaRJt9U7T+5tp6TRelLnqBqiaIT0HsO0+vgyj8hK2KUk7aejFqRrumqPUlAqDwAj8IbS/1hk3IhBAAK/FCUQ==",
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz",
"integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==",
"requires": {
"client-only": "0.0.1"
}

@ -39,6 +39,7 @@ import Blur from '@components/Blur';
import {getUrl, RouteTypes} from '@services/routes';
import {sendInviteMails} from '@services/mail';
import {AppTypes, useAppContext} from '@services/context';
import {getLocaleShort} from '@services/utils';
export async function getServerSideProps({query, locale}) {
const {pid, tid: token} = query;
@ -98,11 +99,12 @@ const ManageButtonsMobile = ({handleClosing, waiting}) => {
const {t} = useTranslation();
const [election, _] = useElection();
const router = useRouter();
const locale = getLocaleShort(router);
return (
<>
{!election.restricted && !isClosed(election) && (
<Link href={getUrl(RouteTypes.VOTE, router, election.ref)} className="d-grid">
<Link href={getUrl(RouteTypes.VOTE, locale, election.ref)} className="d-grid">
<Button
icon={faArrowRight}
color="primary"
@ -115,7 +117,7 @@ const ManageButtonsMobile = ({handleClosing, waiting}) => {
)}
{canViewResults(election) && (
<Link href={getUrl(RouteTypes.RESULTS, router, election.ref)} className="d-grid">
<Link href={getUrl(RouteTypes.RESULTS, locale, election.ref)} className="d-grid">
<Button
icon={faSquarePollVertical}
color="primary"
@ -144,6 +146,7 @@ const HeaderRubbonDesktop = ({handleClosing, handleSubmit, waiting}) => {
const {t} = useTranslation();
const [election, _] = useElection();
const router = useRouter();
const locale = getLocaleShort(router);
return (
<div className="w-100 p-4 bg-primary text-white d-flex justify-content-between align-items-center">
@ -161,7 +164,7 @@ const HeaderRubbonDesktop = ({handleClosing, handleSubmit, waiting}) => {
{t('common.save')}
</Button>
{!election.restricted && !isClosed(election) && (
<Link href={getUrl(RouteTypes.VOTE, router, election.ref)}>
<Link href={getUrl(RouteTypes.VOTE, locale, election.ref)}>
<Button
icon={faCheckToSlot}
color="primary"
@ -175,7 +178,7 @@ const HeaderRubbonDesktop = ({handleClosing, handleSubmit, waiting}) => {
)}
{canViewResults(election) && (
<Link href={getUrl(RouteTypes.RESULTS, router, election.ref)}>
<Link href={getUrl(RouteTypes.RESULTS, locale, election.ref)}>
<Button
icon={faSquarePollVertical}
color="primary"
@ -295,12 +298,14 @@ const CreateElection = ({context, token}) => {
if (election.emails.length !== response.invites.length) {
throw new Error('Unexpected number of invites!');
}
const locale = getLocaleShort(router);
const urlVotes = response.invites.map((token: string) =>
getUrl(RouteTypes.VOTE, router, response.ref, token)
getUrl(RouteTypes.VOTE, locale, response.ref, token)
);
const urlResult = getUrl(
RouteTypes.RESULTS,
router,
locale,
response.ref,
token
);
@ -363,10 +368,12 @@ const CreateElection = ({context, token}) => {
if (election.emails.length !== response.invites.length) {
throw new Error('Unexpected number of invites!');
}
const locale = getLocaleShort(router);
const urlVotes = response.invites.map((token: string) =>
getUrl(RouteTypes.VOTE, router, response.ref, token)
getUrl(RouteTypes.VOTE, locale, response.ref, token)
);
const urlResult = getUrl(RouteTypes.RESULTS, router, response.ref);
const urlResult = getUrl(RouteTypes.RESULTS, locale, response.ref);
await sendInviteMails(
election.emails,
election.name,

@ -1,27 +1,29 @@
import Link from 'next/link';
import { useTranslation } from 'next-i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { faArrowRight } from '@fortawesome/free-solid-svg-icons';
import { Container } from 'reactstrap';
import {useTranslation} from 'next-i18next';
import {serverSideTranslations} from 'next-i18next/serverSideTranslations';
import {faArrowRight} from '@fortawesome/free-solid-svg-icons';
import {Container} from 'reactstrap';
import ErrorMessage from '@components/Error';
import { getUrl, RouteTypes } from '@services/routes';
import {getUrl, RouteTypes} from '@services/routes';
import Blur from '@components/Blur';
import Button from '@components/Button';
import { useRouter } from 'next/router';
import {useRouter} from 'next/router';
import {getLocaleShort} from '@services/utils';
export const getServerSideProps = async ({ query: { pid, tid }, locale }) => {
export const getServerSideProps = async ({query: {pid, tid}, locale}) => {
return {
props: {
...(await serverSideTranslations(locale, ['resource'])),
token: tid,
token: tid ? tid : "",
electionRef: pid.replaceAll('-', ''),
},
};
};
const End = ({ electionRef, token }) => {
const { t } = useTranslation();
const End = ({electionRef, token}) => {
const {t} = useTranslation();
const router = useRouter();
const locale = getLocaleShort(router);
return (
<>
@ -31,7 +33,7 @@ const End = ({ electionRef, token }) => {
<Container className="full-height-container">
<Link
className="d-grid w-100 mt-5"
href={getUrl(RouteTypes.RESULTS, router, electionRef, token)}
href={getUrl(RouteTypes.RESULTS, locale, electionRef, token)}
>
<Button
color="secondary"

@ -1,29 +1,31 @@
import { useState } from 'react';
import {useState} from 'react';
import Link from 'next/link';
import Image from 'next/image';
import { GetStaticProps } from 'next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useTranslation } from 'next-i18next';
import { Container, Row, Col, Input } from 'reactstrap';
import {GetStaticProps} from 'next';
import {serverSideTranslations} from 'next-i18next/serverSideTranslations';
import {useTranslation} from 'next-i18next';
import {Container, Row, Col, Input} from 'reactstrap';
import Logo from '@components/Logo';
import Share from '@components/Share';
import AdvantagesRow from '@components/Advantages';
import ExperienceRow from '@components/Experience';
import Button from '@components/Button';
import { getUrl, RouteTypes } from '@services/routes';
import { faArrowRight } from '@fortawesome/free-solid-svg-icons';
import { useRouter } from 'next/router';
import {getUrl, RouteTypes} from '@services/routes';
import {faArrowRight} from '@fortawesome/free-solid-svg-icons';
import {useRouter} from 'next/router';
import {getLocaleShort} from '@services/utils';
export const getStaticProps: GetStaticProps = async ({ locale }) => ({
export const getStaticProps: GetStaticProps = async ({locale}) => ({
props: {
...(await serverSideTranslations(locale, ['resource'])),
},
});
const StartForm = () => {
const { t } = useTranslation('resource');
const {t} = useTranslation('resource');
const [name, setName] = useState(null);
const router = useRouter();
const locale = getLocaleShort(router);
return (
<>
@ -55,9 +57,9 @@ const StartForm = () => {
href={{
pathname: getUrl(
RouteTypes.CREATE_ELECTION,
router
locale
).toString(),
query: { name: name },
query: {name: name},
}}
>
<Button
@ -88,7 +90,7 @@ const StartForm = () => {
<h2 className="d-none d-md-block">{t('home.slogan')}</h2>
<h2
className="d-block d-mg-none text-center"
style={{ fontSize: '32px' }}
style={{fontSize: '32px'}}
>
{t('home.slogan')}
</h2>
@ -109,8 +111,8 @@ const StartForm = () => {
<Link
className="d-grid w-100"
href={{
pathname: getUrl(RouteTypes.CREATE_ELECTION, router).toString(),
query: { name: name },
pathname: getUrl(RouteTypes.CREATE_ELECTION, locale).toString(),
query: {name: name},
}}
>
<Button
@ -131,7 +133,7 @@ const StartForm = () => {
};
const Home = () => {
const { t } = useTranslation('resource');
const {t} = useTranslation('resource');
return (
<>
<div className="bg-primary">

@ -1,25 +1,26 @@
import { Col, Container, Row } from 'reactstrap';
import { useTranslation } from 'next-i18next';
import {Col, Container, Row} from 'reactstrap';
import {useTranslation} from 'next-i18next';
import Link from 'next/link';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { GetStaticProps } from 'next';
import { getLocaleShort } from '@services/utils';
import { getUrl, RouteTypes } from '@services/routes';
import { useRouter } from 'next/router';
import {serverSideTranslations} from 'next-i18next/serverSideTranslations';
import {GetStaticProps} from 'next';
import {getLocaleShort} from '@services/utils';
import {getUrl, RouteTypes} from '@services/routes';
import {useRouter} from 'next/router';
export const getStaticProps: GetStaticProps = async ({ locale }) => ({
export const getStaticProps: GetStaticProps = async ({locale}) => ({
props: {
...(await serverSideTranslations(locale, ['resource'])),
},
});
const PrivacyPolicy = (props) => {
const { t } = useTranslation();
const {t} = useTranslation();
const router = useRouter();
const locale = getLocaleShort(router);
return (
<Container>
<Row>
<Link href={getUrl(RouteTypes.HOME, router)} className="d-block mb-4">
<Link href={getUrl(RouteTypes.HOME, locale)} className="d-block mb-4">
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
</Link>
</Row>

@ -136,7 +136,8 @@ const ResultBanner = ({result}) => {
const numVotes = getNumVotes(result);
const url = getUrl(RouteTypes.RESULTS, router, result.ref);
const locale = getLocaleShort(router);
const url = getUrl(RouteTypes.RESULTS, locale, result.ref);
return (
<>
@ -234,7 +235,8 @@ const BottomButtonsMobile = ({result}) => {
const {t} = useTranslation();
const router = useRouter();
const url = getUrl(RouteTypes.RESULTS, router, result.ref);
const locale = getLocaleShort(router);
const url = getUrl(RouteTypes.RESULTS, locale, result.ref);
return (
<div className="d-flex flex-column align-items-center d-md-none m-3">
@ -295,7 +297,7 @@ const TitleBanner = ({name, electionRef, token}: TitleBannerInterface) => {
</div>
{token ? (
<div className="d-flex">
<Link href={getUrl(RouteTypes.ADMIN, router, electionRef, token)}>
<Link href={getUrl(RouteTypes.ADMIN, locale, electionRef, token)}>
<Button icon={faGear} position="left">
{t('result.go-to-admin')}
</Button>
@ -315,7 +317,7 @@ const TitleBanner = ({name, electionRef, token}: TitleBannerInterface) => {
</div>
{token ? (
<div className="d-flex">
<Link href={getUrl(RouteTypes.ADMIN, router, electionRef, token)}>
<Link href={getUrl(RouteTypes.ADMIN, locale, electionRef, token)}>
<Button icon={faGear} position="left">
{t('result.go-to-admin')}
</Button>
@ -475,9 +477,10 @@ const ResultPage = ({
}: ResultPageInterface) => {
const {t} = useTranslation();
const router = useRouter();
const locale = getLocaleShort(router);
if (err && err.message.startsWith('No votes')) {
const urlVote = getUrl(RouteTypes.VOTE, router, electionRef, token);
const urlVote = getUrl(RouteTypes.VOTE, locale, electionRef, token);
return (
<ErrorMessage>
{
@ -499,7 +502,7 @@ const ResultPage = ({
}
if (err && err.details.startsWith('The election is not closed')) {
const urlVote = getUrl(RouteTypes.VOTE, router, electionRef, token);
const urlVote = getUrl(RouteTypes.VOTE, locale, electionRef, token);
return (
<ErrorMessage>
{

@ -22,7 +22,7 @@ import {
BallotProvider,
} from '@services/BallotContext';
import {getUrl, RouteTypes} from '@services/routes';
import {isEnded} from '@services/utils';
import {getLocaleShort, isEnded} from '@services/utils';
import WaitingBallot from '@components/WaitingBallot';
import PatternedBackground from '@components/PatternedBackground';
import {useRouter} from 'next/router';
@ -46,9 +46,10 @@ export async function getServerSideProps({query: {pid, tid}, locale}) {
}
if (isEnded(election.date_end)) {
const url = getUrl(RouteTypes.ENDED_VOTE, locale, electionRef)
return {
redirect: {
destination: getUrl(RouteTypes.ENDED_VOTE, electionRef),
destination: url.toString(),
permanent: false,
},
};
@ -148,7 +149,8 @@ const VoteBallot = ({election, token, previousBallot}: VoteInterface) => {
};
if (election.restricted) {
const url = getUrl(RouteTypes.RESTRICTED_VOTE, router)
const locale = getLocaleShort(router);
const url = getUrl(RouteTypes.RESTRICTED_VOTE, locale)
router.push(url);
}

@ -1,7 +1,6 @@
/**
* This file provides the paths to the pages
*/
import {NextRouter} from 'next/router';
import {getWindowUrl, displayRef, getLocaleShort} from './utils';
export enum RouteTypes {
@ -18,11 +17,10 @@ export enum RouteTypes {
export const getUrl = (
type: RouteTypes,
router: NextRouter,
locale: string,
ref?: string,
token?: string
): URL => {
const locale = getLocaleShort(router);
if (ref) {
if (token) {

@ -2,10 +2,11 @@
* This file contains several utils functions
*/
import { NextRouter } from 'next/router';
import {NextRouter} from 'next/router';
import {URL_APP} from './constants';
export const getLocaleShort = (router: NextRouter): string => {
console.log("router", router)
if (!router.locale) {
return router.defaultLocale.substring(0, 2);
}
@ -14,7 +15,7 @@ export const getLocaleShort = (router: NextRouter): string => {
};
export const getWindowUrl = (): string => {
if( typeof window !== 'undefined' && window.location.origin)
if (typeof window !== 'undefined' && window.location.origin)
return window.location.origin;
if (process.env.NODE_ENV === 'development')
return "http://localhost:3000";

Loading…
Cancel
Save