-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPageContainer.tsx
More file actions
35 lines (27 loc) · 962 Bytes
/
PageContainer.tsx
File metadata and controls
35 lines (27 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { ReactNode, useContext, useState } from "react";
// components
import { AdminIconButton, Loading, AdminView } from "@/components";
// context
import { GlobalStateContext } from "@context/GlobalContext";
interface PageContainerProps {
children?: ReactNode;
isLoading?: boolean;
}
export const PageContainer = ({ children, isLoading }: PageContainerProps) => {
const { error, isAdmin } = useContext(GlobalStateContext);
const [showSettings, setShowSettings] = useState(false);
if (isLoading) return <Loading />;
return (
<>
<div className="page-container" />
<div className="p-4 mb-28">
{isAdmin && (
<AdminIconButton setShowSettings={() => setShowSettings(!showSettings)} showSettings={showSettings} />
)}
{showSettings ? <AdminView /> : children}
{error && <p className="p3 pt-10 text-center text-error">{error}</p>}
</div>
</>
);
};
export default PageContainer;