import type { IconName } from '@/components/marketing/icons';

export type PanelNavItem = {
  href: string;
  label: string;
  icon: IconName;
  match?: 'exact' | 'prefix';
};

/** Primary mobile destinations — keep to five. */
export const mobilePrimaryNav: PanelNavItem[] = [
  { href: '/dashboard', label: 'Home', icon: 'home', match: 'exact' },
  { href: '/dashboard/products', label: 'Products', icon: 'box', match: 'prefix' },
  { href: '/dashboard/offers', label: 'Offers', icon: 'offers', match: 'prefix' },
  { href: '/dashboard/orders', label: 'Orders', icon: 'orders', match: 'prefix' },
  { href: '/dashboard/more', label: 'More', icon: 'more', match: 'prefix' },
];

export type SidebarSection = { title?: string; items: PanelNavItem[] };

export const desktopSidebar: SidebarSection[] = [
  {
    items: [{ href: '/dashboard', label: 'Dashboard', icon: 'home', match: 'exact' }],
  },
  {
    title: 'Products',
    items: [
      { href: '/dashboard/products', label: 'Products', icon: 'box', match: 'prefix' },
      { href: '/dashboard/categories', label: 'Categories', icon: 'tag', match: 'prefix' },
      { href: '/dashboard/suppliers', label: 'Suppliers', icon: 'truck', match: 'prefix' },
    ],
  },
  {
    title: 'Sales',
    items: [
      { href: '/dashboard/customers', label: 'Customers', icon: 'users', match: 'prefix' },
      { href: '/dashboard/offers', label: 'Quick Offers', icon: 'offers', match: 'prefix' },
      { href: '/dashboard/orders', label: 'Orders', icon: 'orders', match: 'prefix' },
      { href: '/dashboard/sales', label: 'Sales', icon: 'wallet', match: 'prefix' },
      { href: '/dashboard/expenses', label: 'Expenses', icon: 'wallet', match: 'prefix' },
      { href: '/dashboard/reports', label: 'Profit & Reports', icon: 'chart', match: 'prefix' },
    ],
  },
  {
    title: 'Store',
    items: [
      { href: '/dashboard/storefront', label: 'Storefront', icon: 'store', match: 'prefix' },
      { href: '/dashboard/storefront/settings', label: 'Store Settings', icon: 'settings', match: 'prefix' },
    ],
  },
  {
    title: 'Account',
    items: [
      { href: '/dashboard/billing', label: 'Billing', icon: 'wallet', match: 'prefix' },
      { href: '/dashboard/more', label: 'More', icon: 'more', match: 'prefix' },
      { href: '/dashboard/account', label: 'Account Settings', icon: 'user', match: 'prefix' },
    ],
  },
];

export function isNavActive(pathname: string, item: PanelNavItem) {
  if (item.match === 'exact') return pathname === item.href;
  return pathname === item.href || pathname.startsWith(`${item.href}/`);
}
