Route users through onboarding and finalize profile; replace placeholders with full pages
cgen-b0a06a29a635458ba758b8f3b9b25372
This commit is contained in:
parent
76720abb34
commit
db14907a2a
1 changed files with 8 additions and 4 deletions
|
|
@ -33,15 +33,19 @@ export default function Login() {
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [fullName, setFullName] = useState("");
|
const [fullName, setFullName] = useState("");
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { signIn, signUp, signInWithOAuth, user, loading } = useAuth();
|
const { signIn, signUp, signInWithOAuth, user, loading, profile } = useAuth();
|
||||||
const { success: toastSuccess, error: toastError } = useAethexToast();
|
const { success: toastSuccess, error: toastError } = useAethexToast();
|
||||||
|
|
||||||
// Redirect if already logged in
|
// Redirect if already logged in
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user && !loading) {
|
if (user && !loading) {
|
||||||
navigate("/dashboard");
|
if (profile) {
|
||||||
|
navigate("/dashboard", { replace: true });
|
||||||
|
} else {
|
||||||
|
navigate("/onboarding", { replace: true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [user, loading, navigate]);
|
}, [user, profile, loading, navigate]);
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
@ -63,7 +67,7 @@ export default function Login() {
|
||||||
setIsSignUp(false);
|
setIsSignUp(false);
|
||||||
} else {
|
} else {
|
||||||
await signIn(email, password);
|
await signIn(email, password);
|
||||||
navigate("/dashboard");
|
// Navigation is handled by the auth redirect effect based on profile existence
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("Authentication error:", error);
|
console.error("Authentication error:", error);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue