2022-02-21 08:30:39 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import styled from "styled-components";
|
2022-02-23 10:19:09 +00:00
|
|
|
|
2022-02-21 08:30:39 +00:00
|
|
|
import { PageContainer } from "../components/PageContainer";
|
2022-04-07 10:59:20 +00:00
|
|
|
import { NavBar } from "../components/NavBar";
|
2022-02-21 08:30:39 +00:00
|
|
|
import { Footer } from "../components/Footer";
|
2022-03-02 11:50:32 +00:00
|
|
|
import { UserProvider, useUser } from "../contexts/user";
|
2022-03-29 14:02:02 +00:00
|
|
|
import { FullScreenLoadingIndicator } from "../components/LoadingIndicator";
|
2022-02-21 08:30:39 +00:00
|
|
|
|
2022-04-19 11:16:57 +00:00
|
|
|
import dashboardBg from "../../static/images/dashboard-bg.svg";
|
|
|
|
|
2022-03-02 11:50:32 +00:00
|
|
|
const Wrapper = styled.div.attrs({
|
2022-02-23 10:19:09 +00:00
|
|
|
className: "min-h-screen overflow-hidden",
|
2022-02-21 08:30:39 +00:00
|
|
|
})`
|
2022-04-19 11:16:57 +00:00
|
|
|
background-image: url(${dashboardBg});
|
2022-02-23 10:19:09 +00:00
|
|
|
background-position: center -280px;
|
|
|
|
background-repeat: no-repeat;
|
2022-02-21 08:30:39 +00:00
|
|
|
`;
|
|
|
|
|
2022-03-02 11:50:32 +00:00
|
|
|
const Layout = ({ children }) => {
|
|
|
|
const { user } = useUser();
|
|
|
|
|
|
|
|
// Prevent from flashing the dashboard screen to unauthenticated users.
|
|
|
|
return (
|
|
|
|
<Wrapper>
|
2022-03-29 14:02:02 +00:00
|
|
|
{!user && <FullScreenLoadingIndicator />}
|
2022-03-02 11:50:32 +00:00
|
|
|
{user && <>{children}</>}
|
|
|
|
</Wrapper>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-04-07 11:52:50 +00:00
|
|
|
const DashboardLayout = ({ children }) => (
|
|
|
|
<>
|
|
|
|
<UserProvider>
|
|
|
|
<Layout>
|
|
|
|
<NavBar />
|
|
|
|
<PageContainer className="mt-2 md:mt-14">{children}</PageContainer>
|
|
|
|
<Footer />
|
|
|
|
</Layout>
|
|
|
|
</UserProvider>
|
|
|
|
</>
|
|
|
|
);
|
2022-02-21 08:30:39 +00:00
|
|
|
|
|
|
|
export default DashboardLayout;
|