'use client';

import {
  useQueryStates,
  parseAsString,
  parseAsInteger,
  parseAsBoolean,
  parseAsArrayOf,
} from 'nuqs';

export const useOrderFilters = () => {
  return useQueryStates(
    {
      status: parseAsString,
      sellerName: parseAsString,
      sellerId: parseAsString,
      customerName: parseAsString,
      customerId: parseAsInteger,
      partnerName: parseAsString,
      partnerId: parseAsString,

      codfilial: parseAsArrayOf(parseAsString, ','),
      codusur2: parseAsArrayOf(parseAsString, ','),
      store: parseAsArrayOf(parseAsString, ','),
      orderId: parseAsInteger,
      productId: parseAsInteger,
      productName: parseAsString,
      stockId: parseAsArrayOf(parseAsString, ','),

      hasPreBox: parseAsBoolean.withDefault(false),
      includeCheckout: parseAsBoolean.withDefault(false),

      createDateIni: parseAsString,
      createDateEnd: parseAsString,

      searchTriggered: parseAsBoolean.withDefault(false),
    },
    {
      shallow: true,
      history: 'replace',
    }
  );
};
