"use client";

import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { useAppSelector } from "@/src/redux/hook";

export default function Page() {
  const isLoggedIn = useAppSelector((state) => state.auth.isLoggedIn);
  const router = useRouter();

  useEffect(() => {
    if (isLoggedIn === undefined || isLoggedIn === null) return;

    if (isLoggedIn) {
      router.replace("/admin/dashboard");
    } else {
      router.replace("/admin/login");
    }
  }, [isLoggedIn, router]);

  return null;
}
