import { i18next } from '@things-factory/i18n-base'

export const WORKSHEET_TYPE = {
  UNLOADING: {
    name: i18next.t('label.unloading'),
    value: 'UNLOADING'
  },
  PUTAWAY: {
    name: i18next.t('label.putaway'),
    value: 'PUTAWAY'
  },
  BATCH_PICKING: {
    name: i18next.t('label.batch_picking'),
    value: 'BATCH_PICKING'
  },
  CYCLE_COUNT: {
    name: i18next.t('label.cycle_count'),
    value: 'CYCLE_COUNT'
  },
  CYCLE_COUNT_RECHECK: {
    name: i18next.t('label.cycle_count_recheck'),
    value: 'CYCLE_COUNT_RECHECK'
  },
  STOCK_TAKE: {
    name: i18next.t('label.stock_take'),
    value: 'STOCK_TAKE'
  },
  VAS: {
    name: i18next.t('label.vas'),
    value: 'VAS'
  },
  WAREHOUSE_RETURN: {
    name: i18next.t('label.warehouse_return'),
    value: 'WAREHOUSE_RETURN'
  },
  PICKING: {
    name: i18next.t('label.picking'),
    value: 'PICKING'
  },
  PACKING: {
    name: i18next.t('label.packing'),
    value: 'PACKING'
  },
  LOADING: {
    name: i18next.t('label.loading'),
    value: 'LOADING'
  },
  UNLOADING_RETURN: {
    name: i18next.t('label.unloading_return'),
    value: 'UNLOADING_RETURN'
  },
  PUTAWAY_RETURN: {
    name: i18next.t('label.putaway_return'),
    value: 'PUTAWAY_RETURN'
  },
  SORTING: {
    name: i18next.t('label.sorting'),
    value: 'SORTING'
  },
  PICKING_REPLENISHMENT: {
    name: i18next.t('label.picking_replenishment'),
    value: 'PICKING_REPLENISHMENT'
  },
  PUTAWAY_REPLENISHMENT: {
    name: i18next.t('label.putaway_replenishment'),
    value: 'PUTAWAY_REPLENISHMENT'
  },
  ZONE_PICKING: {
    name: i18next.t('label.zone_picking'),
    value: 'ZONE_PICKING'
  }
}

export const WORKSHEET_STATUS = {
  DEACTIVATED: {
    name: i18next.t('label.deactivated'),
    value: 'DEACTIVATED'
  },
  EXECUTING: {
    name: i18next.t('label.executing'),
    value: 'EXECUTING'
  },
  DONE: {
    name: i18next.t('label.done'),
    value: 'DONE'
  },
  ADJUSTED: {
    name: i18next.t('label.adjusted'),
    value: 'ADJUSTED'
  },
  PENDING_APPROVAL: {
    name: i18next.t('label.pending_approval'),
    value: 'PENDING_APPROVAL'
  },
  PENDING_ADJUSTMENT: {
    name: i18next.t('label.pending_adjustment'),
    value: 'PENDING_ADJUSTMENT'
  },
  PARTIALLY_UNLOADED: {
    name: i18next.t('label.partially_unloaded'),
    value: 'PARTIALLY_UNLOADED'
  },
  NOT_TALLY: {
    name: i18next.t('label.not_tally'),
    value: 'NOT_TALLY'
  },
  CANCELLED: {
    name: i18next.t('label.cancel'),
    value: 'CANCELLED'
  },
  PARTIAL_PENDING_APPROVAL: {
    name: i18next.t('label.partial_pending_approval'),
    value: 'PARTIAL_PENDING_APPROVAL'
  },
  PARTIAL_PROCESSING: {
    name: i18next.t('label.partial_processing'),
    value: 'PARTIAL_PROCESSING'
  },
  PARTIAL_EXECUTING: {
    name: i18next.t('label.partial_executing'),
    value: 'PARTIAL_EXECUTING'
  }
}

export const getWorksheetStatusCandidates = function (worksheetType) {
  if (!worksheetType) throw new Error('There is no worksheet type')

  switch (worksheetType) {
    case WORKSHEET_TYPE.CYCLE_COUNT:
      return [
        WORKSHEET_STATUS.DEACTIVATED,
        WORKSHEET_STATUS.EXECUTING,
        WORKSHEET_STATUS.DONE,
        WORKSHEET_STATUS.ADJUSTED,
        WORKSHEET_STATUS.NOT_TALLY
      ]

    default:
      throw new Error('Failed to find via passed order type')
  }
}
