diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9de998a..4cca398 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: - node-version: [17.x] + node-version: [18.x] steps: - uses: actions/checkout@v2 diff --git a/src/components/Asks/AskBrunch.tsx b/src/components/Asks/AskBrunch.tsx new file mode 100644 index 0000000..b0ddcc4 --- /dev/null +++ b/src/components/Asks/AskBrunch.tsx @@ -0,0 +1,39 @@ +import { get } from "lodash" +import { useCallback } from "react" +import { fetchVolunteerAsksSet } from "../../store/volunteerAsksSet" +import { useAskTools, addAsk, answerLaterOnProfile } from "./utils" +import BrunchForm, { fetchFor as fetchForBrunchForm } from "../VolunteerBoard/BrunchForm/BrunchForm" +import { useBrunch } from "../VolunteerBoard/brunch.utils" + +export function AskBrunch(asks: JSX.Element[], id: number): void { + const { dispatch, jwtToken, volunteerAsks } = useAskTools() + + const onSubmit = useCallback((): void => { + dispatch( + fetchVolunteerAsksSet(jwtToken, 0, { + hiddenAsks: [...(volunteerAsks?.hiddenAsks || []), id], + }) + ) + }, [dispatch, id, jwtToken, volunteerAsks?.hiddenAsks]) + + const [retex] = useBrunch() + const question1Default = "-1" + const question1 = +get(retex, "question1", question1Default) + const needToShow = !!retex && question1 === -1 + + addAsk( + asks, + id, + volunteerAsks, + false, + needToShow, + <> + {answerLaterOnProfile} + Nous avons besoin d'une réponse avant le jeudi 15 soir minuit pour commander les repas ! + ^^ + + ) +} + +// Fetch server-side data here +export const fetchFor = [...fetchForBrunchForm] diff --git a/src/components/Asks/AskRetex.tsx b/src/components/Asks/AskRetex.tsx new file mode 100644 index 0000000..3592411 --- /dev/null +++ b/src/components/Asks/AskRetex.tsx @@ -0,0 +1,59 @@ +import { get } from "lodash" +import { useCallback } from "react" +import { fetchVolunteerAsksSet } from "../../store/volunteerAsksSet" +import { useAskTools, addAsk, answerLaterOnProfile } from "./utils" +import RetexForm, { fetchFor as fetchForRetexForm } from "../VolunteerBoard/RetexForm/RetexForm" +import { useRetex } from "../VolunteerBoard/retex.utils" + +export function AskRetex(asks: JSX.Element[], id: number): void { + const { dispatch, jwtToken, volunteerAsks } = useAskTools() + + const onSubmit = useCallback((): void => { + dispatch( + fetchVolunteerAsksSet(jwtToken, 0, { + hiddenAsks: [...(volunteerAsks?.hiddenAsks || []), id], + }) + ) + }, [dispatch, id, jwtToken, volunteerAsks?.hiddenAsks]) + + const [retex] = useRetex() + const question1Default = "-1" + const dayWishes = get(retex, "dayWishes", "") + const question1 = +get(retex, "question1", question1Default) + const question2 = get(retex, "question2", "") + const question3 = get(retex, "question3", "") + const question4 = get(retex, "question4", "") + const question5 = get(retex, "question5", "") + const question6 = get(retex, "question6", "") + const question7 = get(retex, "question7", "") + const question8 = get(retex, "question8", "") + const question9 = get(retex, "question9", "") + const wasHereBeforeAfter = dayWishes.match(/M|J|V|L/) + const needToShow = + !!retex && + (question1 === -1 || + !question2 || + !question3 || + !question4 || + (wasHereBeforeAfter && !question5) || + !question6 || + !question7 || + !question8 || + !question9) + + addAsk( + asks, + id, + volunteerAsks, + false, + needToShow, + <> + {answerLaterOnProfile} + Tes réponses sont modifiable sur la page Mon profil jusqu'au 23 + septembre. + + ) +} + +// Fetch server-side data here +export const fetchFor = [...fetchForRetexForm] diff --git a/src/components/Asks/index.tsx b/src/components/Asks/index.tsx index 79acb2d..8f1aa8d 100644 --- a/src/components/Asks/index.tsx +++ b/src/components/Asks/index.tsx @@ -3,16 +3,18 @@ import React, { memo } from "react" import styles from "./styles.module.scss" import { useAskTools } from "./utils" import { AskWelcome } from "./AskWelcome" +import { AskBrunch, fetchFor as fetchForBrunch } from "./AskBrunch" +import { AskRetex, fetchFor as fetchForRetex } from "./AskRetex" import { AskDiscord, fetchFor as fetchForDiscord } from "./AskDiscord" -import { AskDayWishes, fetchFor as fetchForDayWishes } from "./AskDayWishes" -import { AskHosting, fetchFor as fetchForHosting } from "./AskHosting" +// import { AskDayWishes, fetchFor as fetchForDayWishes } from "./AskDayWishes" +// import { AskHosting, fetchFor as fetchForHosting } from "./AskHosting" // import { AskMeals, fetchFor as fetchForMeals } from "./AskMeals" -import { AskPersonalInfo, fetchFor as fetchForPersonalInfo } from "./AskPersonalInfo" -import { AskTeamWishes, fetchFor as fetchForTeamWishes } from "./AskTeamWishes" -import { - AskParticipationDetails, - fetchFor as fetchForParticipationDetails, -} from "./AskParticipationDetails" +// import { AskPersonalInfo, fetchFor as fetchForPersonalInfo } from "./AskPersonalInfo" +// import { AskTeamWishes, fetchFor as fetchForTeamWishes } from "./AskTeamWishes" +// import { +// AskParticipationDetails, +// fetchFor as fetchForParticipationDetails, +// } from "./AskParticipationDetails" import { AskPushNotif } from "./AskPushNotif" const Asks = (): JSX.Element | null => { @@ -20,13 +22,15 @@ const Asks = (): JSX.Element | null => { const asks: JSX.Element[] = [] AskWelcome(asks, 1) - AskDiscord(asks, 3) + AskBrunch(asks, 2) + AskRetex(asks, 3) + AskDiscord(asks, 5) - AskDayWishes(asks, 10) - AskTeamWishes(asks, 11) - AskParticipationDetails(asks, 12) - AskPersonalInfo(asks, 15) - AskHosting(asks, 20) + // AskDayWishes(asks, 10) + // AskTeamWishes(asks, 11) + // AskParticipationDetails(asks, 12) + // AskPersonalInfo(asks, 15) + // AskHosting(asks, 20) // AskMeals(asks, 22) AskPushNotif(asks, 99) @@ -62,11 +66,13 @@ export default memo(Asks) // Fetch server-side data here export const fetchFor = [ + ...fetchForBrunch, + ...fetchForRetex, ...fetchForDiscord, - ...fetchForDayWishes, - ...fetchForHosting, + // ...fetchForDayWishes, + // ...fetchForHosting, // ...fetchForMeals, - ...fetchForTeamWishes, - ...fetchForParticipationDetails, - ...fetchForPersonalInfo, + // ...fetchForTeamWishes, + // ...fetchForParticipationDetails, + // ...fetchForPersonalInfo, ] diff --git a/src/components/Form/IgnoreButton/IgnoreButton.tsx b/src/components/Form/IgnoreButton/IgnoreButton.tsx index f42499a..687dac0 100644 --- a/src/components/Form/IgnoreButton/IgnoreButton.tsx +++ b/src/components/Form/IgnoreButton/IgnoreButton.tsx @@ -37,7 +37,7 @@ const FormButton: FC = ({ children, text, onClick }): JSX.Element => {
{children}
)} diff --git a/src/components/Navigation/MainMenu.tsx b/src/components/Navigation/MainMenu.tsx index dafb203..9affa03 100644 --- a/src/components/Navigation/MainMenu.tsx +++ b/src/components/Navigation/MainMenu.tsx @@ -52,7 +52,7 @@ const MainMenu: FC = (): JSX.Element => { - + {/* */} {
- {["WhatsApp", "Signal", "SMS", "Email", "Appel", "Aucun"].map((option) => ( + {["WhatsApp", "Signal", "SMS", "Email", "Aucun"].map((option) => (