2023-02-08 17:58:55 -06:00
|
|
|
import Navbar from "@/components/Navbar";
|
2023-11-07 12:06:42 -06:00
|
|
|
import AnnouncementBar from "@/components/AnnouncementBar";
|
2023-02-08 17:58:55 -06:00
|
|
|
import Sidebar from "@/components/Sidebar";
|
2023-11-07 12:06:42 -06:00
|
|
|
import { ReactNode, useEffect, useState } from "react";
|
|
|
|
import getLatestVersion from "@/lib/client/getLatestVersion";
|
2023-02-08 17:58:55 -06:00
|
|
|
|
2023-02-13 15:22:47 -06:00
|
|
|
interface Props {
|
2023-02-08 17:58:55 -06:00
|
|
|
children: ReactNode;
|
|
|
|
}
|
|
|
|
|
2023-06-09 17:31:14 -05:00
|
|
|
export default function MainLayout({ children }: Props) {
|
2023-11-07 12:06:42 -06:00
|
|
|
const showAnnouncementBar = localStorage.getItem("showAnnouncementBar");
|
|
|
|
const [showAnnouncement, setShowAnnouncement] = useState(
|
|
|
|
showAnnouncementBar ? showAnnouncementBar === "true" : true
|
|
|
|
);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
getLatestVersion(setShowAnnouncement);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (showAnnouncement) {
|
|
|
|
localStorage.setItem("showAnnouncementBar", "true");
|
|
|
|
setShowAnnouncement(true);
|
|
|
|
} else if (!showAnnouncement) {
|
|
|
|
localStorage.setItem("showAnnouncementBar", "false");
|
|
|
|
setShowAnnouncement(false);
|
|
|
|
}
|
|
|
|
}, [showAnnouncement]);
|
|
|
|
|
|
|
|
const toggleAnnouncementBar = () => {
|
|
|
|
setShowAnnouncement(!showAnnouncement);
|
|
|
|
};
|
|
|
|
|
2023-10-16 12:10:52 -05:00
|
|
|
return (
|
|
|
|
<>
|
2023-11-07 12:06:42 -06:00
|
|
|
{showAnnouncement ? (
|
|
|
|
<AnnouncementBar toggleAnnouncementBar={toggleAnnouncementBar} />
|
|
|
|
) : undefined}
|
|
|
|
|
2023-10-16 12:10:52 -05:00
|
|
|
<div className="flex">
|
|
|
|
<div className="hidden lg:block">
|
2023-11-07 12:06:42 -06:00
|
|
|
<Sidebar
|
|
|
|
className={`fixed ${showAnnouncement ? "top-10" : "top-0"}`}
|
|
|
|
/>
|
2023-10-16 12:10:52 -05:00
|
|
|
</div>
|
2023-04-30 15:54:40 -05:00
|
|
|
|
2023-11-07 12:06:42 -06:00
|
|
|
<div
|
2024-01-19 23:34:49 -06:00
|
|
|
className={`w-full sm:pb-0 pb-20 flex flex-col min-h-${
|
2023-11-09 10:44:49 -06:00
|
|
|
showAnnouncement ? "full" : "screen"
|
2023-12-19 10:50:43 -06:00
|
|
|
} lg:ml-80 ${showAnnouncement ? "mt-10" : ""}`}
|
2023-11-07 12:06:42 -06:00
|
|
|
>
|
2023-10-16 12:10:52 -05:00
|
|
|
<Navbar />
|
|
|
|
{children}
|
2023-02-08 17:58:55 -06:00
|
|
|
</div>
|
2023-10-16 12:10:52 -05:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
2023-02-08 17:58:55 -06:00
|
|
|
}
|