feat: waiting ballot

pull/89/head
Pierre-Louis Guhur 1 year ago
parent 92075063b6
commit 9ff0de63e8

@ -0,0 +1,39 @@
import Image from 'next/image';
import {useTranslation} from 'next-i18next';
import {Row, Col} from 'reactstrap';
import twitter from '../public/twitter.svg';
import facebook from '../public/facebook.svg';
interface ShareInterface {
title?: string;
}
const ShareRow = ({title}: ShareInterface) => {
const {t} = useTranslation('resource');
return (
<Row className="sharing justify-content-md-center">
<Col className="col-auto">{title || t('common.share')}</Col>
<Col className="col-auto">
<a
target="_blank"
rel="noopener noreferrer"
href="https://www.facebook.com/mieuxvoter.fr/"
>
<Image height={22} width={22} src={facebook} alt="icon facebook" />
</a>
</Col>
<Col className="col-auto">
<a
target="_blank"
rel="noopener noreferrer"
href="https://twitter.com/mieux_voter"
>
<Image height={22} width={22} src={twitter} alt="icon twitter" />
</a>
</Col>
</Row>
);
};
export default ShareRow;

@ -1,14 +1,155 @@
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 Button from '@components/Button';
import Share from '@components/Share';
import {ElectionPayload} from '@services/api';
import {useAppContext} from '@services/context';
import urne from '../public/urne.svg'
import star from '../public/star.svg'
import {Container} from 'reactstrap';
export default () => {
return (<div className="d-flex h-100 w-100 justify-content-center align-items-middle">
<Image
src={urne}
width={22}
height={22}
className="align-self-center"
alt="urne"
/>
</div>)
export interface WaitingBallotInterface {
election: ElectionPayload;
}
export default ({election}: WaitingBallotInterface) => {
const {setApp} = useAppContext();
const [urneProperties, setUrne] = useState<CSSProperties>({width: 0, height: 0, marginBottom: 0});
const [starProperties, setStar] = useState<CSSProperties>({width: 0, height: 0, marginLeft: 100, marginBottom: 0});
const [urneContainerProperties, setUrneContainer] = useState<CSSProperties>({height: "100vh"});
const [electionProperties, setElection] = useState<CSSProperties>({display: "none"});
const {t} = useTranslation();
useEffect(() => {
setApp({footer: false});
setUrne(urne => ({
...urne,
width: 300,
height: 300,
}));
const timer = setTimeout(() => {
setStar(star => ({
...star,
width: 150,
height: 150,
marginLeft: 150,
marginBottom: 300,
}
));
}, 1000);
const timer2 = setTimeout(() => {
// setElection({display: "block"});
setUrneContainer(urneContainer => ({
...urneContainer,
height: "50vh",
}));
setStar(star => ({
...star,
width: 100,
height: 100,
marginLeft: 100,
marginBottom: 200,
}));
setUrne(urne => ({
...urne,
width: 200,
height: 200,
}));
}, 3000);
const timer3 = setTimeout(() => {
setElection({display: "block"});
}, 4500);
return () => {
clearTimeout(timer);
clearTimeout(timer2);
clearTimeout(timer3);
};
}, [])
return (<Container
className="d-flex h-100 w-100 align-items-center flex-column"
style={{
maxWidth: "400px"
}}
>
<div
style={{
transition: "width 2s, height 2s",
height: urneContainerProperties.height,
}}
className="d-flex align-items-center"
>
<div
className="position-relative"
style={{
transition: "width 2s, height 2s, margin-bottom 2s",
zIndex: 2,
marginTop: urneProperties.marginBottom,
height: urneProperties.height,
width: urneProperties.width,
}}
>
<Image
src={urne}
alt="urne"
fill={true}
/>
</div>
<div
className="position-absolute"
style={{
transition: "width 2s, height 2s, margin-left 2s, margin-bottom 2s",
marginLeft: starProperties.marginLeft,
marginBottom: starProperties.marginBottom,
height: starProperties.height,
width: starProperties.width,
}}
>
<Image
src={star}
fill={true}
alt="urne"
/>
</div>
</div>
<div style={{
display: electionProperties.display,
transition: "display 2s",
}}
className="d-flex flex-column align-items-center"
>
<h4 className="text-center">
{t('admin.success-election')}
</h4>
{election && election.private ?
<h5 className="text-center">
{t('admin.success-emails')}
</h5>
: null}
<Button
customIcon={<FontAwesomeIcon icon={faArrowRight} />}
position="right"
color="secondary"
outline={true}
className="mt-3 py-3 px-4"
>
{t('admin.go-to-admin')}
</Button>
<Share title={t('common.share-short')} />
</div>
</Container >)
}

@ -39,7 +39,7 @@ const AddField = () => {
<Col className="col-auto">
<FontAwesomeIcon icon={faPlus} />
</Col>
<GradeModalAdd isOpen={modal} toggle={toggle} />
<GradeModalAdd key={election.grades.length} isOpen={modal} toggle={toggle} />
</Row>
);
};

