import React, { useCallback, useEffect, 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 './shared/AsyncSelect'; import { ChevronGrabberHorizontal, FolderIcon, GlobeIcon, LifeBuoyIcon, QuestionMarkRoundIcon, SettingsSlidersIcon, } from './shared/CustomIcon'; import { Tabs } from 'components/shared/Tabs'; const Sidebar = () => { const { orgSlug } = useParams(); const navigate = useNavigate(); const client = useGQLClient(); const { disconnect } = useDisconnect(); const [selectedOrgSlug, setSelectedOrgSlug] = useState(orgSlug); const [organizations, setOrganizations] = useState([]); const fetchUserOrganizations = useCallback(async () => { const { organizations } = await client.getOrganizations(); setOrganizations(organizations); }, [orgSlug]); useEffect(() => { fetchUserOrganizations(); setSelectedOrgSlug(orgSlug); }, [orgSlug]); const handleLogOut = useCallback(() => { disconnect(); navigate('/login'); }, [disconnect, navigate]); return (
Snowball Logo Snowball
{ setSelectedOrgSlug(value!); navigate(`/${value}`); }} selected={(_, index) => (
Application Logo
{organizations[index!]?.name}
Organization
)} arrow={} > {/* TODO: Show label organization and manage in option */} {organizations.map((org) => ( ))}
{[ { title: 'Projects', icon: }, { title: 'Settings', icon: }, ].map(({ title, icon }, index) => ( {title} ))}
{/* TODO: use proper link buttons */} } value=""> Log Out } value=""> Documentation } value=""> Support
); }; export default Sidebar;