mirror of
https://github.com/R0m1k3/Reviflow.git
synced 2026-10-23 15:08:10 +02:00
fix(auth): add logging and remove button animation for stability
This commit is contained in:
1 parent
c1bab81bde
commit
3d95250d59
1 file changed
+10
-2
@@ -31,19 +31,27 @@ export const LoginPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async (data: LoginForm) => {
|
const onSubmit = async (data: LoginForm) => {
|
||||||
|
console.log("DEBUG: Login form submitted", data);
|
||||||
try {
|
try {
|
||||||
setGlobalError(null);
|
setGlobalError(null);
|
||||||
const loginData = isParentMode
|
const loginData = isParentMode
|
||||||
? { email: data.identifier, password: data.password }
|
? { email: data.identifier, password: data.password }
|
||||||
: { username: data.identifier, password: data.password };
|
: { username: data.identifier, password: data.password };
|
||||||
|
|
||||||
|
console.log("DEBUG: Calling login with", loginData);
|
||||||
await login(loginData);
|
await login(loginData);
|
||||||
|
console.log("DEBUG: Login successful, navigating");
|
||||||
navigate('/');
|
navigate('/');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error("DEBUG: Login error caught in component", err);
|
||||||
setGlobalError("Identifiants invalides ou erreur de connexion");
|
setGlobalError("Identifiants invalides ou erreur de connexion");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onError = (errors: any) => {
|
||||||
|
console.log("DEBUG: Form validation failed", errors);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-[#FDFCF8] to-[#F1F5F9] p-4 sm:p-6 lg:p-8">
|
<div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-[#FDFCF8] to-[#F1F5F9] p-4 sm:p-6 lg:p-8">
|
||||||
<div className="w-full max-w-md">
|
<div className="w-full max-w-md">
|
||||||
@@ -78,7 +86,7 @@ export const LoginPage = () => {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form className="space-y-5" onSubmit={handleSubmit(onSubmit)}>
|
<form className="space-y-5" onSubmit={handleSubmit(onSubmit, onError)}>
|
||||||
{globalError && (
|
{globalError && (
|
||||||
<div className="bg-red-50 border border-red-100 text-red-600 p-4 rounded-xl text-sm font-medium flex items-center">
|
<div className="bg-red-50 border border-red-100 text-red-600 p-4 rounded-xl text-sm font-medium flex items-center">
|
||||||
<span className="mr-2">⚠️</span> {globalError}
|
<span className="mr-2">⚠️</span> {globalError}
|
||||||
@@ -134,7 +142,7 @@ export const LoginPage = () => {
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
className="w-full h-12 flex items-center justify-center rounded-2xl bg-indigo-600 px-4 text-sm font-bold text-white shadow-lg shadow-indigo-200 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed transition-all active:scale-[0.98]"
|
className="w-full h-12 flex items-center justify-center rounded-2xl bg-indigo-600 px-4 text-sm font-bold text-white shadow-lg shadow-indigo-200 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed transition-all"
|
||||||
>
|
>
|
||||||
{isSubmitting ? (
|
{isSubmitting ? (
|
||||||
<Loader2 className="h-5 w-5 animate-spin" />
|
<Loader2 className="h-5 w-5 animate-spin" />
|
||||||
|
|||||||
Reference in new issue
Block a user