From 30c50a3eec21e1572fc1635a1a2b483c7684bf9a Mon Sep 17 00:00:00 2001 From: Andre H Date: Wed, 28 Feb 2024 23:08:21 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore:=20use=20UserSelect=20in?= =?UTF-8?q?=20sidebar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/shared/Sidebar/Sidebar.tsx | 69 ++++++------------- 1 file changed, 22 insertions(+), 47 deletions(-) diff --git a/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx b/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx index 0d746749..1dbb3b6d 100644 --- a/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx +++ b/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx @@ -1,14 +1,11 @@ -import React, { useCallback, useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Link, NavLink, useNavigate, useParams } from 'react-router-dom'; import { Organization } from 'gql-client'; -import { Option } from '@material-tailwind/react'; import { useDisconnect } from 'wagmi'; import { useGQLClient } from 'context/GQLClientContext'; -import AsyncSelect from 'components/shared/AsyncSelect'; import { - ChevronGrabberHorizontal, FolderIcon, GlobeIcon, LifeBuoyIcon, @@ -17,6 +14,7 @@ import { } from 'components/shared/CustomIcon'; import { Tabs } from 'components/shared/Tabs'; import { Heading } from 'components/shared/Heading'; +import { UserSelect } from 'components/shared/UserSelect'; export const Sidebar = () => { const { orgSlug } = useParams(); @@ -37,6 +35,22 @@ export const Sidebar = () => { setSelectedOrgSlug(orgSlug); }, [orgSlug]); + const formattedSelected = useMemo(() => { + const selected = organizations.find((org) => org.slug === selectedOrgSlug); + return { + value: selected?.slug ?? '', + label: selected?.name ?? '', + imgSrc: '/logo.svg', + }; + }, [organizations, selectedOrgSlug, orgSlug]); + const formattedSelectOptions = useMemo(() => { + return organizations.map((org) => ({ + value: org.slug, + label: org.name, + imgSrc: '/logo.svg', + })); + }, [organizations, selectedOrgSlug, orgSlug]); + const handleLogOut = useCallback(() => { disconnect(); navigate('/login'); @@ -57,49 +71,10 @@ export const Sidebar = () => { {/* Switch organization */}
- { - setSelectedOrgSlug(value!); - navigate(`/${value}`); - }} - selected={(_, index) => ( -
- Application Logo -
-
- {organizations[index!]?.name} -
-
Organization
-
-
- )} - arrow={} - > - {/* // TODO: Show label organization and manage in option */} - {organizations.map((org) => ( - - ))} -
+ {[