Add volunteerDayWishesSet in store

This commit is contained in:
pikiou
2022-01-21 07:34:50 +01:00
parent fc65a2d42b
commit 93e82a36ee
11 changed files with 256 additions and 38 deletions

View File

@@ -28,17 +28,17 @@ const HomePage: FC<Props> = (): JSX.Element => {
}, shallowEqual)
const [teamWishes, setTeamWishes] = useState(wishesForm?.teamWishes.join(",") || "")
const [teamWishComment, setTeamWishComment] = useState(wishesForm?.teamWishComment || "")
const [teamWishesComment, setTeamWishesComment] = useState(wishesForm?.teamWishesComment || "")
useEffect(() => {
setTeamWishes(wishesForm?.teamWishes.join(",") || "")
setTeamWishComment(wishesForm?.teamWishComment || "")
setTeamWishesComment(wishesForm?.teamWishesComment || "")
}, [wishesForm])
const onTeamWishesChanged = (e: React.ChangeEvent<HTMLInputElement>) =>
setTeamWishes(e.target.value)
const onTeamWishCommentChanged = (e: React.ChangeEvent<HTMLInputElement>) =>
setTeamWishComment(e.target.value)
const onTeamWishesCommentChanged = (e: React.ChangeEvent<HTMLInputElement>) =>
setTeamWishesComment(e.target.value)
const onSubmit = useCallback(
(event: React.SyntheticEvent): void => {
@@ -51,11 +51,11 @@ const HomePage: FC<Props> = (): JSX.Element => {
fetchVolunteerTeamWishesSet(jwtToken, 0, {
id: wishesForm.id,
teamWishes: (teamWishes || "").split(","),
teamWishComment,
teamWishesComment,
})
)
},
[dispatch, jwtToken, wishesForm, teamWishes, teamWishComment]
[dispatch, jwtToken, wishesForm, teamWishes, teamWishesComment]
)
if (jwtToken === undefined) return <p>Loading...</p>
@@ -73,10 +73,10 @@ const HomePage: FC<Props> = (): JSX.Element => {
<br />
<input
type="text"
id="teamWishComment"
id="teamWishesComment"
required
value={teamWishComment}
onChange={onTeamWishCommentChanged}
value={teamWishesComment}
onChange={onTeamWishesCommentChanged}
/>
<button type="button" onClick={onSubmit}>
Envoyer