import JobIcon from '../../components/Icons/JobIcon'
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import ReloadIcon from '../../components/Icons/ReloadIcon'

export const Job = {
  name: 'job',
  label: 'Job',
  prefix: 'JOB',
  icon: JobIcon,
  actions: [
    {
      name: 'info',
      label: 'Info',
      default: true,
      row: true,
      icon: InfoCircleIcon,
      url: (_id) => `/dashboard/production/jobs/info?jobId=${_id}`
    },
    {
      name: 'reload',
      label: 'Reload',
      icon: ReloadIcon,
      url: (_id) => `/dashboard/production/jobs/info?jobId=${_id}&action=reload`
    }
  ],
  columns: [
    '_id',
    'gcodeFile',
    'gcodeFile._id',
    'state',
    'quantity',
    'createdAt'
  ],
  filters: ['state', '_id', 'gcodeFile._id', 'quantity'],
  sorters: ['createdAt', 'state', 'quantity', 'gcodeFile'],
  properties: [
    {
      name: '_id',
      label: 'ID',
      type: 'id',
      columnFixed: 'left',
      objectType: 'job',
      showCopy: true
    },
    {
      name: 'state',
      label: 'State',
      type: 'state',
      objectType: 'job',
      showStatus: true,
      showProgress: true,
      showId: false,
      showQuantity: false,
      columnWidth: 150,
      readOnly: true
    },
    {
      name: 'gcodeFile',
      label: 'GCode File',
      type: 'object',
      columnFixed: 'left',
      objectType: 'gcodeFile',
      required: true
    },
    {
      name: 'gcodeFile._id',
      label: 'GCode File ID',
      type: 'id',
      objectType: 'gcodeFile',
      showHyperlink: true
    },
    {
      name: 'quantity',
      label: 'Quantity',
      type: 'number',
      columnWidth: 125,
      required: true
    },
    {
      name: 'createdAt',
      label: 'Created At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'startedAt',
      label: 'Started At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'printers',
      label: 'Printers',
      type: 'objectList',
      objectType: 'printer',
      required: true
    }
  ]
}
