mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-08 08:34:20 +02:00
Add hosting Ask
This commit is contained in:
parent
032e15d985
commit
fac06c1b41
@ -2,12 +2,12 @@ import { get } from "lodash"
|
|||||||
import { useCallback } from "react"
|
import { useCallback } from "react"
|
||||||
import { fetchVolunteerAsksSet } from "../../store/volunteerAsksSet"
|
import { fetchVolunteerAsksSet } from "../../store/volunteerAsksSet"
|
||||||
import { useAskTools, addAsk, answerLaterOnProfile } from "./utils"
|
import { useAskTools, addAsk, answerLaterOnProfile } from "./utils"
|
||||||
import ParticipationDetailsForm, {
|
import HostingForm, {
|
||||||
fetchFor as fetchForParticipationDetailsForm,
|
fetchFor as fetchForHostingForm,
|
||||||
} from "../VolunteerBoard/ParticipationDetailsForm/ParticipationDetailsForm"
|
} from "../VolunteerBoard/HostingForm/HostingForm"
|
||||||
import { useUserParticipationDetails } from "../VolunteerBoard/participationDetails.utils"
|
import { useUserHosting } from "../VolunteerBoard/hosting.utils"
|
||||||
|
|
||||||
export function AskParticipationDetails(asks: JSX.Element[], id: number): void {
|
export function AskHosting(asks: JSX.Element[], id: number): void {
|
||||||
const { dispatch, jwtToken, volunteerAsks } = useAskTools()
|
const { dispatch, jwtToken, volunteerAsks } = useAskTools()
|
||||||
|
|
||||||
const onSubmit = useCallback((): void => {
|
const onSubmit = useCallback((): void => {
|
||||||
@ -18,10 +18,13 @@ export function AskParticipationDetails(asks: JSX.Element[], id: number): void {
|
|||||||
)
|
)
|
||||||
}, [dispatch, id, jwtToken, volunteerAsks?.hiddenAsks])
|
}, [dispatch, id, jwtToken, volunteerAsks?.hiddenAsks])
|
||||||
|
|
||||||
const [participationDetails] = useUserParticipationDetails()
|
const [hosting] = useUserHosting()
|
||||||
const tshirtSize = get(participationDetails, "tshirtSize", "")
|
const needsHosting = get(hosting, "needsHosting", false)
|
||||||
const food = get(participationDetails, "food", "")
|
const canHostCount = get(hosting, "canHostCount", 0)
|
||||||
const needToShow = !tshirtSize || !food
|
const distanceToFestival = get(hosting, "distanceToFestival", 0)
|
||||||
|
const hostingComment = get(hosting, "hostingComment", "")
|
||||||
|
const needToShow =
|
||||||
|
!needsHosting && canHostCount === 0 && distanceToFestival === 0 && hostingComment === ""
|
||||||
|
|
||||||
addAsk(
|
addAsk(
|
||||||
asks,
|
asks,
|
||||||
@ -29,11 +32,9 @@ export function AskParticipationDetails(asks: JSX.Element[], id: number): void {
|
|||||||
volunteerAsks,
|
volunteerAsks,
|
||||||
false,
|
false,
|
||||||
needToShow,
|
needToShow,
|
||||||
<ParticipationDetailsForm afterSubmit={onSubmit}>
|
<HostingForm afterSubmit={onSubmit}>{answerLaterOnProfile}</HostingForm>
|
||||||
{answerLaterOnProfile}
|
|
||||||
</ParticipationDetailsForm>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch server-side data here
|
// Fetch server-side data here
|
||||||
export const fetchFor = [...fetchForParticipationDetailsForm]
|
export const fetchFor = [...fetchForHostingForm]
|
||||||
|
@ -5,6 +5,7 @@ import { useAskTools } from "./utils"
|
|||||||
import { AskWelcome } from "./AskWelcome"
|
import { AskWelcome } from "./AskWelcome"
|
||||||
import { AskDiscord, fetchFor as fetchForDiscord } from "./AskDiscord"
|
import { AskDiscord, fetchFor as fetchForDiscord } from "./AskDiscord"
|
||||||
import { AskDayWishes, fetchFor as fetchForDayWishes } from "./AskDayWishes"
|
import { AskDayWishes, fetchFor as fetchForDayWishes } from "./AskDayWishes"
|
||||||
|
import { AskHosting, fetchFor as fetchForHosting } from "./AskHosting"
|
||||||
import { AskTeamWishes, fetchFor as fetchForTeamWishes } from "./AskTeamWishes"
|
import { AskTeamWishes, fetchFor as fetchForTeamWishes } from "./AskTeamWishes"
|
||||||
import {
|
import {
|
||||||
AskParticipationDetails,
|
AskParticipationDetails,
|
||||||
@ -22,6 +23,7 @@ const Asks = (): JSX.Element | null => {
|
|||||||
AskDayWishes(asks, 10)
|
AskDayWishes(asks, 10)
|
||||||
AskTeamWishes(asks, 11)
|
AskTeamWishes(asks, 11)
|
||||||
AskParticipationDetails(asks, 12)
|
AskParticipationDetails(asks, 12)
|
||||||
|
AskHosting(asks, 20)
|
||||||
|
|
||||||
AskPushNotif(asks, 99)
|
AskPushNotif(asks, 99)
|
||||||
|
|
||||||
@ -58,6 +60,7 @@ export default memo(Asks)
|
|||||||
export const fetchFor = [
|
export const fetchFor = [
|
||||||
...fetchForDiscord,
|
...fetchForDiscord,
|
||||||
...fetchForDayWishes,
|
...fetchForDayWishes,
|
||||||
|
...fetchForHosting,
|
||||||
...fetchForTeamWishes,
|
...fetchForTeamWishes,
|
||||||
...fetchForParticipationDetails,
|
...fetchForParticipationDetails,
|
||||||
]
|
]
|
||||||
|
@ -41,7 +41,7 @@ const HostingForm: FC<Props> = ({ children, afterSubmit }): JSX.Element => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className={styles.title}>Mes jours de présence</div>
|
<div className={styles.title}>Mon hébergement</div>
|
||||||
<div className={classnames(styles.inputWrapper, styles.noBottomMargin)}>
|
<div className={classnames(styles.inputWrapper, styles.noBottomMargin)}>
|
||||||
<div className={styles.leftCol}>
|
<div className={styles.leftCol}>
|
||||||
<div className={styles.needsHostingTitle}>
|
<div className={styles.needsHostingTitle}>
|
||||||
|
@ -243,7 +243,7 @@ export const volunteerAsksSet = expressAccessor.set(async (list, body, id) => {
|
|||||||
}
|
}
|
||||||
const newVolunteer = cloneDeep(volunteer)
|
const newVolunteer = cloneDeep(volunteer)
|
||||||
|
|
||||||
if (notifChanges.teamWishes !== undefined) newVolunteer.hiddenAsks = notifChanges.hiddenAsks
|
if (notifChanges.hiddenAsks !== undefined) newVolunteer.hiddenAsks = notifChanges.hiddenAsks
|
||||||
if (notifChanges.acceptsNotifs !== undefined)
|
if (notifChanges.acceptsNotifs !== undefined)
|
||||||
newVolunteer.acceptsNotifs = notifChanges.acceptsNotifs
|
newVolunteer.acceptsNotifs = notifChanges.acceptsNotifs
|
||||||
if (notifChanges.pushNotifSubscription !== undefined)
|
if (notifChanges.pushNotifSubscription !== undefined)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user