@ -1,11 +1,15 @@
import Link from 'next/link';
import { useTranslation } from 'next-i18next';
import { Button, Row, Col } from 'reactstrap';
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';
const Footer = () => {
const { t } = useTranslation();
const {t} = useTranslation();
const {app} = useAppContext();
if (!app.footer) {return null;}
const menu = [
{

@ -1,18 +1,22 @@
/* 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 {useTranslation} from 'next-i18next';
import {useAppContext} from '@services/context';
import LanguageSelector from './LanguageSelector';
import openMenuIcon from '../../public/open-menu-icon.svg';
const Header = () => {
const [isOpen, setOpen] = useState(false);
const {app} = useAppContext();
const toggle = () => setOpen(!isOpen);
const { t } = useTranslation('resource');
const {t} = useTranslation('resource');
if (!app.footer) {return null;}
return (
<>

@ -7,13 +7,11 @@ import WaitingBallot from '@components/WaitingBallot';
import PatternedBackground from '@components/PatternedBackground';
import {
ElectionProvider,
useElection,
} from '@services/ElectionContext';
import {ProgressSteps, creationSteps} from '@components/CreationSteps';
import {GetStaticProps} from 'next';
import {ElectionPayload} from '@services/api';
import {getUrlConfirm} from '@services/utils';
import {useRouter} from 'next/router';
export const getStaticProps: GetStaticProps = async ({locale}) => ({
props: {
@ -25,9 +23,8 @@ const CreateElectionForm = () => {
/**
* Manage the steps for creating an election
*/
const [wait, setWait] = useState(true);
const router = useRouter();
const [wait, setWait] = useState(false);
const [payload, setPayload] = useState<ElectionPayload | null>(null);
const handleSubmit = () => {
if (stepId < creationSteps.length - 1) {
@ -37,14 +34,9 @@ const CreateElectionForm = () => {
}
};
const onCreatedElection = (election: ElectionPayload) => {
console.log("ready");
// router.push(getUrlConfirm(election.id.toString()))
}
if (wait) {
return <PatternedBackground>
<WaitingBallot />;
<WaitingBallot election={payload} />
</PatternedBackground>
}
@ -61,7 +53,7 @@ const CreateElectionForm = () => {
Step = (
<ConfirmField
onSubmit={handleSubmit}
onCreatedElection={onCreatedElection}
onCreatedElection={setPayload}
goToCandidates={() => setStepId(0)}
goToParams={() => setStepId(1)}
/>

@ -6,13 +6,12 @@ import {serverSideTranslations} from 'next-i18next/serverSideTranslations';
import {useTranslation} from 'next-i18next';
import {Container, Row, Col, Button, Input} from 'reactstrap';
import Logo from '@components/Logo';
import Share from '@components/Share';
import {CREATE_ELECTION} from '@services/routes';
import ballotBox from '../public/urne.svg';
import email from '../public/email.svg';
import respect from '../public/respect.svg';
import vote from '../public/vote.svg';
import twitter from '../public/twitter.svg';
import facebook from '../public/facebook.svg';
import arrowRight from '../public/arrow-white.svg';
export const getStaticProps: GetStaticProps = async ({locale}) => ({
@ -155,33 +154,6 @@ const ExperienceRow = () => {
);
};
const ShareRow = () => {
const {t} = useTranslation('resource');
return (
<Row className="sharing justify-content-md-center">
<Col className="col-auto">{t('home.share')}</Col>
<Col className="col-auto">
<a
target="_blank"
rel="noopener noreferrer"
href="https://www.facebook.com/mieuxvoter.fr/"
>
<Image height={22} width={22} src={facebook} alt="icon facebook" />
</a>
</Col>
<Col className="col-auto">
<a
target="_blank"
rel="noopener noreferrer"
href="https://twitter.com/mieux_voter"
>
<Image height={22} width={22} src={twitter} alt="icon twitter" />
</a>
</Col>
</Row>
);
};
const Home = () => {
const {t} = useTranslation('resource');
return (
@ -192,7 +164,7 @@ const Home = () => {
<section className="sectionTwoHome">
<AdvantagesRow />
<ExperienceRow />
<ShareRow />
<Share />
</section>
</Container>
);

@ -21,12 +21,13 @@
"home.alt-icon-envelop": "icon of an envelop",
"home.alt-icon-respect": "icon of hands holding each other",
"home.alt-icon-ballot": "icon of a ballot",
"home.share": "Share the application Better Vote",
"menu.majority-judgment": "Majority judgment",
"menu.whoarewe": "Who are we?",
"menu.faq": "FAQ",
"menu.news": "News",
"menu.contact-us": "Contact us",
"common.share": "Share the application Better Vote",
"common.share-short": "Share the application",
"common.save": "Save",
"common.back-homepage": "Return to home page",
"common.support-us": "Support us",
@ -84,5 +85,8 @@
"admin.confirm-question": "Question of your vote",
"admin.confirm-candidates": "Candidates",
"admin.confirm-submit": "Start the vote",
"admin.confirm-title": "Confirm your vote"
"admin.confirm-title": "Confirm your vote",
"admin.success-election": "The vote has been created with success!",
"admin.success-emails": "The voting link has been sent by emails to the participants.",
"admin.go-to-admin": "Manage the vote"
}

@ -17,7 +17,6 @@
"home.experience-2-title": "Obtenez le meilleur consensus.",
"home.experience-2-desc": "Le profil des mérites dresse un panorama précis de lopinion des électeurs. Le gagnant du vote est celui qui est la meilleure mention majoritaire.",
"home.experience-call-to-action": "Découvrez le jugement majoritaire",
"home.share": "Partagez lapplication Mieux voter",
"home.alt-icon-ballot-box": "icone d'urne",
"home.alt-icon-envelop": "icone d'enveloppe",
"home.alt-icon-respect": "icone de mains qui se serrent",
@ -27,6 +26,8 @@
"menu.faq": "FAQ",
"menu.news": "Actualités",
"menu.contact-us": "Nous contacter",
"common.share": "Partagez l'application Mieux voter",
"common.share-short": "Partagez l'application",
"common.back-homepage": "Revenir sur la page d'accueil",
"common.support-us": "Soutenez nous",
"common.save": "Sauvegarder",
@ -84,5 +85,8 @@
"admin.confirm-question": "Question de votre vote",
"admin.confirm-candidates": "Candidats",
"admin.confirm-submit": "Démarrer le vote",
"admin.confirm-title": "Confirmer votre vote"
"admin.confirm-title": "Confirmer votre vote",
"admin.success-election": "Le vote a été créé avec succès",
"admin.success-emails": "Le lien du vote a été envoyé par courriel aux participants.",
"admin.go-to-admin": "Administrez le vote"
}

@ -1,16 +1,20 @@
import {createContext, useContext} from 'react';
import {createContext, useState, useContext, Dispatch, SetStateAction} from 'react';
interface Application {
footer: boolean;
}
interface AppContextInterface {
app: Application;
setApp: Dispatch<SetStateAction<Application>>;
}
const AppContext = createContext<AppContextInterface | null>(null);
export function AppProvider({children}) {
let state = {}
const [app, setApp] = useState<Application>({footer: true});
return (
<AppContext.Provider value={state}>
<AppContext.Provider value={{app, setApp}}>
{children}
</AppContext.Provider>
);

@ -405,3 +405,7 @@ a, a:hover {
.bg-blue {
background-color: $mv-blue-color!important;
}
.no-shadow {
box-shadow: unset!important;
}

Loading…
Cancel
Save