Initial commit for new panel

This commit is contained in:
AmirReza Jamali
2025-09-09 11:20:26 +03:30
commit 1d4ccb3575
343 changed files with 20031 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
"use client";
import { useRouter } from "next/navigation";
import { useEffect, ReactNode } from "react";
import { useUser } from "./";
import Loading from "@/app/loading";
interface AuthGuardProps {
children: ReactNode;
}
const AuthGuard = ({ children }: AuthGuardProps): React.ReactNode => {
const { isAuthenticated, isLoading } = useUser();
const router = useRouter();
useEffect(() => {
if (!isLoading && !isAuthenticated) {
router.push("/auth/sign-in");
}
}, [isLoading, isAuthenticated, router]);
if (isLoading || !isAuthenticated) {
return <Loading />;
}
return children;
};
export default AuthGuard;