From 459ef4a85d3437f6005e2544e83209fb9f4db565 Mon Sep 17 00:00:00 2001 From: pikiou Date: Mon, 22 May 2023 08:26:15 +0200 Subject: [PATCH] Update meals, tee-shirt and hosting forms --- src/components/Asks/AskHosting.tsx | 8 +- src/components/Asks/AskMeals.tsx | 16 +- src/components/Asks/index.tsx | 29 +- src/components/Asks/utils.tsx | 9 + src/components/VolunteerBoard/Board.tsx | 36 +- .../VolunteerBoard/Hosting/Hosting.tsx | 33 +- .../HostingForm/HostingForm.tsx | 533 ++++++++++++++++-- .../HostingForm/styles.module.scss | 111 ++-- src/components/VolunteerBoard/Meals/Meals.tsx | 24 +- .../VolunteerBoard/MealsForm/MealsForm.tsx | 49 +- .../MealsForm/styles.module.scss | 4 +- .../ParticipationDetails.tsx | 53 +- .../ParticipationDetailsForm.tsx | 101 +--- .../TeamWishesForm/TeamWishesForm.tsx | 4 +- .../VolunteerBoard/hosting.utils.ts | 102 +++- src/components/VolunteerBoard/meals.utils.ts | 32 +- .../participationDetails.utils.ts | 67 ++- src/server/gsheets/volunteers.ts | 73 ++- src/services/accessors.ts | 10 +- src/services/volunteers.ts | 78 ++- src/store/volunteerMealsSet.ts | 3 +- 21 files changed, 991 insertions(+), 384 deletions(-) diff --git a/src/components/Asks/AskHosting.tsx b/src/components/Asks/AskHosting.tsx index b04bf81..11b3f25 100644 --- a/src/components/Asks/AskHosting.tsx +++ b/src/components/Asks/AskHosting.tsx @@ -19,12 +19,8 @@ export function AskHosting(asks: JSX.Element[], id: number): void { }, [dispatch, id, jwtToken, volunteerAsks?.hiddenAsks]) const [hosting] = useUserHosting() - const needsHosting = get(hosting, "needsHosting", false) - const canHostCount = get(hosting, "canHostCount", 0) - const distanceToFestival = get(hosting, "distanceToFestival", 0) - const hostingComment = get(hosting, "hostingComment", "") - const needToShow = - !needsHosting && canHostCount === 0 && distanceToFestival === 0 && hostingComment === "" + const hostingType = get(hosting, "hostingType", false) + const needToShow = hostingType === "" addAsk( asks, diff --git a/src/components/Asks/AskMeals.tsx b/src/components/Asks/AskMeals.tsx index 65ba699..f40b90d 100644 --- a/src/components/Asks/AskMeals.tsx +++ b/src/components/Asks/AskMeals.tsx @@ -1,7 +1,7 @@ import { get } from "lodash" import { useCallback } from "react" import { fetchVolunteerAsksSet } from "../../store/volunteerAsksSet" -import { useAskTools, addAsk, answerLaterOnProfile } from "./utils" +import { useAskTools, addAsk, answerLaterOnProfileBefore } from "./utils" import MealsForm, { fetchFor as fetchForMealsForm } from "../VolunteerBoard/MealsForm/MealsForm" import { useUserMeals } from "../VolunteerBoard/meals.utils" @@ -16,13 +16,9 @@ export function AskMeals(asks: JSX.Element[], id: number): void { ) }, [dispatch, id, jwtToken, volunteerAsks?.hiddenAsks]) - const [meals] = useUserMeals() - const needsMeals = get(meals, "needsMeals", false) - const canHostCount = get(meals, "canHostCount", 0) - const distanceToFestival = get(meals, "distanceToFestival", 0) - const mealsComment = get(meals, "mealsComment", "") - const needToShow = - !needsMeals && canHostCount === 0 && distanceToFestival === 0 && mealsComment === "" + const [userMeals] = useUserMeals() + const meals = get(userMeals, "meals", []) + const needToShow = meals.length === 0 addAsk( asks, @@ -30,7 +26,9 @@ export function AskMeals(asks: JSX.Element[], id: number): void { volunteerAsks, false, needToShow, - {answerLaterOnProfile} + + {answerLaterOnProfileBefore("31 mai à minuit pour commander les repas !")} + ) } diff --git a/src/components/Asks/index.tsx b/src/components/Asks/index.tsx index 7e28a9c..d08ce1d 100644 --- a/src/components/Asks/index.tsx +++ b/src/components/Asks/index.tsx @@ -7,14 +7,14 @@ import { AskWelcome } from "./AskWelcome" // 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 { AskMeals, fetchFor as fetchForMeals } from "./AskMeals" +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 { + AskParticipationDetails, + fetchFor as fetchForParticipationDetails, +} from "./AskParticipationDetails" // import { AskPushNotif } from "./AskPushNotif" const Asks = (): JSX.Element | null => { @@ -28,10 +28,10 @@ const Asks = (): JSX.Element | null => { AskDayWishes(asks, 10) AskTeamWishes(asks, 11) - // AskParticipationDetails(asks, 12) - // AskPersonalInfo(asks, 15) - // AskHosting(asks, 20) - // AskMeals(asks, 22) + AskMeals(asks, 15) + // AskPersonalInfo(asks, 16) + AskHosting(asks, 20) + AskParticipationDetails(asks, 22) // AskPushNotif(asks, 99) @@ -42,6 +42,9 @@ const Asks = (): JSX.Element | null => {