From 15c6cc0be761bdc21b539936e7581c086738ff7d Mon Sep 17 00:00:00 2001 From: pikiou Date: Tue, 11 Jan 2022 21:46:37 +0100 Subject: [PATCH] Fix api url in prod --- src/components/ForgotForm/ForgotForm.tsx | 4 +- src/components/Notifications/index.tsx | 50 ++++++++----------- .../Notifications/styles.module.scss | 12 +++++ src/config/prod.ts | 6 ++- src/pages/Home/Home.tsx | 16 +++++- src/pages/Home/styles.module.scss | 6 +++ src/server/gsheets/volunteers.ts | 2 +- src/server/ssr.tsx | 3 +- src/store/utils.ts | 13 +++-- src/store/volunteerNotifsSet.ts | 5 +- webpack/base.config.ts | 2 +- 11 files changed, 75 insertions(+), 44 deletions(-) diff --git a/src/components/ForgotForm/ForgotForm.tsx b/src/components/ForgotForm/ForgotForm.tsx index 6c5d3ef..b0fd47b 100644 --- a/src/components/ForgotForm/ForgotForm.tsx +++ b/src/components/ForgotForm/ForgotForm.tsx @@ -34,12 +34,12 @@ const ForgotForm = ({ dispatch, error, message }: Props): JSX.Element => {
- +
{error}
{message}
- S'identifier + S'identifier
) diff --git a/src/components/Notifications/index.tsx b/src/components/Notifications/index.tsx index 02b8ce1..8419845 100644 --- a/src/components/Notifications/index.tsx +++ b/src/components/Notifications/index.tsx @@ -1,8 +1,7 @@ import _ from "lodash" import React, { memo, useCallback, useEffect, useRef, useState } from "react" import isNode from "detect-node" -import { shallowEqual, useSelector } from "react-redux" -import { AppDispatch, AppState } from "../../store" +import { AppDispatch } from "../../store" import { fetchVolunteerNotifsSet } from "../../store/volunteerNotifsSet" import styles from "./styles.module.scss" import { logoutUser } from "../../store/auth" @@ -12,19 +11,11 @@ import { VolunteerNotifs } from "../../services/volunteers" interface Props { dispatch: AppDispatch jwt: string + // eslint-disable-next-line react/require-default-props + volunteerNotifs?: VolunteerNotifs } -let prevNotifs: VolunteerNotifs | undefined - -const Notifications = ({ dispatch, jwt }: Props): JSX.Element | null => { - const volunteerNotifs = useSelector((state: AppState) => { - const notifs = state.volunteerNotifsSet.entity - if (notifs) { - prevNotifs = notifs - return notifs - } - return prevNotifs - }, shallowEqual) +const Notifications = ({ dispatch, jwt, volunteerNotifs }: Props): JSX.Element | null => { const hidden = volunteerNotifs?.hiddenNotifs || [] const notifs: JSX.Element[] = [] @@ -62,12 +53,17 @@ const Notifications = ({ dispatch, jwt }: Props): JSX.Element | null => { } const [participation, setParticipation] = useState(volunteerNotifs?.active || "inconnu") + const [participationMessage, setParticipationMessage] = useState("") const onChangeValue2 = (e: React.ChangeEvent) => setParticipation(e.target.value) const onSubmit2 = useCallback( (event: React.SyntheticEvent): void => { event.preventDefault() + if (participation === "inconnu") { + setParticipationMessage("Il nous faudrait une réponse ^^") + return + } dispatch( fetchVolunteerNotifsSet(jwt, 0, { @@ -88,16 +84,6 @@ const Notifications = ({ dispatch, jwt }: Props): JSX.Element | null => {
Si les conditions sanitaires te le permettent, souhaites-tu être bénévole à PeL 2022 ?
-