diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index afb5fea..32d4adb 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -16,67 +16,75 @@ const Layout: React.FC = ({ children, selectedKey, onSelect }) => { useEffect(() => { // Check localStorage to see if the toast has been dismissed - const isToastDismissed = localStorage.getItem("desktopToastDismissed") === "true"; - - - + const isToastDismissed = + localStorage.getItem("desktopToastDismissed") === "true"; const handleResize = () => { - if (window.innerWidth < 768 && !isToastDismissed && !toastShown && !toastShown ) { - toast((t) => ( - - - + if ( + window.innerWidth < 768 && + !isToastDismissed && + !toastShown && + !toastShown + ) { + toast( + (t) => ( + - Switch to desktop for a better experience + + + Switch to desktop for a better experience + + - - - ), { - position: "top-center", - duration: Infinity, - style: { - background: "green", - color: "#fff", - }, - }); + ), + { + position: "top-center", + duration: Infinity, + style: { + background: "green", + color: "#fff", + }, + } + ); setToastShown(true); // Mark toast as shown } }; // Check on initial load - if (!localStorage.getItem('isToastCalled')){ + if (!localStorage.getItem("isToastCalled")) { handleResize(); - localStorage.setItem('isToastCalled',"true") + localStorage.setItem("isToastCalled", "true"); } // Attach event listener for window resize @@ -88,15 +96,20 @@ const Layout: React.FC = ({ children, selectedKey, onSelect }) => { }, [toastShown]); return ( - + }, { text: "Drafts", key: "draft", icon: }, ...(userRole !== Role.CCTA - ? [{ text: "Submitted for Review", key: "submitted", icon: }, - ] + ? [ + { + text: "Submitted for Review", + key: "submitted", + icon: , + }, + ] : []), ...(userRole === Role.CCTA - ? [{ text: "Up for Review", key: "up-review", icon: }] + ? [ + { + text: "Up for Review", + key: "up-review", + icon: , + }, + ] : []), - { text: "My Published Contents", key: "publish", icon: }, + { + text: "My Published Contents", + key: "publish", + icon: , + }, { text: "All My Contents", key: "allContents", icon: }, - { text: "Discover Contents", key: "discover-contents", icon: }, - + { + text: "Discover Contents", + key: "discover-contents", + icon: , + }, ]; interface SidebarProps { @@ -58,7 +80,7 @@ const Sidebar: React.FC = ({ selectedKey, onSelect }) => { const handleNavigation = (key: string) => { console.log(key); router.push(`/workspace/content/${key}`); - localStorage.setItem("selectedFilters", JSON.stringify([])) + localStorage.setItem("selectedFilters", JSON.stringify([])); onSelect(key); if (isMobile) { setDrawerOpen(false); // Close drawer after selecting in mobile view @@ -69,18 +91,15 @@ const Sidebar: React.FC = ({ selectedKey, onSelect }) => { setDrawerOpen(!drawerOpen); }; - const goBack = () => { if (typeof window !== "undefined" && window.localStorage) { const userInfo = JSON.parse(localStorage.getItem("adminInfo") || "{}"); console.log("userInfo", userInfo); if (userInfo?.role === Role.SCTA || userInfo?.role === Role.CCTA) { router.push("/course-planner"); - - } - else - router.push("/"); - }}; + } else router.push("/"); + } + }; const drawerContent = ( = ({ selectedKey, onSelect }) => { width="284px !important" height="100%" sx={{ - fontSize: '16px', - '@media (max-width: 900px)': { - background: 'linear-gradient(to bottom, white, #F8EFDA)', - fontSize: '12px', + fontSize: "16px", + "@media (max-width: 900px)": { + background: "linear-gradient(to bottom, white, #F8EFDA)", + fontSize: "12px", }, }} > - - logo + + logo = ({ selectedKey, onSelect }) => { justifyContent="space-between" paddingTop={"1rem"} > - @@ -140,8 +160,8 @@ const Sidebar: React.FC = ({ selectedKey, onSelect }) => { ? "var(--mui-palette-primary-main)" : "transparent", color: "#000", - - fontSize: '16px !important' , + + fontSize: "16px !important", "&:hover": { background: @@ -160,14 +180,23 @@ const Sidebar: React.FC = ({ selectedKey, onSelect }) => { selectedKey === item?.key ? "#2E1500" : theme.palette.warning.A200, - minWidth: '40px', - fontWeight: selectedKey === item?.key ? '500' : '500', - fontSize: '16px !important' + minWidth: "40px", + fontWeight: selectedKey === item?.key ? "500" : "500", + fontSize: "16px !important", }} > {item?.icon} - + ))} @@ -178,8 +207,14 @@ const Sidebar: React.FC = ({ selectedKey, onSelect }) => { <> {isMobile ? ( <> - - + = ({ selectedKey, onSelect }) => { display: "flex", justifyContent: "flex-start", width: 284, - }} > {drawerContent} @@ -212,4 +246,4 @@ const Sidebar: React.FC = ({ selectedKey, onSelect }) => { ); }; -export default Sidebar; \ No newline at end of file +export default Sidebar;