+ );
+};
+
+
+export default RestrictedVote;
+
diff --git a/pages/votes/[pid]/[[...tid]].tsx b/pages/votes/[pid]/[[...tid]].tsx
index eebc156..b5f7269 100644
--- a/pages/votes/[pid]/[[...tid]].tsx
+++ b/pages/votes/[pid]/[[...tid]].tsx
@@ -25,6 +25,7 @@ import {getUrl, RouteTypes} from '@services/routes';
import {isEnded} from '@services/utils';
import WaitingBallot from '@components/WaitingBallot';
import PatternedBackground from '@components/PatternedBackground';
+import {useRouter} from 'next/router';
const shuffle = (array) => array.sort(() => Math.random() - 0.5);
@@ -109,6 +110,7 @@ const VoteBallot = ({election, token, previousBallot}: VoteInterface) => {
const {t} = useTranslation();
const [ballot, dispatch] = useBallot();
+ const router = useRouter();
const [voting, setVoting] = useState(false);
const [payload, setPayload] = useState(null);
@@ -145,6 +147,11 @@ const VoteBallot = ({election, token, previousBallot}: VoteInterface) => {
}
};
+ if (election.restricted) {
+ const url = getUrl(RouteTypes.RESTRICTED_VOTE, router)
+ router.push(url);
+ }
+
if (voting) {
return (
diff --git a/public/locales/en/resource.json b/public/locales/en/resource.json
index b800ccb..d1457a3 100644
--- a/public/locales/en/resource.json
+++ b/public/locales/en/resource.json
@@ -64,6 +64,8 @@
"error.not-enough-grades": "Not enough grades",
"error.not-enough-candidates": "Not enough candidates",
"error.uncorrect-name": "The title is incorrect",
+ "error.restricted-election-title": "The election is restricted",
+ "error.restricted-election-desc": "You can only vote if you have been invited.",
"faq.title": "Frequently asked questions",
"faq.sec-1-title": "What is majority judgment?",
"faq.sec-1-desc": "A simple and intuitive principle, which changes everything: the voter votes by giving his/her opinion on all the candidates, by attributing to each one a mention on a scale of values (e.g. Very good, Good, Fair, Insufficient, To be rejected). The candidate with the highest majority rating wins the election (the one with \"the highest majority\" rating).",
diff --git a/public/locales/fr/resource.json b/public/locales/fr/resource.json
index d1b29ed..788e13e 100644
--- a/public/locales/fr/resource.json
+++ b/public/locales/fr/resource.json
@@ -66,6 +66,8 @@
"error.uncorrect-name": "The title is incorrect",
"error.not-enough-grades": "Il manque des mentions",
"error.not-enough-candidates": "Il manque des candidats",
+ "error.restricted-election-title": "L'élection est restreinte",
+ "error.restricted-election-desc": "Vous ne pouvez accéder à cette élection que par une invitation.",
"faq.title": "Foire aux questions",
"faq.sec-1-title": "Qu'est-ce que le jugement majoritaire ?",
"faq.sec-1-desc": "Un principe simple et intuitif, qui change tout : l’électeur vote en donnant son avis sur tous les candidats, en leur attribuant à chacun une mention sur une échelle de valeurs (par exemple. Très bien, Bien, Assez bien, Passable, Insuffisant, À Rejeter). Le candidat le mieux évalué par une majorité remporte l’élection (celui qui obtient la meilleure mention « majoritaire »).",
diff --git a/services/routes.ts b/services/routes.ts
index a67446e..c31d32a 100644
--- a/services/routes.ts
+++ b/services/routes.ts
@@ -1,8 +1,8 @@
/**
* This file provides the paths to the pages
*/
-import { NextRouter } from 'next/router';
-import { getWindowUrl, displayRef, getLocaleShort } from './utils';
+import {NextRouter} from 'next/router';
+import {getWindowUrl, displayRef, getLocaleShort} from './utils';
export enum RouteTypes {
ADMIN = 'admin',
@@ -13,6 +13,7 @@ export enum RouteTypes {
HOME = '',
RESULTS = 'results',
VOTE = 'votes',
+ RESTRICTED_VOTE = 'errors/restricted',
}
export const getUrl = (