mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-12 14:20:08 +02:00
Add Brunch and Retex forms ans asks
This commit is contained in:
39
src/components/Asks/AskBrunch.tsx
Normal file
39
src/components/Asks/AskBrunch.tsx
Normal file
@@ -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,
|
||||
<>
|
||||
<BrunchForm afterSubmit={onSubmit}>{answerLaterOnProfile}</BrunchForm>
|
||||
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]
|
59
src/components/Asks/AskRetex.tsx
Normal file
59
src/components/Asks/AskRetex.tsx
Normal file
@@ -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,
|
||||
<>
|
||||
<RetexForm afterSubmit={onSubmit}>{answerLaterOnProfile}</RetexForm>
|
||||
Tes réponses sont modifiable sur la page <a href="/profil">Mon profil</a> jusqu'au 23
|
||||
septembre.
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
// Fetch server-side data here
|
||||
export const fetchFor = [...fetchForRetexForm]
|
@@ -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,
|
||||
]
|
||||
|
Reference in New Issue
Block a user