update account form for email login
This commit is contained in:
@@ -12,7 +12,9 @@ const updateAccountSchema = {
|
||||
.string({
|
||||
error: 'Last name is required',
|
||||
})
|
||||
.nonempty(),
|
||||
.nonempty({
|
||||
error: 'common:formFieldError.stringNonEmpty',
|
||||
}),
|
||||
personalCode: z.string().refine(
|
||||
(val) => {
|
||||
try {
|
||||
@@ -30,7 +32,7 @@ const updateAccountSchema = {
|
||||
}),
|
||||
phone: z
|
||||
.string({
|
||||
error: 'Phone number is required',
|
||||
error: 'error:invalidPhone',
|
||||
})
|
||||
.nonempty()
|
||||
.refine(
|
||||
@@ -75,18 +77,26 @@ export const UpdateAccountSchemaServer = z.object({
|
||||
email: updateAccountSchema.email,
|
||||
phone: updateAccountSchema.phone,
|
||||
city: updateAccountSchema.city,
|
||||
weight: updateAccountSchema.weight,
|
||||
height: updateAccountSchema.height,
|
||||
weight: updateAccountSchema.weight.nullable(),
|
||||
height: updateAccountSchema.height.nullable(),
|
||||
userConsent: updateAccountSchema.userConsent,
|
||||
});
|
||||
export const UpdateAccountSchemaClient = z.object({
|
||||
export const UpdateAccountSchemaClient = ({ isEmailUser }: { isEmailUser: boolean }) => z.object({
|
||||
firstName: updateAccountSchema.firstName,
|
||||
lastName: updateAccountSchema.lastName,
|
||||
personalCode: updateAccountSchema.personalCode,
|
||||
email: updateAccountSchema.email,
|
||||
phone: updateAccountSchema.phone,
|
||||
city: updateAccountSchema.city,
|
||||
weight: updateAccountSchema.weight.gt(-1).gte(0).nullable(),
|
||||
height: updateAccountSchema.height.gt(-1).gte(0).nullable(),
|
||||
...(isEmailUser
|
||||
? {
|
||||
city: z.string().optional(),
|
||||
weight: z.number().optional(),
|
||||
height: z.number().optional(),
|
||||
}
|
||||
: {
|
||||
city: updateAccountSchema.city,
|
||||
weight: updateAccountSchema.weight,
|
||||
height: updateAccountSchema.height,
|
||||
}),
|
||||
userConsent: updateAccountSchema.userConsent,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user