65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { LoginForm, RegisterForm } from "./index";
|
|
|
|
interface AuthWrapperProps {
|
|
teams: any[];
|
|
}
|
|
|
|
export function AuthWrapper({ teams }: AuthWrapperProps) {
|
|
const [isLogin, setIsLogin] = useState(true);
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const handleLogin = async (email: string, password: string) => {
|
|
setLoading(true);
|
|
try {
|
|
// TODO: Implémenter la logique de login
|
|
console.log("Login attempt:", { email, password });
|
|
// await authClient.login(email, password);
|
|
} catch (error) {
|
|
console.error("Login failed:", error);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
const handleRegister = async (data: {
|
|
firstName: string;
|
|
lastName: string;
|
|
email: string;
|
|
password: string;
|
|
teamId: string;
|
|
}) => {
|
|
setLoading(true);
|
|
try {
|
|
// TODO: Implémenter la logique de register
|
|
console.log("Register attempt:", data);
|
|
// await authClient.register(data);
|
|
} catch (error) {
|
|
console.error("Register failed:", error);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
if (isLogin) {
|
|
return (
|
|
<LoginForm
|
|
onSubmit={handleLogin}
|
|
onSwitchToRegister={() => setIsLogin(false)}
|
|
loading={loading}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<RegisterForm
|
|
teams={teams}
|
|
onSubmit={handleRegister}
|
|
onSwitchToLogin={() => setIsLogin(true)}
|
|
loading={loading}
|
|
/>
|
|
);
|
|
}
|