32 lines
1.2 KiB
JavaScript
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;
|