cleanup register and login

This commit is contained in:
Alex Holliday committed 2025-12-27 16:07:57 +00:00
1 parent a967c12ba5
commit 7961a9a88e
9 files changed
+36 -37

No files matched your search

+2 -6
View File
@@ -15,13 +15,11 @@ import {
logout,
} from "@/features/authSlice";
import { z } from "zod";
import { loginSchema } from "@/validation";
import { useForm, Controller } from "react-hook-form";
import type { IUser } from "@/types/user";
const schema = z.object({
email: z.email("Invalid email address"),
password: z.string().min(6, "Password must be at least 6 characters"),
});
const schema = loginSchema;
type FormData = z.infer<typeof schema>;
@@ -99,7 +97,6 @@ const Login = () => {
<Controller
name="email"
control={control}
defaultValue=""
render={({ field }) => (
<TextInput
{...field}
@@ -114,7 +111,6 @@ const Login = () => {
<Controller
name="password"
control={control}
defaultValue=""
render={({ field }) => (
<TextInput
{...field}
+1 -1
View File
@@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next";
import { usePost } from "@/hooks/UseApi";
import { useNavigate } from "react-router";
import { z } from "zod";
import { registerSchema } from "@/validation/zod";
import { registerSchema } from "@/validation";
type FormData = z.infer<typeof registerSchema>;
const Register = () => {
+2 -11
View File
@@ -12,7 +12,7 @@ import { useTranslation } from "react-i18next";
import { useTheme } from "@mui/material/styles";
import { useInitForm } from "@/hooks/forms/UseInitRegisterForm";
import { registerSchema } from "@/validation/zod";
import { registerSchema } from "@/validation";
type FormData = z.infer<typeof registerSchema>;
export const RegisterForm = ({
@@ -41,11 +41,7 @@ export const RegisterForm = ({
formState: { errors },
} = useForm<FormData>({
resolver: zodResolver(registerSchema),
defaultValues: {
email: "",
password: "",
confirmPassword: "",
},
defaultValues: defaults,
});
useEffect(() => {
@@ -83,7 +79,6 @@ export const RegisterForm = ({
<Controller
name="email"
control={control}
defaultValue=""
render={({ field }) => (
<TextInput
disabled={mode === "invite"}
@@ -100,7 +95,6 @@ export const RegisterForm = ({
disabled={defaults.firstName ? true : false}
name="firstName"
control={control}
defaultValue=""
render={({ field }) => (
<TextInput
{...field}
@@ -116,7 +110,6 @@ export const RegisterForm = ({
disabled={defaults.lastName ? true : false}
name="lastName"
control={control}
defaultValue=""
render={({ field }) => (
<TextInput
{...field}
@@ -131,7 +124,6 @@ export const RegisterForm = ({
<Controller
name="password"
control={control}
defaultValue=""
render={({ field }) => (
<TextInput
{...field}
@@ -147,7 +139,6 @@ export const RegisterForm = ({
<Controller
name="confirmPassword"
control={control}
defaultValue=""
render={({ field }) => (
<TextInput
{...field}
+1 -1
View File
@@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next";
import { usePost } from "@/hooks/UseApi";
import { useNavigate } from "react-router";
import { z } from "zod";
import { registerSchema } from "@/validation/zod";
import { registerSchema } from "@/validation";
import { useGet } from "@/hooks/UseApi";
import { useParams } from "react-router";
import type { IUser } from "@/types/user";