Skip to content

Commit

Permalink
chore: use full name instead of first name and last name
Browse files Browse the repository at this point in the history
  • Loading branch information
tienan92it committed Sep 27, 2023
1 parent ce2248e commit b64eaa3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
18 changes: 5 additions & 13 deletions src/components/Header/ProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ interface Props {
}

const validationSchema = z.object({
firstName: z.string().min(1, 'First name is required.'),
lastName: z.string().min(1, 'Last name is required.'),
fullName: z.string().min(1, 'Full name is required.'),
})

export const ProfileModal = (props: Props) => {
const { trigger, open, onOpenChange } = props
const { user } = useAuthContext()
const formInstance = useForm({
defaultValues: { firstName: user.firstName, lastName: user.lastName },
defaultValues: { fullName: user?.fullName },
resolver: zodResolver(validationSchema),
})
const { handleSubmit } = formInstance
Expand All @@ -55,16 +54,9 @@ export const ProfileModal = (props: Props) => {
<form className="mt-5" onSubmit={handleSubmit(onSubmit)}>
<div className="space-y-5 mb-8">
<FormInput
label="First name"
name="firstName"
placeholder="First name"
rules={{ required: 'Required' }}
fullWidth
/>
<FormInput
label="Last name"
name="lastName"
placeholder="Last name"
label="Full name"
name="fullName"
placeholder="Full name"
rules={{ required: 'Required' }}
fullWidth
/>
Expand Down
18 changes: 4 additions & 14 deletions src/pages/forms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import { FormCheckboxGroup } from 'components/FormCheckboxGroup'
import { Checkbox } from 'components/Checkbox'

const personalFormDefaultValues = {
firstName: '',
lastName: '',
fullName: '',
email: '',
country: '',
address: '',
Expand All @@ -24,8 +23,7 @@ const personalFormDefaultValues = {
}

const personalFormValidationSchema = z.object({
firstName: z.string().min(1, 'First name is required.'),
lastName: z.string().min(1, 'Last name is required.'),
fullName: z.string().min(1, 'Full name is required.'),
email: z.string().email(),
})

Expand All @@ -46,16 +44,8 @@ const PersonalForm = () => {
<div className="grid grid-cols-6 gap-6 p-6">
<div className="col-span-3">
<FormInput
label="First name"
name="firstName"
rules={{ required: 'Required' }}
fullWidth
/>
</div>
<div className="col-span-3">
<FormInput
label="Last name"
name="lastName"
label="Full name"
name="fullName"
rules={{ required: 'Required' }}
fullWidth
/>
Expand Down

0 comments on commit b64eaa3

Please sign in to comment.