import { Stack, useRouter } from "expo-router";
import { useAuth } from "@/context/auth-context";
import { useEffect } from "react";

export default function AuthLayout() {
  const { user } = useAuth();
  const router = useRouter();

  useEffect(() => {
    if (user) {
      router.replace("/(tabs)");
    } else {
        router.replace("/(auth)/login");
    }
  }, [user]);

  return <Stack />;
}