From 0ee37f2af12f3033843b89433668c1c2f88ccd34 Mon Sep 17 00:00:00 2001 From: stampaaaron Date: Wed, 26 Feb 2025 09:05:25 +0000 Subject: [PATCH 1/2] fix: prefilling participant form on edit --- .../administration/participants/edit.$id.tsx | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/apps/frontend/src/routes/_auth/administration/participants/edit.$id.tsx b/apps/frontend/src/routes/_auth/administration/participants/edit.$id.tsx index a1a19f6d..9bd604e3 100644 --- a/apps/frontend/src/routes/_auth/administration/participants/edit.$id.tsx +++ b/apps/frontend/src/routes/_auth/administration/participants/edit.$id.tsx @@ -1,11 +1,13 @@ import { createFileRoute, useNavigate } from "@tanstack/react-router"; -import { components } from "../../../../api.gen"; import { $api } from "../../../../stores/api"; import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query"; -import { Button, TextInput, useForm } from "@quassel/ui"; +import { Button, DateInput, Stack, TextInput, useForm } from "@quassel/ui"; import { useEffect } from "react"; -type FormValues = components["schemas"]["ParticipantMutationDto"]; +type FormValues = { + id: string; + birthday: Date; +}; function AdministrationParticipantsEdit() { const p = Route.useParams(); @@ -27,27 +29,30 @@ function AdministrationParticipantsEdit() { }, }); const f = useForm(); - const handleSubmit = (values: FormValues) => { + const handleSubmit = ({ id, birthday }: FormValues) => { editParticipantMutation.mutate({ - body: { ...values }, + body: { id: +id, birthday: birthday.toISOString() }, params: { path: { id: p.id } }, }); }; useEffect(() => { - f.setValues(participant.data ?? {}); - f.resetDirty(); + const { birthday, id } = participant.data; + + f.setValues({ birthday: new Date(birthday!), id: id.toString() }); }, [participant.isSuccess, participant.data]); return ( <>
- - + + + - + + ); From e2664f8514ceaab1b334ad7d3d5f0c4f43ce5d9d Mon Sep 17 00:00:00 2001 From: stampaaaron Date: Wed, 26 Feb 2025 09:05:46 +0000 Subject: [PATCH 2/2] ci: add changeset --- .changeset/unlucky-frogs-whisper.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/unlucky-frogs-whisper.md diff --git a/.changeset/unlucky-frogs-whisper.md b/.changeset/unlucky-frogs-whisper.md new file mode 100644 index 00000000..cdd7bf37 --- /dev/null +++ b/.changeset/unlucky-frogs-whisper.md @@ -0,0 +1,5 @@ +--- +"@quassel/frontend": patch +--- + +Fix prefilling participant form on edit