import { NamedRoutes } from '@/core';
import { Routes } from '@angular/router';
import config from 'src/config';

export type TPosSaleInvoicesRouteNames = 'saleInvoices' | 'saleInvoice';

const baseRoute = `${config.isPosApplication ? '' : '/pos'}/sale_invoices`;

export const posSaleInvoicesNamedRoutes: NamedRoutes<TPosSaleInvoicesRouteNames> = {
  saleInvoices: {
    path: 'sale_invoices',
    loadComponent: () =>
      import('../../views/list.component').then((m) => m.PosSaleInvoicesComponent),
    meta: {
      title: 'فاکتورها',
      pagePath: () => baseRoute,
    },
  },
  saleInvoice: {
    path: 'sale_invoices/:invoiceId',
    loadComponent: () =>
      import('../../views/single.component').then((m) => m.PosSaleInvoiceComponent),
    meta: {
      title: 'جزئیات فاکتور',
      pagePath: (invoiceId: string) => `${baseRoute}/${invoiceId}`,
    },
  },
};

export const POS_SALE_INVOICES_ROUTES: Routes = [
  posSaleInvoicesNamedRoutes.saleInvoices,
  posSaleInvoicesNamedRoutes.saleInvoice,
];
