diff --git a/packages/dashboard-v2/src/layouts/DashboardLayout.js b/packages/dashboard-v2/src/layouts/DashboardLayout.js index 32156549..07f4eabf 100644 --- a/packages/dashboard-v2/src/layouts/DashboardLayout.js +++ b/packages/dashboard-v2/src/layouts/DashboardLayout.js @@ -7,8 +7,9 @@ import { authenticatedOnly } from "../lib/swrConfig"; import { PageContainer } from "../components/PageContainer"; import { NavBar } from "../components/Navbar"; import { Footer } from "../components/Footer"; +import { UserProvider, useUser } from "../contexts/user"; -const Layout = styled.div.attrs({ +const Wrapper = styled.div.attrs({ className: "min-h-screen overflow-hidden", })` background-image: url(/images/dashboard-bg.svg); @@ -16,17 +17,35 @@ const Layout = styled.div.attrs({ background-repeat: no-repeat; `; +const Layout = ({ children }) => { + const { user } = useUser(); + + // Prevent from flashing the dashboard screen to unauthenticated users. + return ( + + {!user && ( +
+

Loading...

{/* TODO: Do something nicer here */} +
+ )} + {user && <>{children}} +
+ ); +}; + const DashboardLayout = ({ children }) => { return ( <> - - - -
{children}
-
-