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 * as api from "@/lib/api"
import { serviceServerActionProcedure } from "@/server/trpc" 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 { passwordValidator } from "@/utils/passwordValidator"
import { phoneValidator } from "@/utils/phoneValidator" import { phoneValidator } from "@/utils/phoneValidator"
@@ -29,7 +29,7 @@ const registerUserPayload = z.object({
}) })
export const registerUser = serviceServerActionProcedure export const registerUser = serviceServerActionProcedure
.input(registerSchema) .input(signUpSchema)
.mutation(async function ({ ctx, input }) { .mutation(async function ({ ctx, input }) {
const payload = { const payload = {
...input, ...input,

View File

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

View File

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

View File

@@ -4,19 +4,13 @@ import { passwordValidator } from "@/utils/passwordValidator"
import { phoneValidator } from "@/utils/phoneValidator" import { phoneValidator } from "@/utils/phoneValidator"
const countryRequiredMsg = "Country is required" const countryRequiredMsg = "Country is required"
export const registerSchema = z.object({ export const signUpSchema = z.object({
firstName: z firstName: z.string().max(250).trim().min(1, {
.string() message: "First name is required",
.max(250) }),
.refine((value) => value.trim().length > 0, { lastName: z.string().max(250).trim().min(1, {
message: "First name is required", message: "Last name is required",
}), }),
lastName: z
.string()
.max(250)
.refine((value) => value.trim().length > 0, {
message: "Last name is required",
}),
email: z.string().max(250).email(), email: z.string().max(250).email(),
phoneNumber: phoneValidator( phoneNumber: phoneValidator(
"Phone is required", "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 } link?: { href: string; text: string }
subtitle?: string subtitle?: string
title: string title: string