From 2e19bdb964759917ad7e3dffedf623ef3dae562d Mon Sep 17 00:00:00 2001 From: Pierre-Louis Guhur Date: Wed, 2 Nov 2022 13:30:42 +0100 Subject: [PATCH] fix: clean up buttons --- components/Button.jsx | 23 ++++++++++++++++ components/admin/CandidateField.jsx | 2 +- components/admin/CandidateModalDel.jsx | 24 ++++------------- components/admin/CandidateModalSet.jsx | 24 ++++------------- components/admin/CandidatesField.jsx | 36 ++++++++++++++++---------- components/layouts/Footer.jsx | 2 +- pages/_app.jsx | 4 +-- pages/index.jsx | 3 ++- public/back.svg | 3 +-- styles/scss/_app.scss | 31 ++++------------------ styles/scss/_buttons.scss | 34 +++++++++++------------- 11 files changed, 82 insertions(+), 104 deletions(-) create mode 100644 components/Button.jsx diff --git a/components/Button.jsx b/components/Button.jsx new file mode 100644 index 0000000..f39aa6f --- /dev/null +++ b/components/Button.jsx @@ -0,0 +1,23 @@ +import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; +import {Row, Col, Button} from "reactstrap"; + +const ButtonWithIcon = ({icon, children, ...props}) => { + if (icon) { + return + } + + else { + return () + } +} + +export default ButtonWithIcon diff --git a/components/admin/CandidateField.jsx b/components/admin/CandidateField.jsx index aa3a2b9..d697218 100644 --- a/components/admin/CandidateField.jsx +++ b/components/admin/CandidateField.jsx @@ -37,7 +37,7 @@ const CandidateField = ({position, className, ...inputProps}) => { return ( diff --git a/components/admin/CandidateModalDel.jsx b/components/admin/CandidateModalDel.jsx index 0433024..6629a24 100644 --- a/components/admin/CandidateModalDel.jsx +++ b/components/admin/CandidateModalDel.jsx @@ -3,7 +3,6 @@ import { Col, Label, Input, - Button, Modal, ModalBody, Form @@ -17,6 +16,7 @@ import { import {useTranslation} from "next-i18next"; import Image from 'next/image'; import {useElection, useElectionDispatch} from './ElectionContext'; +import Button from '@components/Button' import {upload} from '@services/imgpush'; import {IMGPUSH_URL} from '@services/constants'; import defaultAvatar from '../../public/default-avatar.svg' @@ -54,27 +54,13 @@ const CandidateModal = ({isOpen, position, toggle}) => { {candidate.name ?

{candidate.name}

: null} - - diff --git a/components/admin/CandidateModalSet.jsx b/components/admin/CandidateModalSet.jsx index fef671f..54dd652 100644 --- a/components/admin/CandidateModalSet.jsx +++ b/components/admin/CandidateModalSet.jsx @@ -4,7 +4,6 @@ import { Col, Label, Input, - Button, Modal, ModalBody, Form @@ -17,6 +16,7 @@ import { import {useTranslation} from "next-i18next"; import Image from 'next/image'; import {useElection, useElectionDispatch} from './ElectionContext'; +import Button from '@components/Button' import {upload} from '@services/imgpush'; import {IMGPUSH_URL} from '@services/constants'; import defaultAvatar from '../../public/default-avatar.svg' @@ -146,27 +146,13 @@ const CandidateModal = ({isOpen, position, toggle}) => { - - diff --git a/components/admin/CandidatesField.jsx b/components/admin/CandidatesField.jsx index e04d11c..a006527 100644 --- a/components/admin/CandidatesField.jsx +++ b/components/admin/CandidatesField.jsx @@ -3,17 +3,18 @@ import {useTranslation} from "next-i18next"; import CandidateField from './CandidateField' import Alert from '@components/Alert' import {MAX_NUM_CANDIDATES} from '@services/constants'; -import {Container} from 'reactstrap'; +import {Container, Button} from 'reactstrap'; import {useElection, useElectionDispatch} from './ElectionContext'; -const CandidatesField = () => { +const CandidatesField = ({onSubmit}) => { const {t} = useTranslation(); const election = useElection(); const dispatch = useElectionDispatch(); const candidates = election.candidates; const [error, setError] = useState(null) + const disabled = candidates.filter(c => c.name !== "").length < 2; // What to do when we change the candidates useEffect(() => { @@ -27,18 +28,25 @@ const CandidatesField = () => { }, [candidates]) return ( - -

{t('admin.add-candidates')}

- - {candidates.map((candidate, index) => { - return ( - - ) - })} -
+ +
+

{t('admin.add-candidates')}

+ + {candidates.map((candidate, index) => { + return ( + + ) + })} +
+
+ +
+
); } diff --git a/components/layouts/Footer.jsx b/components/layouts/Footer.jsx index 0bb71e1..cbce8aa 100644 --- a/components/layouts/Footer.jsx +++ b/components/layouts/Footer.jsx @@ -80,7 +80,7 @@ const Footer = () => {
-