Files
frontend/src/app/(withAuth)/layout.js
AmirHossein Mahmoodi 12d6d08bef Feature/amiriis missions
2025-06-25 07:41:03 +00:00

32 lines
1.2 KiB
JavaScript

"use client";
import { useAuth } from "@/lib/contexts/auth";
import { Typography, Stack } from "@mui/material";
import WithAuthMiddleware from "@/core/middlewares/withAuth";
import LoadingHardPage from "@/core/components/LoadingHardPage";
const Layout = ({ children }) => {
const { isAuth, initAuthState, errorState } = useAuth();
if (!initAuthState && !isAuth)
return (
<LoadingHardPage
authState={errorState.status}
label={
errorState.status ? (
<Stack justifyContent={"center"} alignItems={"center"}>
<Typography variant={"body1"}>{errorState.message}</Typography>
<Typography variant={"body1"}> کد : {errorState.status}</Typography>
</Stack>
) : (
<Typography variant={"body1"}>درحال احراز هویت...</Typography>
)
}
loading={true}
/>
);
return <WithAuthMiddleware>{children}</WithAuthMiddleware>;
};
export default Layout;