diff --git a/.qdrant-initialized b/.qdrant-initialized new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/Components/Common/Sidebar/Sidebar.tsx b/src/Components/Common/Sidebar/Sidebar.tsx index e18c17bcb68..1a449b3c1ba 100644 --- a/src/Components/Common/Sidebar/Sidebar.tsx +++ b/src/Components/Common/Sidebar/Sidebar.tsx @@ -1,10 +1,10 @@ import { createContext, useContext, useEffect, useRef, useState } from "react"; import { SidebarItem, ShrinkedSidebarItem } from "./SidebarItem"; -import SidebarUserCard from "./SidebarUserCard"; import NotificationItem from "../../Notifications/NotificationsList"; import useActiveLink from "../../../Common/hooks/useActiveLink"; import CareIcon, { IconName } from "../../../CAREUI/icons/CareIcon"; import SlideOver from "../../../CAREUI/interactive/SlideOver"; +import SidebarUserCard from "./SidebarUserCard"; import { classNames } from "../../../Utils/utils"; import { Link } from "raviger"; import useAuthUser from "../../../Common/hooks/useAuthUser"; @@ -13,7 +13,6 @@ import careConfig from "@careConfig"; export const SIDEBAR_SHRINK_PREFERENCE_KEY = "sidebarShrinkPreference"; const LOGO_COLLAPSE = "/images/logo_collapsed.svg"; - type StatelessSidebarProps = | { shrinkable: true; @@ -35,6 +34,7 @@ const StatelessSidebar = ({ onItemClick, }: StatelessSidebarProps) => { const authUser = useAuthUser(); + const activeLink = useActiveLink(); const NavItems: { text: string; @@ -62,21 +62,18 @@ const StatelessSidebar = ({ { text: "Notice Board", to: "/notice_board", icon: "l-meeting-board" }, ]; - const activeLink = useActiveLink(); const Item = shrinked ? ShrinkedSidebarItem : SidebarItem; const indicatorRef = useRef(null); const activeLinkRef = useRef(null); const [lastIndicatorPosition, setLastIndicatorPosition] = useState(0); - const [isOverflowVisible, setOverflowVisisble] = useState(false); + const [isOverflowVisible, setOverflowVisible] = useState(false); const updateIndicator = () => { if (!indicatorRef.current) return; const index = NavItems.findIndex((item) => item.to === activeLink); const navItemCount = NavItems.length + (careConfig.urls.dashboard ? 2 : 1); // +2 for notification and dashboard if (index !== -1) { - // Haha math go brrrrrrrrr - const e = indicatorRef.current; const itemHeight = activeLinkRef.current?.clientHeight || 0; if (lastIndicatorPosition > index) { @@ -104,9 +101,8 @@ const StatelessSidebar = ({ addEventListener("resize", updateIndicator); return () => removeEventListener("resize", updateIndicator); }, []); - const handleOverflow = (value: boolean) => { - setOverflowVisisble(value); + setOverflowVisible(value); }; return ( @@ -119,7 +115,7 @@ const StatelessSidebar = ({ : "overflow-y-auto overflow-x-hidden" }`} > -
{/* flexible spacing */} +
-
{/* flexible spacing */} +
@@ -167,25 +162,19 @@ const StatelessSidebar = ({ handleOverflow={handleOverflow} /> )} -
-
-
{shrinkable && ( -
- setShrinked && setShrinked(!shrinked)} - /> -
+ setShrinked && setShrinked(!shrinked)} + handleOverflow={handleOverflow} + /> )}
-
+ +
+ ); }; @@ -195,7 +184,6 @@ export const SidebarShrinkContext = createContext<{ setShrinked: (state: boolean) => void; }>({ shrinked: false, - // eslint-disable-next-line @typescript-eslint/no-empty-function setShrinked: () => {}, }); @@ -226,20 +214,32 @@ export const MobileSidebar = (props: MobileSidebarProps) => { interface ToggleShrinkProps { shrinked: boolean; toggle: () => void; + handleOverflow: (value: boolean) => void; } +const ToggleShrink = ({ + shrinked, + toggle, + handleOverflow, +}: ToggleShrinkProps) => { + const Item = shrinked ? ShrinkedSidebarItem : SidebarItem; -const ToggleShrink = ({ shrinked, toggle }: ToggleShrinkProps) => ( -
- + } + do={() => { + toggle(); + handleOverflow(!shrinked); + }} + handleOverflow={handleOverflow} /> -
-); + ); +}; +export default StatelessSidebar; diff --git a/src/Components/Common/Sidebar/SidebarUserCard.tsx b/src/Components/Common/Sidebar/SidebarUserCard.tsx index 69678f676d4..8df9e018e1b 100644 --- a/src/Components/Common/Sidebar/SidebarUserCard.tsx +++ b/src/Components/Common/Sidebar/SidebarUserCard.tsx @@ -1,56 +1,55 @@ -import { Link } from "raviger"; +import React from "react"; import { useTranslation } from "react-i18next"; import CareIcon from "../../../CAREUI/icons/CareIcon"; import { formatName } from "../../../Utils/utils"; import useAuthUser, { useAuthContext } from "../../../Common/hooks/useAuthUser"; +import { ShrinkedSidebarItem, SidebarItem } from "./SidebarItem"; -const SidebarUserCard = ({ shrinked }: { shrinked: boolean }) => { +interface SidebarUserCardProps { + shrinked: boolean; + handleOverflow: (value: boolean) => void; +} + +const SidebarUserCard: React.FC = ({ + shrinked, + handleOverflow, +}) => { const { t } = useTranslation(); const user = useAuthUser(); const { signOut } = useAuthContext(); + const Item = shrinked ? ShrinkedSidebarItem : SidebarItem; + return (
- - - -
- -
-
-
- - {formatName(user)} - -
-
+ + } + selected={false} + handleOverflow={handleOverflow} + /> + + -

{t("sign_out")}

-
-
+ } + selected={false} + do={signOut} + handleOverflow={handleOverflow} + />
); };