import CollectionLabelIcon from '../../../assets/icons/CollectionLabelIcon';
import CustomerLabelIcon from '../../../assets/icons/CustomerLabelIcon';
import DeliveryNotes from '../../../assets/icons/DeliveryNotes';
import LoadSheetIcon from '../../../assets/icons/LoadSheetIcon';
import RunsheetIcon from '../../../assets/icons/RunsheetIcon';

export const getStatusBg = (status: string) => {
  switch (status) {
    case 'onTotalOrder':
      return 'rgba(99, 150, 229, 0.20)';
    case 'late':
      return 'rgba(233, 82, 82, 0.20)';
    case 'onComplete':
      return 'rgba(87, 219, 122, 0.20)';
    case 'onPending':
      return 'rgba(254, 186, 48, 0.20)';
    case 'onCollection':
      return 'rgba(123, 97, 255, 0.20)';
    default:
      return 'gray';
  }
};

export const getStatusColor = (status: string) => {
  switch (status) {
    case 'onTotalOrder':
      return '#6396E5';
    case 'late':
      return '#E95252';
    case 'onComplete':
      return '#29CC6A';
    case 'onPending':
      return '#FEBA30';
    case 'onCollection':
      return '#7B61FF';
    default:
      return 'gray';
  }
};

export const iconMap: Record<
  string,
  React.ComponentType<React.SVGProps<SVGSVGElement>>
> = {
  assembly: RunsheetIcon,
  heavyItems: RunsheetIcon,
  supplier: RunsheetIcon,
  vip: RunsheetIcon,
};

export const PrintIconMap: Record<
  string,
  React.ComponentType<React.SVGProps<SVGSVGElement>>
> = {
  runSheet: RunsheetIcon,
  loadSheet: LoadSheetIcon,
  deliveryLables: DeliveryNotes,
  customerLables: CustomerLabelIcon,
  collectionLables: CollectionLabelIcon,
};

// Date format
export const formatDate = (date: any) => {
  const padZero = (num: any) => num.toString().padStart(2, '0');
  const year = date.getFullYear();
  const month = padZero(date.getMonth() + 1);
  const day = padZero(date.getDate());
  // const hours = padZero(date.getHours());
  // const minutes = padZero(date.getMinutes());
  // const seconds = padZero(date.getSeconds());

  return `
  ${day}/${month}/${year}
  `;
};

export const displayValueOrNA = (value: any) => {
  const isBlankArray = Array.isArray(value) && value.length === 0;
  if (value === 0) {
    return 0;
  }
  if (value === 'NA' || value === undefined || value === null || isBlankArray) {
    return 'NA';
  }
  return value;
};
