feat: add ignoreSessionCheck prop to AreaRiservataLayout for session handling flexibility
This commit is contained in:
parent
243148267b
commit
c3cdac8310
2 changed files with 31 additions and 28 deletions
|
|
@ -61,43 +61,46 @@ export const AreaRiservataLayout = ({
|
|||
children,
|
||||
noSidebar,
|
||||
noFooter,
|
||||
ignoreSessionCheck,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
noSidebar?: boolean;
|
||||
noFooter?: boolean;
|
||||
ignoreSessionCheck?: boolean;
|
||||
}) => {
|
||||
const { data: bannerData } = api.settings.getBannerData.useQuery({
|
||||
area_riservata: true,
|
||||
});
|
||||
const session = useSession();
|
||||
if (!ignoreSessionCheck) {
|
||||
if (session.status === "pending")
|
||||
return (
|
||||
<div className="flex h-full min-h-screen flex-col text-clip">
|
||||
<SiteHeader />
|
||||
|
||||
if (session.status === "pending")
|
||||
return (
|
||||
<div className="flex h-full min-h-screen flex-col text-clip">
|
||||
<SiteHeader />
|
||||
<main className="flex h-full flex-1 overflow-auto">
|
||||
<div className="flex h-auto w-full flex-col md:flex-row">
|
||||
<LoadingPage />;
|
||||
</div>
|
||||
</main>
|
||||
{!noFooter && <MiniFooter />}
|
||||
</div>
|
||||
);
|
||||
if (session.status !== "success" || !session.user) {
|
||||
window.location.reload();
|
||||
return (
|
||||
<div className="flex h-full min-h-screen flex-col text-clip">
|
||||
<SiteHeader />
|
||||
|
||||
<main className="flex h-full flex-1 overflow-auto">
|
||||
<div className="flex h-auto w-full flex-col md:flex-row">
|
||||
<LoadingPage />;
|
||||
</div>
|
||||
</main>
|
||||
{!noFooter && <MiniFooter />}
|
||||
</div>
|
||||
);
|
||||
if (session.status !== "success" || !session.user) {
|
||||
window.location.reload();
|
||||
return (
|
||||
<div className="flex h-full min-h-screen flex-col text-clip">
|
||||
<SiteHeader />
|
||||
|
||||
<main className="flex h-full flex-1 overflow-auto">
|
||||
<div className="flex h-auto w-full flex-col md:flex-row">
|
||||
<LoadingPage />;
|
||||
</div>
|
||||
</main>
|
||||
{!noFooter && <MiniFooter />}
|
||||
</div>
|
||||
);
|
||||
<main className="flex h-full flex-1 overflow-auto">
|
||||
<div className="flex h-auto w-full flex-col md:flex-row">
|
||||
<LoadingPage />;
|
||||
</div>
|
||||
</main>
|
||||
{!noFooter && <MiniFooter />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
@ -111,7 +114,7 @@ export const AreaRiservataLayout = ({
|
|||
<main className="flex h-full flex-1 overflow-auto">
|
||||
<div className="flex h-auto w-full flex-col md:flex-row">
|
||||
{noSidebar ? null : (
|
||||
<Sidebar isAdmin={session.user.isAdmin || false} />
|
||||
<Sidebar isAdmin={session.user?.isAdmin || false} />
|
||||
)}
|
||||
<EnforcedSessionContext.Provider value={session as ValidSession}>
|
||||
{children}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ const PreOnboardServizio: NextPageWithLayout<PreOnboardServizioProps> = ({
|
|||
|
||||
PreOnboardServizio.getLayout = function getLayout(page) {
|
||||
return (
|
||||
<AreaRiservataLayout noSidebar noFooter>
|
||||
<AreaRiservataLayout noSidebar noFooter ignoreSessionCheck>
|
||||
{page}
|
||||
</AreaRiservataLayout>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue