import moment from 'moment';
import {
  ShopeeOrderPdfPrintJob,
  LazadaOrderPdfPrintJob,
  TiktokOrderPdfPrintJob,
} from '@/models/orderPdf';

export const PRINT_DAY_CLEANUP = 14;

export const PLATFORM_MODELS = [
  { name: 'shopee', model: ShopeeOrderPdfPrintJob },
  { name: 'lazada', model: LazadaOrderPdfPrintJob },
  { name: 'tiktok', model: TiktokOrderPdfPrintJob },
];

export const PLATFORM_COLORS = {
  shopee: 'orange',
  lazada: 'blue',
  tiktok: 'red',
};

/**
 * @param {Date|string|number} createdAt
 * @returns {number|null}
 */
export const normalizeTimestamp = (createdAt) => {
  if (!createdAt) {
    return null;
  }

  if (createdAt instanceof Date) {
    return createdAt.getTime();
  }

  if (typeof createdAt === 'string') {
    return moment(createdAt).valueOf();
  }

  if (typeof createdAt === 'number') {
    return createdAt;
  }

  return null;
};
