Route new users to onboarding from login
cgen-4321c29aed0542c493d956323c13deca
This commit is contained in:
parent
4cd9dd7d35
commit
3abcfa6cf9
1 changed files with 7 additions and 4 deletions
|
|
@ -34,15 +34,18 @@ 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, profile } = useAuth();
|
const { signIn, signUp, signInWithOAuth, user, loading, profileComplete } =
|
||||||
|
useAuth();
|
||||||
const { success: toastSuccess, error: toastError } = useAethexToast();
|
const { success: toastSuccess, error: toastError } = useAethexToast();
|
||||||
|
|
||||||
// After auth resolves and a user exists, navigate to dashboard
|
// After auth resolves and a user exists, navigate to dashboard
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user && !loading) {
|
if (!loading && user) {
|
||||||
navigate("/dashboard", { replace: true });
|
navigate(profileComplete ? "/dashboard" : "/onboarding", {
|
||||||
|
replace: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [user, loading, navigate]);
|
}, [user, loading, profileComplete, navigate]);
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue