feat: add sidebar content

This commit is contained in:
rajun 2026-10-27 16:28:54 +05:30
parent 94ac0a1d02
commit 468d2c6940

View File

@ -0,0 +1,61 @@
import { Plus } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { ClientLogo } from '~/components/ui/client-logo';
import { Text } from '~/components/ui/text';
import { SidebarBrand } from '~/components/admin/sidebar/sidebar-brand';
import { SidebarFooter } from '~/components/admin/sidebar/sidebar-footer';
import { SidebarLink } from '~/components/admin/sidebar/sidebar-link';
import { ASSET_FILTER } from '~/data/assets/constants';
import { ROUTES } from '~/data/routes';
import { useActiveNav, type NavSection } from '~/hooks/admin/use-active-nav';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import { useAdminDialogs } from '~/hooks/admin/use-admin-dialogs';
import { toBrand } from '~/services/asset-media';
export function SidebarContent({ onNavigate }: { onNavigate?: () => void }) {
const { projects, counts } = useAdminData();
const { openProject } = useAdminDialogs();
const active = useActiveNav();
const clients = projects.filter((project) => project.status === 'active');
const nav: { section: NavSection; label: string; to: string; count: number }[] = [
{ section: 'projects', label: 'Projects', to: ROUTES.projects, count: clients.length },
{ section: 'assets', label: 'All assets', to: ROUTES.assets, count: counts.total },
{ section: 'unassigned', label: 'Unassigned', to: ROUTES.assetsFiltered(ASSET_FILTER.unassigned), count: counts.unassigned },
];
return (
<div className='flex h-full flex-col gap-[22px] px-3 py-4'>
<SidebarBrand onNavigate={onNavigate} />
<nav aria-label='Main' className='flex flex-col gap-0.5'>
{nav.map((item) => (
<SidebarLink key={item.section} size='nav' active={active.section === item.section} onNavigate={onNavigate} {...item} />
))}
</nav>
<div className='flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto'>
<div className='flex items-center justify-between px-2.5 pb-1.5'>
<Text as='span' variant='eyebrow'>Clients</Text>
<Button variant='ghost' size='icon-sm' className='h-5 w-5 rounded-option' aria-label='New project' onClick={() => openProject()}>
<Plus size={12} strokeWidth={2.4} />
</Button>
</div>
{clients.map((project) => (
<SidebarLink
key={project.id}
size='client'
to={ROUTES.project(project.id)}
label={project.name}
count={project.assetCount}
active={active.projectId === project.id}
leading={<ClientLogo brand={toBrand(project)} variant='mark' size='sm' />}
onNavigate={onNavigate}
/>
))}
</div>
<SidebarFooter settingsActive={active.section === 'settings'} onNavigate={onNavigate} />
</div>
);
}