fix: compatibility issues with recent packages

legacy
Pierre-Louis Guhur 1 year ago
parent 2a86c0d3f8
commit 4e772f2044

@ -44,7 +44,7 @@ const CopyField = (props) => {
className="btn btn-success"
type="button"
>
<FontAwesomeIcon icon={iconOpen} className="mr-2" />
<FontAwesomeIcon icon={iconOpen} className="me-2" />
{t("Go")}
</Button>
*/}
@ -53,7 +53,7 @@ const CopyField = (props) => {
onClick={handleClickOnButton}
type="button"
>
<FontAwesomeIcon icon={iconCopy} className="mr-2" />
<FontAwesomeIcon icon={iconCopy} className="me-2" />
{t("Copy")}
</Button>
</div>

@ -1,16 +1,14 @@
import Link from "next/link";
import { Container, Row, Col } from "reactstrap";
import { useTranslation } from "next-i18next";
import {Container, Row, Col} from "reactstrap";
import {useTranslation} from "next-i18next";
const Error = (props) => {
const { t } = useTranslation();
const {t} = useTranslation();
return (
<Container>
<Row>
<Link href="/">
<a className="d-block ml-auto mr-auto mb-4">
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
</a>
<Link href="/" className="d-block ms-auto me-auto mb-4">
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
</Link>
</Row>
<Row className="mt-4">
@ -19,12 +17,10 @@ const Error = (props) => {
</Col>
</Row>
<Row className="mt-4">
<Col className="text-right mr-4">
<Link href="/">
<a className="btn btn-secondary">{t("common.backHomepage")}</a>
</Link>
<Col className="text-right me-4">
<Link href="/" className="btn btn-secondary">{t("common.backHomepage")}</Link>
</Col>
<Col className="text-left ml-4">
<Col className="text-left ms-4">
<a
href="mailto:app@mieuxvoter.fr?subject=[HELP]"
className="btn btn-success"

@ -18,7 +18,7 @@ const Facebook = props => {
};
return (
<button className={props.className} onClick={handleClick} type="button">
<FontAwesomeIcon icon={faFacebookSquare} className="mr-2" />
<FontAwesomeIcon icon={faFacebookSquare} className="me-2" />
{props.text}
</button>
);

@ -12,7 +12,7 @@ const Gform = (props) => {
target="_blank"
rel="noopener noreferrer"
>
<FontAwesomeIcon icon={faCommentAlt} className="mr-2" />
<FontAwesomeIcon icon={faCommentAlt} className="me-2" />
Votre avis nous intéresse !
</a>
);

@ -30,7 +30,7 @@ const Paypal = () => {
title={t("PayPal - The safer, easier way to pay online!")}
>
{" "}
<FontAwesomeIcon icon={faPaypal} className="mr-2" />
<FontAwesomeIcon icon={faPaypal} className="me-2" />
{t("Support us !")}
</button>
<input type="hidden" name="cmd" value="_s-xclick" />

@ -1,24 +1,15 @@
import { useState } from "react";
import ButtonWithConfirm from "./ButtonWithConfirm";
import { Row, Col, Input, InputGroup, InputGroupAddon } from "reactstrap";
import { useTranslation } from "react-i18next";
import {Row, Col, Input, InputGroup, InputGroupAddon} from "reactstrap";
import {useTranslation} from "react-i18next";
import HelpButton from "@components/form/HelpButton";
const DragHandle = ({ children }) => (
<span className="input-group-text indexNumber">{children}</span>
);
const CandidateField = ({ label, candIndex, onDelete, ...inputProps }) => {
const { t } = useTranslation();
const CandidateField = ({label, candIndex, onDelete, ...inputProps}) => {
const {t} = useTranslation();
return (
<Row>
<Col>
<InputGroup>
<InputGroupAddon addonType="prepend">
<DragHandle>
<span>{candIndex + 1}</span>
</DragHandle>
</InputGroupAddon>
<Input
type="text"
value={label}
@ -35,7 +26,7 @@ const CandidateField = ({ label, candIndex, onDelete, ...inputProps }) => {
></ButtonWithConfirm>
</InputGroup>
</Col>
<Col xs="auto" className="align-self-center pl-0">
<Col xs="auto" className="align-self-center ps-0">
<HelpButton>
{t(
"Enter the name of your candidate or proposal here (250 characters max.)"

@ -1,27 +1,24 @@
import { useState, useEffect, createRef } from "react";
import { useTranslation } from "react-i18next";
import { Button, Card, CardBody } from "reactstrap";
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {useState, useEffect, createRef} from "react";
import {useTranslation} from "react-i18next";
import {Button, Card, CardBody} from "reactstrap";
import {faPlus} from "@fortawesome/free-solid-svg-icons";
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import CandidateField from "./CandidateField";
const SortableItem = ({ className, ...childProps }) => (
const SortableItem = ({className, ...childProps}) => (
<li className={className}>
<CandidateField {...childProps} />
</li>
);
const SortableContainer = ({ children }) => {
return <ul className="sortable">{children}</ul>;
};
const CandidatesField = ({ onChange }) => {
const { t } = useTranslation();
const CandidatesField = ({onChange}) => {
const {t} = useTranslation();
const [candidates, setCandidates] = useState([]);
const addCandidate = () => {
if (candidates.length < 1000) {
candidates.push({ label: "", fieldRef: createRef() });
candidates.push({label: "", fieldRef: createRef()});
setCandidates([...candidates]);
onChange(candidates);
} else {
@ -37,8 +34,8 @@ const CandidatesField = ({ onChange }) => {
const removeCandidate = (index) => {
if (candidates.length === 1) {
const newCandidates = [];
newCandidates.push({ label: "", fieldRef: createRef() });
newCandidates.push({ label: "", fieldRef: createRef() });
newCandidates.push({label: "", fieldRef: createRef()});
newCandidates.push({label: "", fieldRef: createRef()});
setCandidates(newCandidates);
onChange(newCandidates);
} else {
@ -65,20 +62,15 @@ const CandidatesField = ({ onChange }) => {
}
};
const onSortEnd = ({ oldIndex, newIndex }) => {
setCandidates(candidates, oldIndex, newIndex);
};
return (
<>
<SortableContainer onSortEnd={onSortEnd}>
<ul className="sortable">
{candidates.map((candidate, index) => {
const className = "sortable";
return (
<SortableItem
className={className}
key={`item-${index}`}
index={index}
candIndex={index}
label={candidate.label}
onDelete={() => removeCandidate(index)}
@ -88,7 +80,7 @@ const CandidatesField = ({ onChange }) => {
/>
);
})}
</SortableContainer>
</ul>
<Button
color="secondary"
@ -97,7 +89,7 @@ const CandidatesField = ({ onChange }) => {
type="button"
onClick={addCandidate}
>
<FontAwesomeIcon icon={faPlus} className="mr-2" />
<FontAwesomeIcon icon={faPlus} className="me-2" />
{t("Add a proposal")}
</Button>
</>

@ -20,7 +20,7 @@ const ConfirmModal = ({tabIndex, title, candidates, grades, isTimeLimited, start
onClick={toggle}
tabIndex={tabIndex}
>
<FontAwesomeIcon icon={faCheck} className="mr-2" />
<FontAwesomeIcon icon={faCheck} className="me-2" />
{t("Validate")}
</button>
<Modal
@ -33,15 +33,15 @@ const ConfirmModal = ({tabIndex, title, candidates, grades, isTimeLimited, start
</ModalHeader>
<ModalBody>
<div className="mt-1 mb-1">
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
<div className="text-white bg-primary p-2 ps-3 pe-3 rounded">
{t("Question of the election")}
</div>
<div className="p-2 pl-3 pr-3 bg-light mb-3">{title}</div>
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
<div className="p-2 ps-3 pe-3 bg-light mb-3">{title}</div>
<div className="text-white bg-primary p-2 ps-3 pe-3 rounded">
{t("Candidates/Proposals")}
</div>
<div className="p-2 pl-3 pr-3 bg-light mb-3">
<ul className="m-0 pl-4">
<div className="p-2 ps-3 pe-3 bg-light mb-3">
<ul className="m-0 ps-4">
{candidates.map((candidate, i) => {
if (candidate.label !== "") {
return (
@ -56,10 +56,10 @@ const ConfirmModal = ({tabIndex, title, candidates, grades, isTimeLimited, start
</ul>
</div>
<div className={(isTimeLimited ? "d-block " : "d-none")} >
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
<div className="text-white bg-primary p-2 ps-3 pe-3 rounded">
{t("Dates")}
</div>
<div className="p-2 pl-3 pr-3 bg-light mb-3">
<div className="p-2 ps-3 pe-3 bg-light mb-3">
{t("The election will take place from")}{" "}
<b>
{start.toLocaleDateString()}, {t("at")}{" "}
@ -72,15 +72,15 @@ const ConfirmModal = ({tabIndex, title, candidates, grades, isTimeLimited, start
</b>
</div>
</div>
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
<div className="text-white bg-primary p-2 ps-3 pe-3 rounded">
{t("Grades")}
</div>
<div className="p-2 pl-3 pr-3 bg-light mb-3">
<div className="p-2 ps-3 pe-3 bg-light mb-3">
{grades.map((mention, i) => {
return i < grades.length ? (
<span
key={i}
className="badge badge-light mr-2 mt-2"
className="badge badge-light me-2 mt-2"
style={{
backgroundColor: mention.color,
color: "#fff"
@ -93,10 +93,10 @@ const ConfirmModal = ({tabIndex, title, candidates, grades, isTimeLimited, start
);
})}
</div>
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
<div className="text-white bg-primary p-2 ps-3 pe-3 rounded">
{t("Voters' list")}
</div>
<div className="p-2 pl-3 pr-3 bg-light mb-3">
<div className="p-2 ps-3 pe-3 bg-light mb-3">
{emails.length > 0 ? (
emails.join(", ")
) : (
@ -117,7 +117,7 @@ const ConfirmModal = ({tabIndex, title, candidates, grades, isTimeLimited, start
<h6 className="m-0 p-0">
<FontAwesomeIcon
icon={faExclamationTriangle}
className="mr-2"
className="me-2"
/>
<u>{t("Results available at the close of the vote")}</u>
</h6>

@ -20,31 +20,27 @@ const Header = () => {
<Head><title>{t("title")}</title></Head>
<header>
<Navbar color="light" light expand="md">
<Link href="/">
<a className="navbar-brand">
<div className="d-flex flex-row">
<div className="align-self-center">
<img src="/logos/logo-color.svg" alt="logo" height="32" />
</div>
<div className="align-self-center ml-2">
<div className="logo-text">
<h1>
{t("Voting platform")}
<small>{t("Majority Judgment")}</small>
</h1>
</div>
<Link href="/" className="navbar-brand">
<div className="d-flex flex-row">
<div className="align-self-center">
<img src="/logos/logo-color.svg" alt="logo" height="32" />
</div>
<div className="align-self-center ms-2">
<div className="logo-text">
<h1>
{t("Voting platform")}
<small>{t("Majority Judgment")}</small>
</h1>
</div>
</div>
</a>
</div>
</Link>
<NavbarToggler onClick={toggle} />
<Collapse isOpen={isOpen} navbar>
<Nav className="ml-auto" navbar>
<Nav className="ms-auto" navbar>
<NavItem>
<Link href="/new/">
<a className="text-primary nav-link"> <FontAwesomeIcon icon={faRocket} className="mr-2" />
{t("Start an election")}
</a>
<Link href="/new/" className="text-primary nav-link"> <FontAwesomeIcon icon={faRocket} className="me-2" />
{t("Start an election")}
</Link>
</NavItem>
<NavItem style={{width: "80px"}}>

@ -1,22 +1,22 @@
import Link from "next/link";
import { Container, Row, Col } from "reactstrap";
import { useTranslation } from "next-i18next";
import {Container, Row, Col} from "reactstrap";
import {useTranslation} from "next-i18next";
import Paypal from "@components/banner/Paypal";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import {serverSideTranslations} from "next-i18next/serverSideTranslations";
import config from "../next-i18next.config.js";
export const getStaticProps = async ({ locale }) => ({
export const getStaticProps = async ({locale}) => ({
props: {
...(await serverSideTranslations(locale, [], config)),
...(await serverSideTranslations(locale, ["resource", "common", "locale"])),
},
});
const FAQ = (props) => {
const { t } = useTranslation();
const {t} = useTranslation();
return (
<Container>
<Row>
<Link href="/" className="d-block ml-auto mr-auto mb-4">
<Link href="/" className="d-block ms-auto me-auto mb-4">
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
</Link>
</Row>
@ -37,7 +37,7 @@ const FAQ = (props) => {
lélectorat (celui qui obtient la meilleure mention « majoritaire
»).
</p>
<div style={{ maxWidth: "445px" }}>
<div style={{maxWidth: "445px"}}>
<video width="100%" height="250" controls="controls">
<source
src="/video/Le_Jugement_Majoritaire_en_1_minute.mp4"

@ -1,22 +1,21 @@
import { useState } from "react";
import {useState} from "react";
import Head from "next/head";
import Link from "next/link";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useTranslation } from "next-i18next";
import { Container, Row, Col, Button, Input } from "reactstrap";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faRocket } from "@fortawesome/free-solid-svg-icons";
import config from "../next-i18next.config.js";
import {serverSideTranslations} from "next-i18next/serverSideTranslations";
import {useTranslation} from "next-i18next";
import {Container, Row, Col, Button, Input} from "reactstrap";
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faRocket} from "@fortawesome/free-solid-svg-icons";
export const getStaticProps = async ({ locale }) => ({
export const getStaticProps = async ({locale}) => ({
props: {
...(await serverSideTranslations(locale, [], config)),
...(await serverSideTranslations(locale, ["resource", "common", "locale"])),
},
});
const Home = () => {
const [title, setTitle] = useState(null);
const { t } = useTranslation();
const {t} = useTranslation();
return (
<Container>
<form autoComplete="off">
@ -25,7 +24,7 @@ const Home = () => {
src="logos/logo-line-white.svg"
alt="logo of Mieux Voter"
height="128"
className="d-block ml-auto mr-auto mb-4"
className="d-block ms-auto me-auto mb-4"
/>
</Row>
<Row>
@ -47,12 +46,12 @@ const Home = () => {
/>
</Col>
<Col xs="12" md="3" xl="2">
<Link href={{ pathname: "/new/", query: { title: title } }}>
<Link href={{pathname: "/new/", query: {title: title}}}>
<Button
type="submit"
className="btn btn-block btn-secondary mt-2"
>
<FontAwesomeIcon icon={faRocket} className="mr-2" />
<FontAwesomeIcon icon={faRocket} className="me-2" />
{t("resource.start")}
</Button>
</Link>

@ -1,21 +1,20 @@
import Link from "next/link";
import { Container, Row, Col } from "reactstrap";
import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import config from "../next-i18next.config.js";
import {Container, Row, Col} from "reactstrap";
import {useTranslation} from "next-i18next";
import {serverSideTranslations} from "next-i18next/serverSideTranslations";
export const getStaticProps = async ({ locale }) => ({
export const getStaticProps = async ({locale}) => ({
props: {
...(await serverSideTranslations(locale, [], config)),
...(await serverSideTranslations(locale, ["resource", "common", "locale"])),
},
});
const LegalNotices = (props) => {
const { t } = useTranslation();
const {t} = useTranslation();
return (
<Container>
<Row>
<Link href="/" className="d-block ml-auto mr-auto mb-4">
<Link href="/" className="d-block ms-auto me-auto mb-4">
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
</Link>
</Row>

@ -1,14 +1,14 @@
import { createRef } from "react";
import {createRef} from "react";
import Head from "next/head";
import { useRouter } from "next/router";
import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import {useRouter} from "next/router";
import {useTranslation} from "next-i18next";
import {serverSideTranslations} from "next-i18next/serverSideTranslations";
import {
getDetails,
apiErrors,
ELECTION_NOT_STARTED_ERROR,
} from "@services/api";
import { Col, Container, Row } from "reactstrap";
import {Col, Container, Row} from "reactstrap";
import Link from "next/link";
import {
faCopy,
@ -17,27 +17,26 @@ import {
faExternalLinkAlt,
faPollH,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import CopyField from "@components/CopyField";
import Error from "@components/Error";
import Facebook from "@components/banner/Facebook";
import config from "../../../next-i18next.config.js";
export async function getServerSideProps({ query: { pid }, locale }) {
export async function getServerSideProps({query: {pid}, locale}) {
let [details, translations] = await Promise.all([
getDetails(pid),
serverSideTranslations(locale, [], config),
serverSideTranslations(locale, ["resource", "common", "locale"]),
]);
if (details.includes(ELECTION_NOT_STARTED_ERROR)) {
details = { title: "", on_invitation_only: true, restrict_results: true };
details = {title: "", on_invitation_only: true, restrict_results: true};
} else {
if (typeof details === "string" || details instanceof String) {
return { props: { err: details, ...translations } };
return {props: {err: details, ...translations}};
}
if (!details.title) {
return { props: { err: "Unknown error", ...translations } };
return {props: {err: "Unknown error", ...translations}};
}
}
@ -59,7 +58,7 @@ const ConfirmElection = ({
pid,
err,
}) => {
const { t } = useTranslation();
const {t} = useTranslation();
if (err) {
return <Error value={apiErrors(err, t)} />;
@ -102,12 +101,10 @@ const ConfirmElection = ({
const participate = invitationOnly ? null : (
<>
<Col className="col-lg-3 text-center mr-10">
<Link href={`/vote/${pid}`}>
<a target="_blank" rel="noreferrer" className="btn btn-success">
<FontAwesomeIcon icon={faVoteYea} className="mr-2" />
{t("resource.participateBtn")}
</a>
<Col className="col-lg-3 text-center me-10">
<Link href={`/vote/${pid}`} target="_blank" rel="noreferrer" className="btn btn-success">
<FontAwesomeIcon icon={faVoteYea} className="me-2" />
{t("resource.participateBtn")}
</Link>
</Col>
</>
@ -137,7 +134,7 @@ const ConfirmElection = ({
<Col className="offset-lg-3" lg="6">
<h3 className="mb-3 text-center">{title}</h3>
<h5 className="mb-3 text-center">
<FontAwesomeIcon icon={faExclamationTriangle} className="mr-2" />
<FontAwesomeIcon icon={faExclamationTriangle} className="me-2" />
{t("Keep these links carefully")}
</h5>
<div className="border rounded p-4 pb-5">
@ -156,11 +153,9 @@ const ConfirmElection = ({
<Row className="mt-4 mb-4 justify-content-md-center">
{participate}
<Col className="text-center col-lg-3">
<Link href={`/result/${pid}`}>
<a target="_blank" rel="noreferrer" className="btn btn-secondary">
<FontAwesomeIcon icon={faPollH} className="mr-2" />
{t("resource.resultsBtn")}
</a>
<Link href={`/result/${pid}`} target="_blank" rel="noreferrer" className="btn btn-secondary">
<FontAwesomeIcon icon={faPollH} className="me-2" />
{t("resource.resultsBtn")}
</Link>
</Col>
</Row>

@ -1,8 +1,8 @@
import { useState, useEffect } from "react";
import {useState, useEffect} from "react";
import Head from "next/head";
import { useRouter } from "next/router";
import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import {useRouter} from "next/router";
import {useTranslation} from "next-i18next";
import {serverSideTranslations} from "next-i18next/serverSideTranslations";
import {
Collapse,
Container,
@ -10,33 +10,23 @@ import {
Col,
Input,
Label,
InputGroup,
InputGroupAddon,
Button,
Card,
CardBody,
} from "reactstrap";
import { ReactMultiEmail, isEmail } from "react-multi-email";
// import "react-multi-email/style.css";
import { toast, ToastContainer } from "react-toastify";
// import "react-toastify/dist/ReactToastify.css";
import queryString from "query-string";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {ReactMultiEmail, isEmail} from "react-multi-email";
import {toast, ToastContainer} from "react-toastify";
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {
faPlus,
faTrashAlt,
faCheck,
faCogs,
faExclamationTriangle,
} from "@fortawesome/free-solid-svg-icons";
import { useAppContext } from "@services/context";
import { createElection } from "@services/api";
import { translateGrades } from "@services/grades";
import {createElection} from "@services/api";
import {translateGrades} from "@services/grades";
import HelpButton from "@components/form/HelpButton";
import Loader from "@components/wait";
import CandidatesField from "@components/form/CandidatesField";
import ConfirmModal from "@components/form/ConfirmModal";
import config from "../../next-i18next.config.js";
// Error messages
const AT_LEAST_2_CANDIDATES_ERROR = "Please add at least 2 candidates.";
@ -76,19 +66,19 @@ const displayClockOptions = () =>
</option>
));
export const getStaticProps = async ({ locale }) => ({
export const getStaticProps = async ({locale}) => ({
props: {
...(await serverSideTranslations(locale, [], config)),
...(await serverSideTranslations(locale, ["resource", "common", "locale"])),
},
});
const CreateElection = (props) => {
const { t } = useTranslation();
const {t} = useTranslation();
// default value : start at the last hour
const now = new Date();
const [title, setTitle] = useState("");
const [candidates, setCandidates] = useState([{ label: "" }, { label: "" }]);
const [candidates, setCandidates] = useState([{label: ""}, {label: ""}]);
const [numGrades, setNumGrades] = useState(5);
const [waiting, setWaiting] = useState(false);
const [isAdvancedOptionsOpen, setAdvancedOptionsOpen] = useState(false);
@ -107,7 +97,7 @@ const CreateElection = (props) => {
useEffect(() => {
if (!router.isReady) return;
const { title: urlTitle } = router.query;
const {title: urlTitle} = router.query;
setTitle(urlTitle || "");
}, [router.isReady]);
@ -123,16 +113,9 @@ const CreateElection = (props) => {
setAdvancedOptionsOpen(!isAdvancedOptionsOpen);
};
const addCandidate = () => {
if (candidates.length < 1000) {
candidates.push({ label: "" });
setCandidates(candidates);
}
};
const checkFields = () => {
if (!candidates) {
return { ok: false, msg: AT_LEAST_2_CANDIDATES_ERROR };
return {ok: false, msg: AT_LEAST_2_CANDIDATES_ERROR};
}
let numCandidates = 0;
@ -140,14 +123,14 @@ const CreateElection = (props) => {
if (c.label !== "") numCandidates += 1;
});
if (numCandidates < 2) {
return { ok: false, msg: AT_LEAST_2_CANDIDATES_ERROR };
return {ok: false, msg: AT_LEAST_2_CANDIDATES_ERROR};
}
if (!title || title === "") {
return { ok: false, msg: NO_TITLE_ERROR };
return {ok: false, msg: NO_TITLE_ERROR};
}
return { ok: true, msg: "OK" };
return {ok: true, msg: "OK"};
};
const handleSubmit = () => {
@ -365,7 +348,7 @@ const CreateElection = (props) => {
setStart(
new Date(
timeMinusDate(start) +
new Date(e.target.valueAsNumber).getTime()
new Date(e.target.valueAsNumber).getTime()
)
);
}}
@ -379,7 +362,7 @@ const CreateElection = (props) => {
setStart(
new Date(
dateMinusTime(start).getTime() +
e.target.value * 3600000
e.target.value * 3600000
)
)
}
@ -403,7 +386,7 @@ const CreateElection = (props) => {
setFinish(
new Date(
timeMinusDate(finish) +
new Date(e.target.valueAsNumber).getTime()
new Date(e.target.valueAsNumber).getTime()
)
);
}}
@ -417,7 +400,7 @@ const CreateElection = (props) => {
setFinish(
new Date(
dateMinusTime(finish).getTime() +
e.target.value * 3600000
e.target.value * 3600000
)
)
}

@ -1,21 +1,20 @@
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 config from "../next-i18next.config.js";
import {serverSideTranslations} from "next-i18next/serverSideTranslations";
export const getStaticProps = async ({ locale }) => ({
export const getStaticProps = async ({locale}) => ({
props: {
...(await serverSideTranslations(locale, [], config)),
...(await serverSideTranslations(locale, ["resource", "common", "locale"])),
},
});
const PrivacyPolicy = (props) => {
const { t } = useTranslation();
const {t} = useTranslation();
return (
<Container>
<Row>
<Link href="/" className="d-block ml-auto mr-auto mb-4">
<Link href="/" className="d-block ms-auto me-auto mb-4">
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
</Link>
</Row>

@ -1,8 +1,8 @@
import { useState } from "react";
import {useState} from "react";
import Head from "next/head";
import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useRouter } from "next/router";
import {useTranslation} from "next-i18next";
import {serverSideTranslations} from "next-i18next/serverSideTranslations";
import {useRouter} from "next/router";
import {
Container,
Row,
@ -13,32 +13,30 @@ import {
CardBody,
Table,
} from "reactstrap";
import { getResults, getDetails, apiErrors } from "@services/api";
import { grades } from "@services/grades";
import { translateGrades } from "@services/grades";
import {getResults, getDetails, apiErrors} from "@services/api";
import {translateGrades} from "@services/grades";
import Facebook from "@components/banner/Facebook";
import Error from "@components/Error";
import config from "../../../next-i18next.config.js";
export async function getServerSideProps({ query, locale }) {
const { pid, tid } = query;
export async function getServerSideProps({query, locale}) {
const {pid, tid} = query;
const [res, details, translations] = await Promise.all([
getResults(pid),
getDetails(pid),
serverSideTranslations(locale, [], config),
serverSideTranslations(locale, ["resource", "common", "locale"]),
]);
if (typeof res === "string" || res instanceof String) {
return { props: { err: res.slice(1, -1), ...translations } };
return {props: {err: res.slice(1, -1), ...translations}};
}
if (typeof details === "string" || details instanceof String) {
return { props: { err: res.slice(1, -1), ...translations } };
return {props: {err: res.slice(1, -1), ...translations}};
}
if (!details.candidates || !Array.isArray(details.candidates)) {
return { props: { err: "Unknown error", ...translations } };
return {props: {err: "Unknown error", ...translations}};
}
return {
@ -52,8 +50,8 @@ export async function getServerSideProps({ query, locale }) {
};
}
const Result = ({ candidates, numGrades, title, pid, err }) => {
const { t } = useTranslation();
const Result = ({candidates, numGrades, title, pid, err}) => {
const {t} = useTranslation();
if (err && err !== "") {
return <Error value={apiErrors(err, t)} />;
@ -111,9 +109,9 @@ const Result = ({ candidates, numGrades, title, pid, err }) => {
const gradeValue = candidate.grade + offsetGrade;
return (
<li key={i} className="mt-2">
<span className="mt-2 ml-2">{candidate.name}</span>
<span className="mt-2 ms-2">{candidate.name}</span>
<span
className="badge badge-light ml-2 mt-2"
className="badge badge-light ms-2 mt-2"
style={{
backgroundColor: grades.slice(0).reverse()[
candidate.grade
@ -156,17 +154,17 @@ const Result = ({ candidates, numGrades, title, pid, err }) => {
<div>
<div
className="median"
style={{ height: candidates.length * 28 + 30 }}
style={{height: candidates.length * 28 + 30}}
/>
<table style={{ width: "100%" }}>
<table style={{width: "100%"}}>
<tbody>
{candidates.map((candidate, i) => {
return (
<tr key={i}>
<td style={{ width: "30px" }}>{i + 1}</td>
<td style={{width: "30px"}}>{i + 1}</td>
{/*candidate.label*/}
<td>
<table style={{ width: "100%" }}>
<table style={{width: "100%"}}>
<tbody>
<tr>
{gradeIds
@ -224,7 +222,7 @@ const Result = ({ candidates, numGrades, title, pid, err }) => {
return (
<span
key={i}
className="badge badge-light mr-2 mt-2"
className="badge badge-light me-2 mt-2"
style={{
backgroundColor: grade.color,
color: "#fff",

@ -1,31 +1,30 @@
import { useState } from "react";
import {useState} from "react";
import Head from "next/head";
import { useRouter } from "next/router";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useTranslation } from "next-i18next";
import { Button, Col, Container, Row } from "reactstrap";
import { toast, ToastContainer } from "react-toastify";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCheck } from "@fortawesome/free-solid-svg-icons";
import { getDetails, castBallot, apiErrors } from "@services/api";
import {useRouter} from "next/router";
import {serverSideTranslations} from "next-i18next/serverSideTranslations";
import {useTranslation} from "next-i18next";
import {Button, Col, Container, Row} from "reactstrap";
import {toast, ToastContainer} from "react-toastify";
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faCheck} from "@fortawesome/free-solid-svg-icons";
import {getDetails, castBallot, apiErrors} from "@services/api";
import Error from "@components/Error";
import { translateGrades } from "@services/grades";
import config from "../../../next-i18next.config.js";
import {translateGrades} from "@services/grades";
const shuffle = (array) => array.sort(() => Math.random() - 0.5);
export async function getServerSideProps({ query: { pid, tid }, locale }) {
export async function getServerSideProps({query: {pid, tid}, locale}) {
const [details, translations] = await Promise.all([
getDetails(pid),
serverSideTranslations(locale, [], config),
serverSideTranslations(locale, ["resource", "common", "locale"]),
]);
if (typeof details === "string" || details instanceof String) {
return { props: { err: details, ...translations } };
return {props: {err: details, ...translations}};
}
if (!details.candidates || !Array.isArray(details.candidates)) {
return { props: { err: "Unknown error", ...translations } };
return {props: {err: "Unknown error", ...translations}};
}
shuffle(details.candidates);
@ -35,7 +34,7 @@ export async function getServerSideProps({ query: { pid, tid }, locale }) {
...translations,
invitationOnly: details.on_invitation_only,
restrictResults: details.restrict_results,
candidates: details.candidates.map((name, i) => ({ id: i, label: name })),
candidates: details.candidates.map((name, i) => ({id: i, label: name})),
title: details.title,
numGrades: details.num_grades,
pid: pid,
@ -44,8 +43,8 @@ export async function getServerSideProps({ query: { pid, tid }, locale }) {
};
}
const VoteBallot = ({ candidates, title, numGrades, pid, err, token }) => {
const { t } = useTranslation();
const VoteBallot = ({candidates, title, numGrades, pid, err, token}) => {
const {t} = useTranslation();
if (err) {
return <Error value={apiErrors(err, t)}></Error>;
@ -138,11 +137,11 @@ const VoteBallot = ({ candidates, title, numGrades, pid, err, token }) => {
lg={colSizeGradeLg}
key={gradeId}
className="text-center p-0"
style={{ lineHeight: 2 }}
style={{lineHeight: 2}}
>
<small
className="nowrap bold badge"
style={{ backgroundColor: grade.color, color: "#fff" }}
style={{backgroundColor: grade.color, color: "#fff"}}
>
{grade.label}
</small>
@ -180,7 +179,7 @@ const VoteBallot = ({ candidates, title, numGrades, pid, err, token }) => {
className="check"
>
<small
className="nowrap d-lg-none ml-2 bold badge"
className="nowrap d-lg-none ms-2 bold badge"
style={
judgments.find((judgment) => {
return (
@ -191,11 +190,11 @@ const VoteBallot = ({ candidates, title, numGrades, pid, err, token }) => {
})
);
})
? { backgroundColor: grade.color, color: "#fff" }
? {backgroundColor: grade.color, color: "#fff"}
: {
backgroundColor: "transparent",
color: "#000",
}
backgroundColor: "transparent",
color: "#000",
}
}
>
{grade.label}
@ -230,11 +229,11 @@ const VoteBallot = ({ candidates, title, numGrades, pid, err, token }) => {
})
);
})
? { backgroundColor: grade.color, color: "#fff" }
? {backgroundColor: grade.color, color: "#fff"}
: {
backgroundColor: "transparent",
color: "#000",
}
backgroundColor: "transparent",
color: "#000",
}
}
/>
</label>
@ -253,12 +252,12 @@ const VoteBallot = ({ candidates, title, numGrades, pid, err, token }) => {
onClick={handleSubmitWithoutAllRate}
className="btn btn-dark "
>
<FontAwesomeIcon icon={faCheck} className="mr-2" />
<FontAwesomeIcon icon={faCheck} className="me-2" />
{t("Submit my vote")}
</Button>
) : (
<Button type="submit" className="btn btn-success ">
<FontAwesomeIcon icon={faCheck} className="mr-2" />
<FontAwesomeIcon icon={faCheck} className="me-2" />
{t("Submit my vote")}
</Button>
)}

@ -1,26 +1,25 @@
import Head from "next/head";
import { Col, Container, Row } from "reactstrap";
import {Col, Container, Row} from "reactstrap";
import Link from "next/link";
import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import {useTranslation} from "next-i18next";
import {serverSideTranslations} from "next-i18next/serverSideTranslations";
import Paypal from "@components/banner/Paypal";
import Gform from "@components/banner/Gform";
import Error from "@components/Error";
import { getDetails, apiErrors } from "@services/api";
import config from "../../../next-i18next.config.js";
import {getDetails, apiErrors} from "@services/api";
export async function getServerSideProps({ query: { pid }, locale }) {
export async function getServerSideProps({query: {pid}, locale}) {
const [details, translations] = await Promise.all([
getDetails(pid),
serverSideTranslations(locale, [], config),
serverSideTranslations(locale, ["resource", "common", "locale"]),
]);
if (typeof details === "string" || details instanceof String) {
return { props: { err: res.slice(1, -1), ...translations } };
return {props: {err: res.slice(1, -1), ...translations}};
}
if (!details.candidates || !Array.isArray(details.candidates)) {
return { props: { err: "Unknown error", ...translations } };
return {props: {err: "Unknown error", ...translations}};
}
return {
@ -28,7 +27,7 @@ export async function getServerSideProps({ query: { pid }, locale }) {
...translations,
invitationOnly: details.on_invitation_only,
restrictResults: details.restrict_results,
candidates: details.candidates.map((name, i) => ({ id: i, label: name })),
candidates: details.candidates.map((name, i) => ({id: i, label: name})),
title: details.title,
numGrades: details.num_grades,
pid: pid,
@ -36,8 +35,9 @@ export async function getServerSideProps({ query: { pid }, locale }) {
};
}
const VoteSuccess = ({ title, invitationOnly, pid, err }) => {
const { t } = useTranslation();
const VoteSuccess = ({title, invitationOnly, pid, err}) => {
const {t} = useTranslation();
if (err && err !== "") {
return <Error value={apiErrors(err, t)} />;
}
@ -55,10 +55,8 @@ const VoteSuccess = ({ title, invitationOnly, pid, err }) => {
/>
</Head>
<Row>
<Link href="/">
<a className="d-block ml-auto mr-auto mb-4">
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
</a>
<Link href="/" className="d-block ms-auto me-auto mb-4">
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
</Link>
</Row>
<Row className="mt-4">

Loading…
Cancel
Save