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 ButtonCopy from '@components/ButtonCopy';
import Share from '@components/Share';
import ErrorMessage from '@components/Error';
import AdminModalEmail from '@components/admin/AdminModalEmail';
import {ElectionPayload, ErrorPayload} from '@services/api';
import {useAppContext} from '@services/context';
import {getUrlVote, getUrlResults} from '@services/routes';
import urne from '../public/urne.svg'
import star from '../public/star.svg'
import {Container} from 'reactstrap';
export interface WaitingBallotInterface {
election?: ElectionPayload;
error?: ErrorPayload;
}
interface InfoElectionInterface extends WaitingBallotInterface {
display: string;
}
const InfoElection = ({election, error, display}: InfoElectionInterface) => {
const {t} = useTranslation();
const [modal, setModal] = useState(false);
const toggleModal = () => setModal(m => !m);
if (!election) return null;
const urlVote = getUrlVote(election.id)
const urlResults = getUrlResults(election.id)
return (
{error && error.detail ?
: null}
{election && election.id ?
<>
{t('admin.success-election')}
{election && election.private ?
{t('admin.success-emails')}
:
}
}
position="right"
color="secondary"
outline={true}
onClick={toggleModal}
className="mt-3 py-3 px-4"
>
{t('admin.go-to-admin')}
> : null}
)
}
export default ({election, error}: WaitingBallotInterface) => {
const {setApp} = useAppContext();
const [urneProperties, setUrne] = useState({width: 0, height: 0, marginBottom: 0});
const [starProperties, setStar] = useState({width: 0, height: 0, marginLeft: 100, marginBottom: 0});
const [urneContainerProperties, setUrneContainer] = useState({height: "100vh"});
const [electionProperties, setElection] = useState({display: "none"});
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 (
)
}