1
1
import { createFileRoute , useNavigate } from "@tanstack/react-router" ;
2
- import { components } from "../../../../api.gen" ;
3
2
import { $api } from "../../../../stores/api" ;
4
3
import { useQueryClient , useSuspenseQuery } from "@tanstack/react-query" ;
5
- import { Button , TextInput , useForm } from "@quassel/ui" ;
4
+ import { Button , DateInput , Stack , TextInput , useForm } from "@quassel/ui" ;
6
5
import { useEffect } from "react" ;
7
6
8
- type FormValues = components [ "schemas" ] [ "ParticipantMutationDto" ] ;
7
+ type FormValues = {
8
+ id : string ;
9
+ birthday : Date ;
10
+ } ;
9
11
10
12
function AdministrationParticipantsEdit ( ) {
11
13
const p = Route . useParams ( ) ;
@@ -27,27 +29,30 @@ function AdministrationParticipantsEdit() {
27
29
} ,
28
30
} ) ;
29
31
const f = useForm < FormValues > ( ) ;
30
- const handleSubmit = ( values : FormValues ) => {
32
+ const handleSubmit = ( { id , birthday } : FormValues ) => {
31
33
editParticipantMutation . mutate ( {
32
- body : { ... values } ,
34
+ body : { id : + id , birthday : birthday . toISOString ( ) } ,
33
35
params : { path : { id : p . id } } ,
34
36
} ) ;
35
37
} ;
36
38
37
39
useEffect ( ( ) => {
38
- f . setValues ( participant . data ?? { } ) ;
39
- f . resetDirty ( ) ;
40
+ const { birthday, id } = participant . data ;
41
+
42
+ f . setValues ( { birthday : new Date ( birthday ! ) , id : id . toString ( ) } ) ;
40
43
} , [ participant . isSuccess , participant . data ] ) ;
41
44
42
45
return (
43
46
< >
44
47
< form autoComplete = "off" onSubmit = { f . onSubmit ( handleSubmit ) } >
45
- < TextInput label = "Id" type = "text" { ...f . getInputProps ( "id" ) } required />
46
- < TextInput label = "Birthday" type = "date" { ...f . getInputProps ( "birthday" ) } required />
48
+ < Stack >
49
+ < TextInput label = "Id" type = "text" { ...f . getInputProps ( "id" ) } required />
50
+ < DateInput label = "Birthday" { ...f . getInputProps ( "birthday" ) } required />
47
51
48
- < Button type = "submit" fullWidth mt = "xl" loading = { editParticipantMutation . isPending } >
49
- Change
50
- </ Button >
52
+ < Button type = "submit" fullWidth loading = { editParticipantMutation . isPending } >
53
+ Change
54
+ </ Button >
55
+ </ Stack >
51
56
</ form >
52
57
</ >
53
58
) ;
0 commit comments