chore(SW-360): use signup naming

This commit is contained in:
Chuma McPhoy
2024-10-23 11:41:20 +02:00
parent 158bae92ae
commit 94744a4260
6 changed files with 19 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
"use client"
import { zodResolver } from "@hookform/resolvers/zod"
import { useEffect,useState } from "react"
import { FormProvider, useForm } from "react-hook-form"
import { useIntl } from "react-intl"
@@ -22,16 +23,16 @@ import Title from "@/components/TempDesignSystem/Text/Title"
import { toast } from "@/components/TempDesignSystem/Toasts"
import useLang from "@/hooks/useLang"
import { RegisterSchema, registerSchema } from "./schema"
import { SignUpSchema, signUpSchema } from "./schema"
import styles from "./form.module.css"
import type { RegisterFormProps } from "@/types/components/form/registerForm"
import type { SignUpFormProps } from "@/types/components/form/signupForm"
export default function Form({ link, subtitle, title }: RegisterFormProps) {
export default function Form({ link, subtitle, title }: SignUpFormProps) {
const intl = useIntl()
const lang = useLang()
const methods = useForm<RegisterSchema>({
const methods = useForm<SignUpSchema>({
defaultValues: {
firstName: "",
lastName: "",
@@ -47,7 +48,7 @@ export default function Form({ link, subtitle, title }: RegisterFormProps) {
},
mode: "all",
criteriaMode: "all",
resolver: zodResolver(registerSchema),
resolver: zodResolver(signUpSchema),
reValidateMode: "onChange",
})
const country = intl.formatMessage({ id: "Country" })
@@ -55,7 +56,7 @@ export default function Form({ link, subtitle, title }: RegisterFormProps) {
const phoneNumber = intl.formatMessage({ id: "Phone number" })
const zipCode = intl.formatMessage({ id: "Zip code" })
async function handleSubmit(data: RegisterSchema) {
async function handleSubmit(data: SignUpSchema) {
try {
const result = await registerUser(data)
if (result && !result.success) {

View File

@@ -4,19 +4,13 @@ import { passwordValidator } from "@/utils/passwordValidator"
import { phoneValidator } from "@/utils/phoneValidator"
const countryRequiredMsg = "Country is required"
export const registerSchema = z.object({
firstName: z
.string()
.max(250)
.refine((value) => value.trim().length > 0, {
message: "First name is required",
}),
lastName: z
.string()
.max(250)
.refine((value) => value.trim().length > 0, {
message: "Last name is required",
}),
export const signUpSchema = z.object({
firstName: z.string().max(250).trim().min(1, {
message: "First name is required",
}),
lastName: z.string().max(250).trim().min(1, {
message: "Last name is required",
}),
email: z.string().max(250).email(),
phoneNumber: phoneValidator(
"Phone is required",
@@ -38,4 +32,4 @@ export const registerSchema = z.object({
}),
})
export type RegisterSchema = z.infer<typeof registerSchema>
export type SignUpSchema = z.infer<typeof signUpSchema>