mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-08 08:34:20 +02:00
fix ParticipationDetailsForm
This commit is contained in:
parent
444582c5cc
commit
67a8e84bd5
@ -2,7 +2,11 @@ import { FC, memo, useCallback, useEffect, useRef, useState } from "react"
|
||||
import get from "lodash/get"
|
||||
import set from "lodash/set"
|
||||
import styles from "./styles.module.scss"
|
||||
import { tShirtSizes, useUserParticipationDetails } from "../participationDetails.utils"
|
||||
import {
|
||||
foodDefaultValue,
|
||||
tShirtSizes,
|
||||
useUserParticipationDetails,
|
||||
} from "../participationDetails.utils"
|
||||
|
||||
const ParticipationDetailsForm: FC = (): JSX.Element | null => {
|
||||
const sizeRef = useRef<HTMLSelectElement | null>(null)
|
||||
@ -15,7 +19,7 @@ const ParticipationDetailsForm: FC = (): JSX.Element | null => {
|
||||
const onSubmit = useCallback(() => {
|
||||
const age = get(ageRef, "current.value", "")
|
||||
const teeshirtSize = has2Shirts ? "" : get(sizeRef, "current.value", "")
|
||||
const food = get(dietRef, "current.value", "")
|
||||
const food = get(dietRef, "current.value", foodDefaultValue)
|
||||
saveParticipationDetails({ age, teeshirtSize, food })
|
||||
}, [has2Shirts, saveParticipationDetails])
|
||||
|
||||
@ -27,7 +31,6 @@ const ParticipationDetailsForm: FC = (): JSX.Element | null => {
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
console.log("participationDetails", participationDetails)
|
||||
const age = get(participationDetails, "age", "")
|
||||
const teeshirtSize = get(participationDetails, "teeshirtSize", "")
|
||||
const food = get(participationDetails, "food", "")
|
||||
@ -47,7 +50,7 @@ const ParticipationDetailsForm: FC = (): JSX.Element | null => {
|
||||
<input
|
||||
type="radio"
|
||||
name="hasShirt"
|
||||
onClick={() => onHas2ShirtsClick(true)}
|
||||
onChange={() => onHas2ShirtsClick(true)}
|
||||
checked={has2Shirts}
|
||||
/>{" "}
|
||||
Oui
|
||||
@ -56,7 +59,7 @@ const ParticipationDetailsForm: FC = (): JSX.Element | null => {
|
||||
<input
|
||||
type="radio"
|
||||
name="hasShirt"
|
||||
onClick={() => onHas2ShirtsClick(false)}
|
||||
onChange={() => onHas2ShirtsClick(false)}
|
||||
checked={!has2Shirts}
|
||||
/>{" "}
|
||||
Non
|
||||
|
@ -18,6 +18,8 @@ export const tShirtSizes = [
|
||||
"Femme XL",
|
||||
]
|
||||
|
||||
export const foodDefaultValue = "Aucune"
|
||||
|
||||
export const useUserParticipationDetails = (): [any, any] => {
|
||||
const save = useAction(fetchVolunteerParticipationDetailsSet)
|
||||
const jwtToken = useSelector(selectUserJwtToken)
|
||||
|
Loading…
x
Reference in New Issue
Block a user