"use client";
import { useEffect } from "react";
import { useRouter } from "next/navigation";

export default function PrivateRoute({ children }: { children: React.ReactNode }) {
  const router = useRouter();
  const isLoggedIn = Boolean(localStorage.getItem("auth_token")); // یا useSession

  useEffect(() => {
    if (!isLoggedIn) {
      router.push("/login");
    }
  }, [isLoggedIn, router]);

  if (!isLoggedIn) return null; // یا loader

  return <>{children}</>;
}
