3131 />
3232 </UFormField >
3333
34+ <UFormField :label =" $t (' common.phone' )" name="phone">
35+ <UInput
36+ v-model =" state .phone "
37+ size="xl"
38+ class="w-full items-center justify-center"
39+ />
40+ </UFormField >
41+
3442 <UFormField :label =" $t (' common.caption' )" name="caption">
3543 <UInput
3644 v-model =" state .caption "
3947 />
4048 </UFormField >
4149
50+ <UFormField :label =" $t (' common.gender.title' )" name="gender">
51+ <USelect
52+ v-model =" state .gender "
53+ :items =" getLocalizedGenderForSelect ()"
54+ :placeholder =" $t (' common.select' )"
55+ size="xl"
56+ class="w-full"
57+ />
58+ </UFormField >
59+
4260 <UButton
4361 type="submit"
4462 variant="solid"
@@ -56,31 +74,40 @@ import type { FormSubmitEvent } from '@nuxt/ui'
5674import type { UpdateUser } from ' ~~/shared/services/user'
5775import { updateUserSchema } from ' ~~/shared/services/user'
5876
77+ const { userId } = defineProps <{ userId: string }>()
78+
5979const emit = defineEmits ([' success' , ' submitted' ])
6080
6181const { t } = useI18n ()
6282const actionToast = useActionToast ()
6383
84+ const partnerStore = usePartnerStore ()
6485const userStore = useUserStore ()
86+ const user = userStore .find (userId )
6587
6688const state = ref <Partial <UpdateUser >>({
67- name: userStore .name ,
68- surname: userStore .surname ,
69- email: userStore .email ?? undefined ,
70- caption: userStore .caption ,
89+ name: user ?.name ,
90+ surname: user ?.surname ,
91+ email: user ?.email ?? undefined ,
92+ phone: user ?.phone ?? undefined ,
93+ caption: user ?.caption ,
94+ gender: user ?.gender ,
7195})
7296
7397async function onSubmit(event : FormSubmitEvent <UpdateUser >) {
7498 const toastId = actionToast .start ()
7599 emit (' submitted' )
76100
77101 try {
78- await $fetch (` /api/user/id/${userStore .id } ` , {
102+ await $fetch (` /api/user/id/${user ? .id } ` , {
79103 method: ' PATCH' ,
80104 body: event .data ,
81105 })
82106
83- await userStore .update ()
107+ await Promise .all ([
108+ userStore .update (),
109+ partnerStore .update (),
110+ ])
84111
85112 actionToast .success (toastId , t (' toast.user-updated' ))
86113 emit (' success' )
0 commit comments