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

export const REPLENISHMENT_CONFIG = {
  CREATE: {
    list: {
      fields: [
        'bizplace',
        'productSku',
        'packingType',
        'packingSize',
        'pickingShelfQty',
        'storageQty',
        'minQty',
        'transferQty'
      ]
    },
    pagination: { limit: 100, pages: [100, 200, 500, 1000] },
    rows: { selectable: { multiple: true } },
    columns: [
      { type: 'gutter', gutterName: 'sequence' },
      { type: 'gutter', gutterName: 'row-selector', multiple: true },
      {
        type: 'object',
        name: 'bizplace',
        header: i18next.t('field.company'),
        imex: { 
          type: 'string',
          header: i18next.t('field.company'),
          key: 'bizplace.name',
          width: 30
         },
        label: true,
        sortable: true,
        width: 250
      },
      {
        type: 'string',
        name: 'productSKU',
        header: i18next.t('field.sku'),
        imex: { 
          type: 'string',
          key: 'productSKU',
          header: i18next.t('field.sku'),
          width: 30
         },
        width: 200
      },
      {
        type: 'string',
        name: 'packingType',
        header: i18next.t('field.packing_type'),
        imex: {
          type: 'string',
          key: 'packingType',
          header: i18next.t('field.packing_type'),
          width: 30
        },
        width: 150
      },
      {
        type: 'string',
        name: 'packingSize',
        header: i18next.t('field.packing_size'),
        imex: {
          type: 'number',
          key: 'packingSize',
          header: i18next.t('field.packing_size'),
          width: 30
        },
        width: 150
      },
      {
        type: 'float',
        name: 'pickingShelfQty',
        header: i18next.t('field.picking_shelf_qty'),
        imex: {
          type: 'number',
          key: 'pickingShelfQty',
          header: i18next.t('field.picking_shelf_qty'),
          width: 30
        },
        width: 150
      },
      {
        type: 'float',
        name: 'storageQty',
        header: i18next.t('field.storage_qty'),
        imex: {
          type: 'number',
          key: 'storageQty',
          header: i18next.t('field.storage_qty'),
          width: 30
        },
        width: 150
      },
      {
        type: 'float',
        name: 'minQty',
        header: i18next.t('field.min_qty'),
        imex: {
          type: 'number',
          key: 'minQty',
          header: i18next.t('field.min_qty'),
          width: 30
        },
        width: 150
      },
      {
        type: 'float',
        name: 'transferQty',
        header: i18next.t('field.transfer_qty'),
        imex: {
          type: 'number',
          key: 'transferQty',
          header: i18next.t('field.transfer_qty'),
          width: 30
        },
        record: { editable: true },
        width: 150
      }
    ]
  },
  LIST: {
    list: {
      fields: ['orderNo', 'type', 'status', 'assignedPicker', 'createdAt', 'startedAt', 'endedAt', 'updater']
    },
    pagination: { limit: 100, pages: [100, 200, 500, 1000] },
    rows: { selectable: { multiple: true } },
    columns: [
      { type: 'gutter', gutterName: 'sequence' },
      { type: 'gutter', gutterName: 'row-selector', multiple: true },
      {
        type: 'gutter',
        gutterName: 'button',
        icon: 'reorder',
        handlers: {
          click: (columns, data, column, record, rowIndex) => {
            navigate(`replenishment_detail/${record.name}`)
          }
        }
      },
      {
        type: 'string',
        name: 'name',
        header: i18next.t('field.order_no'),
        width: 150
      },
      {
        type: 'string',
        name: 'status',
        header: i18next.t('field.status'),
        width: 150
      },
      {
        type: 'datetime',
        name: 'createdAt',
        header: i18next.t('field.created_at'),
        width: 150
      },
      {
        type: 'object',
        name: 'creator',
        header: i18next.t('field.created_by'),
        width: 150
      }
    ]
  },
  DETAIL: {
    list: {
      fields: ['cartonId', 'sku', 'product.name', 'storageLocation', 'transferQty', 'status', 'updater']
    },
    pagination: { infinite: true },
    rows: { selectable: { multiple: true } },
    columns: [
      { type: 'gutter', gutterName: 'sequence' },
      {
        type: 'object',
        name: 'bizplace',
        header: i18next.t('field.company'),
        width: 150
      },
      {
        type: 'string',
        name: 'productSKU',
        header: i18next.t('field.sku'),
        width: 150
      },
      {
        type: 'string',
        name: 'packingType',
        header: i18next.t('field.packing_type'),
        width: 150
      },
      {
        type: 'string',
        name: 'packingSize',
        header: i18next.t('field.packing_size'),
        width: 150
      },
      {
        type: 'float',
        name: 'transferQty',
        header: i18next.t('field.transfer_qty'),
        record: { editable: true },
        width: 150
      }
    ]
  }
}
