Skip to content

Commit

Permalink
feat(ui): Extend the user creation form
Browse files Browse the repository at this point in the history
PR #1278 extends user creation by adding optional first name, last name
and email to the user information.

Add these fields to the user creation form and mark them as optional.

Signed-off-by: Jyrki Keisala <[email protected]>
  • Loading branch information
Etsija committed Oct 24, 2024
1 parent ce6083e commit 7fa954c
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions ui/src/routes/_layout/admin/users/create-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ import { toast } from '@/lib/toast';

const formSchema = z.object({
username: z.string(),
firstName: z.string().optional(),
lastName: z.string().optional(),
email: z.string().email().optional(),
password: z.string().optional(),
temporary: z.boolean(),
});
Expand Down Expand Up @@ -82,6 +85,9 @@ const CreateUser = () => {
await mutateAsync({
requestBody: {
username: values.username,
firstName: values.firstName,
lastName: values.lastName,
email: values.email,
password: values.password,
temporary: values.temporary,
},
Expand Down Expand Up @@ -109,6 +115,45 @@ const CreateUser = () => {
</FormItem>
)}
/>
<FormField
control={form.control}
name='firstName'
render={({ field }) => (
<FormItem>
<FormLabel>First name</FormLabel>
<FormControl>
<Input {...field} placeholder='(optional)' />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name='lastName'
render={({ field }) => (
<FormItem>
<FormLabel>Last name</FormLabel>
<FormControl>
<Input {...field} placeholder='(optional)' />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name='email'
render={({ field }) => (
<FormItem>
<FormLabel>Email address</FormLabel>
<FormControl>
<Input type='email' {...field} placeholder='(optional)' />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name='password'
Expand Down

0 comments on commit 7fa954c

Please sign in to comment.