diff --git a/web/src/components/LoginForm.jsx b/web/src/components/LoginForm.jsx index 6b843bd..6e0b93e 100644 --- a/web/src/components/LoginForm.jsx +++ b/web/src/components/LoginForm.jsx @@ -8,16 +8,15 @@ import { yupResolver } from '@hookform/resolvers/yup'; // นำเข้า Hook API และ Components import { useLoginMutation } from '../services/authApi'; import LandingIntro from './LandingIntro'; -import InputText from './InputText'; +import InputText from './InputText'; // ตรวจสอบ Path ให้ถูกต้อง + +import { loginSchema } from '../schemas/authSchema'; // ตรวจสอบ Path ให้ถูกต้อง -import { loginSchema } from '../schemas/authSchema'; export default function LoginForm() { - // 1. Hook สำหรับเรียก API ล็อกอิน const loginMutation = useLoginMutation(); const [apiErrorMessage, setApiErrorMessage] = useState(""); - // 2. Hook Form Setup const { register, handleSubmit, @@ -30,13 +29,11 @@ export default function LoginForm() { } }); - // 3. Form Submission Logic const onSubmit = (data) => { setApiErrorMessage(""); // เรียกใช้ Mutation (Token + Fetch User) loginMutation.mutate({ - // ส่ง 'username' และ 'password' ตรงตาม API username: data.username, password: data.password }, { @@ -49,73 +46,94 @@ export default function LoginForm() { const loading = loginMutation.isPending; return ( -