import { format } from 'date-fns';

export const EscalationCategory = [
  {
    label: 'Failure-Not Failure',
    value: 'Failure-Not Failure',
  },
  {
    label: 'Failure Fault',
    value: 'Failure Fault',
  },
  {
    label: 'Failure Upgrade',
    value: 'Failure Upgrade',
  },
  {
    label: 'Elite',
    value: 'Elite',
  },
  {
    label: 'New Client',
    value: 'New Client',
  },
];

export const EscalationLevel = [
  {
    label: 'VIP4',
    value: 'VIP4',
  },
  {
    label: 'VIP3',
    value: 'VIP3',
  },
  {
    label: 'VIP2',
    value: 'VIP2',
  },
  {
    label: 'VIP1',
    value: 'VIP1',
  },
  {
    label: 'New Client',
    value: 'New Client',
  },
];
export const EscalationReason = [
  {
    label: 'INBOUND / DAMAGE - ITEM UNFIT TO BE DELIVERED - by Co',
    value: 'INBOUND / DAMAGE - ITEM UNFIT TO BE DELIVERED - by Co',
  },
  {
    label: 'INBOUND / PRODUCT ISSUE - WRONG ITEM BEEN DESPATCHED - by Co',
    value: 'INBOUND / PRODUCT ISSUE - WRONG ITEM BEEN DESPATCHED - by Co',
  },
  {
    label: 'INBOUND / CANCEL - BEFORE ROUTING - by Co',
    value: 'INBOUND / CANCEL - BEFORE ROUTING - by Co',
  },
  {
    label: 'PRE-CALL / ADDRESS - WRONG ADDRESS (UNABLE TO RE-ROUTE) - by BJS',
    value: 'PRE-CALL / ADDRESS - WRONG ADDRESS (UNABLE TO RE-ROUTE) - by BJS',
  },
  {
    label: 'Predated charges PRE-CALL / DEL WINDOW - NOT SUITABLE - by CUST',
    value: 'Predated charges PRE-CALL / DEL WINDOW - NOT SUITABLE - by CUST',
  },
  {
    label: 'ON-ROUTE / ADDRESS - WRONG ADDRESS (UNABLE TO RE-ROUTE) - by BJS',
    value: 'ON-ROUTE / ADDRESS - WRONG ADDRESS (UNABLE TO RE-ROUTE) - by BJS',
  },
  {
    label: 'LOADING / STOCK RECEIPT - NO STK RECEIVED - Co',
    value: 'LOADING / STOCK RECEIPT - NO STK RECEIVED - Co',
  },
];
export const EscalationStatus = [
  {
    label: 'Pending',
    value: 'Pending',
  },
  {
    label: 'Stock Check',
    value: 'Stock Check',
  },
  {
    label: 'Ready to Post Call',
    value: 'Ready to Post Call',
  },
  {
    label: 'Post Called',
    value: 'Post Called',
  },
  {
    label: 'Completed',
    value: 'Completed',
  },
];

export const getIntegerValue = (value: number) => {
  return value ?? 0;
};

export const getStringValue = (value: string) => {
  return value === '' ? 'N/A' : value;
};

export const FormattedDate = ({ date }: any) => {
  const formattedDate = format(new Date(date), 'dd/MM/yyyy');
  return formattedDate;
};

export const javascriptStringDumpToJSON = function(data: string) {
  let d = data.replace(new RegExp(`(?<=[a-zA-Z])'(?=[a-zA-Z ])`, 'g'), '__');
  d = d.replace(new RegExp("'", 'g'), '"');
  d = d.replace(new RegExp('__', 'g'), "'");
  d = d.replace(new RegExp('None', 'g'), 'null');
  d = d.replace(new RegExp('False', 'g'), 'false');
  d = d.replace(new RegExp('True', 'g'), 'true');
  d = d.replace(new RegExp(/(\d+)\s*[a-zA-Z]/gm), '$1');
  return JSON.parse(d);
};
