Files
ipad/src/components/layout/Sidebar.tsx
YI FANG 8155c9f95d init
2025-11-26 09:50:49 +08:00

74 lines
2.7 KiB
TypeScript

import type { QuickActionType } from '../../data/mockData';
import { Button } from '../ui';
import { cls } from '../../utils/cls';
export type SectionKey = 'home' | 'exam' | 'booking' | 'support';
interface SidebarProps {
active: SectionKey;
onNavigate: (key: SectionKey) => void;
onQuickAction: (action: Exclude<QuickActionType, 'none'>) => void;
}
const IconHome = () => <span className='text-xs'>🏠</span>;
const IconHospital = () => <span className='text-xs'>🏥</span>;
const IconCalendar = () => <span className='text-xs'>📅</span>;
const IconSupport = () => <span className='text-xs'>💬</span>;
const NAV_ITEMS = [
{ key: 'home', icon: IconHome, label: '首页' },
{ key: 'exam', icon: IconHospital, label: '体检中心' },
{ key: 'booking', icon: IconCalendar, label: '预约中心' },
{ key: 'support', icon: IconSupport, label: '客服咨询' },
] as const;
export const Sidebar = ({ active, onNavigate, onQuickAction }: SidebarProps) => (
<aside className='bg-white border-r p-4 flex flex-col gap-4'>
<div>
<div className='text-base font-semibold'> · </div>
<div className='text-xs text-gray-500 mt-1'>iPad </div>
</div>
<nav className='space-y-1'>
{NAV_ITEMS.map((item) => (
<Button
key={item.key}
onClick={() => onNavigate(item.key as SectionKey)}
className={cls('w-full justify-start', active === item.key && 'bg-gray-100 border-gray-900 text-gray-900')}
>
<item.icon />
<span>{item.label}</span>
</Button>
))}
</nav>
<section className='mt-2 p-3 rounded-2xl border bg-gray-50/50'>
<div className='text-sm text-gray-700 mb-2'></div>
<div className='grid grid-cols-2 gap-2 text-xs'>
<Button className='justify-center py-1.5' onClick={() => onQuickAction('meal')}>
</Button>
<Button className='justify-center py-1.5' onClick={() => onQuickAction('vip')}>
VIP认证
</Button>
<Button className='justify-center py-1.5' onClick={() => onQuickAction('delivery')}>
</Button>
<Button className='justify-center py-1.5' onClick={() => onQuickAction('note')}>
</Button>
</div>
</section>
<section className='mt-auto p-3 rounded-2xl border bg-gray-50/70 text-xs flex flex-col gap-2'>
<div className='text-sm font-medium flex items-center gap-2'>
<span>💻</span>
<span> / IT </span>
</div>
<div className='text-gray-600'> IT / </div>
</section>
</aside>
);