From 24d613e9cd7b48dace399c41b6384202d2afd7af Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Mon, 2 Dec 2024 10:00:38 +0000 Subject: [PATCH] ENCOA-249 --- src/components/Sidebar.tsx | 378 ++++++++++++++++++------------------- 1 file changed, 189 insertions(+), 189 deletions(-) diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 5e44ad75..a420c558 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -2,17 +2,17 @@ import clsx from "clsx"; import { IconType } from "react-icons"; import { MdSpaceDashboard } from "react-icons/md"; import { - BsFileEarmarkText, - BsClockHistory, - BsPencil, - BsGraphUp, - BsChevronBarRight, - BsChevronBarLeft, - BsShieldFill, - BsCloudFill, - BsCurrencyDollar, - BsClipboardData, - BsPeople, + BsFileEarmarkText, + BsClockHistory, + BsPencil, + BsGraphUp, + BsChevronBarRight, + BsChevronBarLeft, + BsShieldFill, + BsCloudFill, + BsCurrencyDollar, + BsClipboardData, + BsPeople, } from "react-icons/bs"; import { CiDumbbell } from "react-icons/ci"; import { RiLogoutBoxFill } from "react-icons/ri"; @@ -31,50 +31,50 @@ import { useAllowedEntitiesSomePermissions } from "@/hooks/useEntityPermissions" import { useMemo } from "react"; interface Props { - path: string; - navDisabled?: boolean; - focusMode?: boolean; - onFocusLayerMouseEnter?: () => void; - className?: string; - user: User; - entities?: EntityWithRoles[] + path: string; + navDisabled?: boolean; + focusMode?: boolean; + onFocusLayerMouseEnter?: () => void; + className?: string; + user: User; + entities?: EntityWithRoles[] } interface NavProps { - Icon: IconType; - label: string; - path: string; - keyPath: string; - disabled?: boolean; - isMinimized?: boolean; - badge?: number; + Icon: IconType; + label: string; + path: string; + keyPath: string; + disabled?: boolean; + isMinimized?: boolean; + badge?: number; } const Nav = ({ Icon, label, path, keyPath, disabled = false, isMinimized = false, badge }: NavProps) => { - return ( - - - {!isMinimized && {label}} - {!!badge && badge > 0 && ( -
- {badge} -
- )} - - ); + return ( + + + {!isMinimized && {label}} + {!!badge && badge > 0 && ( +
+ {badge} +
+ )} + + ); }; export default function Sidebar({ @@ -86,152 +86,152 @@ export default function Sidebar({ onFocusLayerMouseEnter, className }: Props) { - const router = useRouter(); + const router = useRouter(); - const isAdmin = useMemo(() => ['developer', 'admin'].includes(user?.type), [user?.type]) + const isAdmin = useMemo(() => ['developer', 'admin'].includes(user?.type), [user?.type]) - const [isMinimized, toggleMinimize] = usePreferencesStore((state) => [state.isSidebarMinimized, state.toggleSidebarMinimized]); + const [isMinimized, toggleMinimize] = usePreferencesStore((state) => [state.isSidebarMinimized, state.toggleSidebarMinimized]); - const { totalAssignedTickets } = useTicketsListener(user.id); - const { permissions } = usePermissions(user.id); + const { totalAssignedTickets } = useTicketsListener(user.id); + const { permissions } = usePermissions(user.id); - const entitiesAllowGeneration = useAllowedEntitiesSomePermissions(user, entities, [ - "generate_reading", "generate_listening", "generate_writing", "generate_speaking", "generate_level" - ]) + const entitiesAllowGeneration = useAllowedEntitiesSomePermissions(user, entities, [ + "generate_reading", "generate_listening", "generate_writing", "generate_speaking", "generate_level" + ]) - const logout = async () => { - axios.post("/api/logout").finally(() => { - setTimeout(() => router.reload(), 500); - }); - }; + const logout = async () => { + axios.post("/api/logout").finally(() => { + setTimeout(() => router.reload(), 500); + }); + }; - const disableNavigation = preventNavigation(navDisabled, focusMode); + const disableNavigation = preventNavigation(navDisabled, focusMode); - return ( -
-
-
-
-
+ return ( +
+
+
+
+
-
-
- {isMinimized ? : } - {!isMinimized && Minimize} -
-
{ } : logout} - className={clsx( - "hover:text-mti-rose flex cursor-pointer items-center gap-4 rounded-full p-4 text-black transition duration-300 ease-in-out", - isMinimized ? "w-fit" : "w-full min-w-[250px] px-8", - )}> - - {!isMinimized && Log Out} -
-
- {focusMode && } -
- ); +
+
+ {isMinimized ? : } + {!isMinimized && Minimize} +
+
{ } : logout} + className={clsx( + "hover:text-mti-rose flex cursor-pointer items-center gap-4 rounded-full p-4 text-black transition duration-300 ease-in-out", + isMinimized ? "w-fit" : "w-full min-w-[250px] px-8", + )}> + + {!isMinimized && Log Out} +
+
+ {focusMode && } +
+ ); }