2023-02-08 17:58:55 -06:00
|
|
|
import Navbar from "@/components/Navbar";
|
2024-05-24 18:13:04 -05:00
|
|
|
import Announcement from "@/components/Announcement";
|
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 (
|
2024-05-22 19:56:56 -05:00
|
|
|
<div className="flex" data-testid="dashboard-wrapper">
|
2023-11-07 12:06:42 -06:00
|
|
|
{showAnnouncement ? (
|
2024-05-22 19:56:56 -05:00
|
|
|
<Announcement toggleAnnouncementBar={toggleAnnouncementBar} />
|
2023-11-07 12:06:42 -06:00
|
|
|
) : undefined}
|
2024-05-22 19:56:56 -05:00
|
|
|
<div className="hidden lg:block">
|
|
|
|
<Sidebar className={`fixed top-0`} />
|
|
|
|
</div>
|
2023-11-07 12:06:42 -06:00
|
|
|
|
2024-05-22 19:56:56 -05:00
|
|
|
<div
|
|
|
|
className={`w-full sm:pb-0 pb-20 flex flex-col min-h-screen lg:ml-80`}
|
|
|
|
>
|
|
|
|
<Navbar />
|
|
|
|
{children}
|
2023-10-16 12:10:52 -05:00
|
|
|
</div>
|
2024-05-22 19:56:56 -05:00
|
|
|
</div>
|
2023-10-16 12:10:52 -05:00
|
|
|
);
|
2023-02-08 17:58:55 -06:00
|
|
|
}
|