|
|
@ -15,6 +15,7 @@ import { useState } from 'react'; |
|
|
|
import { loginApi } from "@/services/api/loginApi"; |
|
|
|
import { FormControl } from '@mui/material'; |
|
|
|
import CustomTextField from "@/ui/CustomTextField"; |
|
|
|
import { useRouter } from "next/navigation"; |
|
|
|
|
|
|
|
const loginSchema = z.object({ |
|
|
|
username: z.string(), |
|
|
@ -24,7 +25,7 @@ const loginSchema = z.object({ |
|
|
|
type LoginFormValues = z.infer<typeof loginSchema>; |
|
|
|
|
|
|
|
export default function LoginPage() { |
|
|
|
|
|
|
|
const router = useRouter() |
|
|
|
const { register, handleSubmit, formState: { errors }, control } = useForm<LoginFormValues>({ |
|
|
|
resolver: zodResolver(loginSchema), |
|
|
|
}); |
|
|
@ -36,9 +37,8 @@ export default function LoginPage() { |
|
|
|
const response = await loginApi(data); |
|
|
|
localStorage.setItem('token', response.token); |
|
|
|
localStorage.setItem('refreshToken', response.refreshToken); |
|
|
|
console.log("🚀 ~ response @@@ @@@ @@@ @@@ @@@@:", response) |
|
|
|
|
|
|
|
// router.push('/dashboard');
|
|
|
|
router.push('/home'); |
|
|
|
} catch (err) { |
|
|
|
setError('Invalid credentials'); |
|
|
|
} |
|
|
|