finish form extraction
This commit is contained in:
1 parent
6dcfb67246
commit
18408a6bf6
15 files changed
+65
-64
No files matched your search
@@ -12,8 +12,8 @@ import { useTheme } from "@mui/material/styles";
|
||||
import { useInitForm } from "@/hooks/forms/UseInitProfileForm";
|
||||
import type { IUser } from "@/types/user";
|
||||
|
||||
import { profileSchema } from "@/validation/zod";
|
||||
type FormData = z.infer<typeof profileSchema>;
|
||||
import { profileSchema } from "@/validation";
|
||||
export type FormValues = z.infer<typeof profileSchema>;
|
||||
|
||||
export const ProfileForm = ({
|
||||
user,
|
||||
@@ -23,21 +23,21 @@ export const ProfileForm = ({
|
||||
}: {
|
||||
user: Partial<IUser> | null;
|
||||
hasUser?: boolean;
|
||||
initialData?: Partial<FormData>;
|
||||
onSubmit: SubmitHandler<FormData>;
|
||||
initialData?: Partial<FormValues>;
|
||||
onSubmit: SubmitHandler<FormValues>;
|
||||
loading: boolean;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const { defaults } = useInitForm({ initialData: initialData });
|
||||
const resolver = zodResolver(profileSchema) as unknown as Resolver<FormData>;
|
||||
const resolver = zodResolver(profileSchema) as Resolver<FormValues>;
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm<FormData>({
|
||||
} = useForm<FormValues>({
|
||||
resolver,
|
||||
defaultValues: {
|
||||
firstName: "",
|
||||
|
||||
Reference in new issue
Block a user