feat: adding login/RegisterForm and new columns in PG
This commit is contained in:
64
components/login/auth-wrapper.tsx
Normal file
64
components/login/auth-wrapper.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
"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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user