<%- include('../catalogCommerce/assets.ejs') %>
<%
  const orderTotal = typeof totalCount !== 'undefined' ? totalCount : orders.length;
  const orderStatus = String(currentMenu || '').replace('orders-', '') || 'all';
  const orderTabs = [
    { href: '/dashboard/orders/all', label: i18n.__('orders.all'), icon: 'ti-list', active: orderStatus === 'all', tone: 'neutral' },
    { href: '/dashboard/orders/new', label: i18n.__('orders.new'), icon: 'ti-sparkles', count: counts?.[0]?.value || 0, active: orderStatus === 'new', tone: 'warning' },
    { href: '/dashboard/orders/current', label: i18n.__('orders.current'), icon: 'ti-route', count: counts?.[1]?.value || 0, active: orderStatus === 'current', tone: 'info' },
    { href: '/dashboard/orders/finished', label: i18n.__('orders.finished'), icon: 'ti-circle-check', count: counts?.[2]?.value || 0, active: orderStatus === 'finished', tone: 'success' },
    { href: '/dashboard/orders/cancelled', label: i18n.__('orders.cancelled'), icon: 'ti-circle-x', count: counts?.[3]?.value || 0, active: orderStatus === 'cancelled', tone: 'danger' }
  ];
%>
<main class="cc-console" data-cc-console data-module="orders"
  data-filter-url="<%= filterData.url %>" data-csrf="<%= typeof csrfToken !== 'undefined' ? csrfToken : '' %>">
  <%- include('../catalogCommerce/header.ejs', {
    title: i18n.__('orders.orders'),
    subtitle: i18n.__('catalogCommerce.ordersSubtitle'),
    icon: 'ti-shopping-cart',
    count: orderTotal,
    createUrl: '',
    hasFilters: true,
    tabs: orderTabs,
    secondaryLinks: []
  }) %>
  <%- include('../catalogCommerce/filters.ejs', { filterData, lang, i18n }) %>
  <p class="cc-error" data-cc-error hidden></p>
  <section class="cc-results-shell">
    <div class="cc-results-shell__bar">
      <strong><%= i18n.__('catalogCommerce.ordersRegistry') %></strong>
      <span><%= i18n.__('catalogCommerce.ordersRegistryDescription') %></span>
    </div>
    <div data-cc-results><%- include('./dataTable.ejs', { orders, paginationHtml, lang, i18n, moment }) %></div>
  </section>
</main>
