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

@@ -7,7 +7,7 @@ import { signupVerify } from "@/constants/routes/signup"
import * as api from "@/lib/api"
import { serviceServerActionProcedure } from "@/server/trpc"
import { registerSchema } from "@/components/Forms/Register/schema"
import { signUpSchema } from "@/components/Forms/Signup/schema"
import { passwordValidator } from "@/utils/passwordValidator"
import { phoneValidator } from "@/utils/phoneValidator"
@@ -29,7 +29,7 @@ const registerUserPayload = z.object({
})
export const registerUser = serviceServerActionProcedure
.input(registerSchema)
.input(signUpSchema)
.mutation(async function ({ ctx, input }) {
const payload = {
...input,

View File

@@ -3,7 +3,7 @@ import { redirect } from "next/navigation"
import { overview } from "@/constants/routes/myPages"
import { auth } from "@/auth"
import Form from "@/components/Forms/Register"
import Form from "@/components/Forms/Signup"
import { getLang } from "@/i18n/serverContext"
import { SignupFormWrapperProps } from "@/types/components/blocks/dynamicContent"

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>

View File

@@ -1,4 +1,4 @@
export type RegisterFormProps = {
export type SignUpFormProps = {
link?: { href: string; text: string }
subtitle?: string
title: string