generic return type
This commit is contained in:
1 parent
7c2f789a31
commit
a8f111b399
2 files changed
+7
-8
No files matched your search
@@ -8,6 +8,8 @@ import { TextInput } from "@/Components/Inputs/TextInput/indexV2.tsx";
|
||||
import Button from "@mui/material/Button";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import { usePost } from "@/Hooks/v2/UseApi";
|
||||
import type { ApiResponse } from "@/Hooks/v2/UseApi";
|
||||
|
||||
const schema = z.object({
|
||||
email: z.email("Invalid email address"),
|
||||
password: z.string().min(6, "Password must be at least 6 characters"),
|
||||
@@ -18,14 +20,14 @@ type FormData = z.infer<typeof schema>;
|
||||
const Login = () => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const { post, loading, error } = usePost<FormData>("/auth/login");
|
||||
const { post, loading, error } = usePost<FormData, ApiResponse>("/auth/login");
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
formState: { errors },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(schema), // ⬅️ connect Zod
|
||||
resolver: zodResolver(schema),
|
||||
defaultValues: {
|
||||
email: "",
|
||||
password: "",
|
||||
|
||||
Reference in new issue
Block a user