From 7fc3ec08ba884091f5e19794a27cdc3523eb7075 Mon Sep 17 00:00:00 2001 From: pikiou Date: Thu, 17 Mar 2022 00:22:34 +0100 Subject: [PATCH] =?UTF-8?q?Add=20register=20form,=20missing=20proper=20fee?= =?UTF-8?q?dback=20on=20error=20or=20success=C2=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index.tsx | 120 +++++++++++++----- .../styles.module.scss | 0 src/components/index.ts | 4 +- src/pages/PreRegister/PreRegister.tsx | 48 ------- src/pages/Register/Register.tsx | 27 ++++ src/pages/{PreRegister => Register}/index.tsx | 6 +- .../styles.module.scss | 4 +- src/routes/index.ts | 10 +- src/server/gsheets/accessors.ts | 4 +- src/server/gsheets/expressAccessors.ts | 40 +++++- src/server/gsheets/localDb.ts | 12 +- src/server/gsheets/postulants.ts | 44 +++++++ src/server/gsheets/preVolunteers.ts | 19 --- src/server/gsheets/volunteers.ts | 37 +++++- src/server/index.ts | 19 +-- .../{preVolunteers.ts => postulants.ts} | 12 +- src/services/postulantsAccessors.ts | 9 ++ src/services/preVolunteersAccessors.ts | 10 -- src/services/volunteers.ts | 23 +++- src/services/volunteersAccessors.ts | 2 +- src/store/postulantAdd.ts | 39 ++++++ src/store/preVolunteerAdd.ts | 39 ------ src/store/preVolunteerCount.ts | 46 ------- src/store/rootReducer.ts | 8 +- src/store/utils.ts | 10 +- ...volunteerAdd.ts => volunteerPartialAdd.ts} | 18 +-- 26 files changed, 350 insertions(+), 260 deletions(-) rename src/components/{PreRegisterForm => RegisterForm}/index.tsx (68%) rename src/components/{PreRegisterForm => RegisterForm}/styles.module.scss (100%) delete mode 100644 src/pages/PreRegister/PreRegister.tsx create mode 100644 src/pages/Register/Register.tsx rename src/pages/{PreRegister => Register}/index.tsx (62%) rename src/pages/{PreRegister => Register}/styles.module.scss (73%) create mode 100644 src/server/gsheets/postulants.ts delete mode 100644 src/server/gsheets/preVolunteers.ts rename src/services/{preVolunteers.ts => postulants.ts} (60%) create mode 100644 src/services/postulantsAccessors.ts delete mode 100644 src/services/preVolunteersAccessors.ts create mode 100644 src/store/postulantAdd.ts delete mode 100644 src/store/preVolunteerAdd.ts delete mode 100644 src/store/preVolunteerCount.ts rename src/store/{volunteerAdd.ts => volunteerPartialAdd.ts} (66%) diff --git a/src/components/PreRegisterForm/index.tsx b/src/components/RegisterForm/index.tsx similarity index 68% rename from src/components/PreRegisterForm/index.tsx rename to src/components/RegisterForm/index.tsx index 39b79cd..6bf819f 100644 --- a/src/components/PreRegisterForm/index.tsx +++ b/src/components/RegisterForm/index.tsx @@ -4,15 +4,16 @@ import { toast } from "react-toastify" import _ from "lodash" import styles from "./styles.module.scss" -import { fetchPreVolunteerAdd } from "../../store/preVolunteerAdd" +import { fetchPostulantAdd } from "../../store/postulantAdd" import { AppDispatch, AppState } from "../../store" +import { fetchVolunteerPartialAdd } from "../../store/volunteerPartialAdd" interface Props { dispatch: AppDispatch - preVolunteerCount: number | undefined } -const PreRegisterForm = ({ dispatch, preVolunteerCount }: Props): JSX.Element => { +const RegisterForm = ({ dispatch }: Props): JSX.Element => { + const [potentialVolunteer, setPotentialVolunteer] = useState(true) const [firstname, setFirstname] = useState("") const [lastname, setLastname] = useState("") const [email, setEmail] = useState("") @@ -21,31 +22,60 @@ const PreRegisterForm = ({ dispatch, preVolunteerCount }: Props): JSX.Element => const [comment, setComment] = useState("") const [sending, setSending] = useState(false) + const onNewVolunteer = (e: React.ChangeEvent) => + setPotentialVolunteer(!e.target.value) + const onPotentialVolunteer = (e: React.ChangeEvent) => + setPotentialVolunteer(!!e.target.value) + const onFirstnameChanged = (e: React.ChangeEvent) => setFirstname(e.target.value) const onLastnameChanged = (e: React.ChangeEvent) => setLastname(e.target.value) + const onEmailChanged = (e: React.ChangeEvent) => setEmail(e.target.value) const onMobileChanged = (e: React.ChangeEvent) => setMobile(e.target.value) + const onAlreadyVolunteer = (e: React.ChangeEvent) => setAlreadyVolunteer(!!e.target.value) const onNotYesVolunteer = (e: React.ChangeEvent) => setAlreadyVolunteer(!e.target.value) + const onCommentChanged = (e: React.ChangeEvent) => setComment(e.target.value) const onSubmit = () => { if (firstname && lastname && email && mobile && !sending) { - dispatch( - fetchPreVolunteerAdd({ - firstname, - lastname, - email, - mobile, - alreadyVolunteer, - comment, - }) - ) + if (potentialVolunteer) { + dispatch( + fetchPostulantAdd({ + firstname, + lastname, + email, + mobile, + potential: true, + comment, + }) + ) + } else { + dispatch( + fetchPostulantAdd({ + firstname, + lastname, + email, + mobile, + potential: false, + comment, + }) + ) + dispatch( + fetchVolunteerPartialAdd({ + firstname, + lastname, + email, + mobile, + }) + ) + } setSending(true) } else { @@ -61,13 +91,13 @@ const PreRegisterForm = ({ dispatch, preVolunteerCount }: Props): JSX.Element => } } - const { error, entities: preVolunteer } = useSelector( - (state: AppState) => state.preVolunteerAdd, + const { error, entities: postulant } = useSelector( + (state: AppState) => state.postulantAdd, shallowEqual ) let sendSuccess - if (!_.isEmpty(preVolunteer)) { + if (!_.isEmpty(postulant)) { if (sending) { setSending(false) } @@ -75,7 +105,7 @@ const PreRegisterForm = ({ dispatch, preVolunteerCount }: Props): JSX.Element => } let sendError - if (error && _.isEmpty(preVolunteer)) { + if (error && _.isEmpty(postulant)) { if (sending) { setSending(false) } @@ -140,31 +170,53 @@ const PreRegisterForm = ({ dispatch, preVolunteerCount }: Props): JSX.Element => confort avant tout !

- Certains bénévoles sont visiteurs le samedi ou le dimanche pour vivre le - festival de l'intérieur. Les deux jours avant et le jour après le - festival, ceux qui le peuvent viennent préparer et ranger. Bref, chacun - participe à la hauteur de ses wishes et disponibilités ! + La majorité d'entre nous sommes bénévoles les samedi et dimanche + , mais certains bénévoles ne sont pas disponibles les deux jours. On leur + demande alors d'aider à la mise en place jeudi ou vendredi, ou au + rangement le lundi. Bref, chacun participe comme il peut mais deux jours + minimum !

Le samedi soir quand les visiteurs sont partis, nous prolongeons la fête en - dînant avec les auteurs, illustrateurs et éditeurs présents sur le festival. + dînant avec les exposants présents sur le festival.

- Si l'expérience pourrait vous tenter, remplissez le formulaire suivant pour - en discuter lors d'un des gros apéros mensuels !
- Cette inscription ne vous oblige en rien il s'agit juste d'une prise - de contact. + Si l'expérience vous tente, remplissez le formulaire suivant pour devenir + bénévoles !
+ Vous pouvez aussi juste nous rencontrer avant de vous décider à devenir + bénévole, on comprend qu'un saut dans l'inconnu soit difficile.
- Les prochains sont les 21 décembre et 27 janvier, mais nous vous appelerons - d'ici là pour les détails :) + Dans les deux cas, venez nous rencontrer mardi 22 mars près de Châtelet, détails + après l'inscription :)
- {/* */} -
+
+
+ Je veux devenir bénévole + + + + +
+