import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import ReloadIcon from '../../components/Icons/ReloadIcon'
import EditIcon from '../../components/Icons/EditIcon'
import DocumentJobIcon from '../../components/Icons/DocumentJobIcon'

export const DocumentJob = {
  name: 'documentJob',
  label: 'Document Job',
  prefix: 'DSZ',
  icon: DocumentJobIcon,
  actions: [
    {
      name: 'info',
      label: 'Info',
      default: true,
      row: true,
      icon: InfoCircleIcon,
      url: (_id) =>
        `/dashboard/management/documentjobs/info?documentJobId=${_id}`
    },

    {
      name: 'reload',
      label: 'Reload',
      icon: ReloadIcon,
      url: (_id) =>
        `/dashboard/management/documentjobs/info?documentJobId=${_id}&action=reload`
    },
    {
      name: 'edit',
      label: 'Edit',
      row: true,
      icon: EditIcon,
      url: (_id) =>
        `/dashboard/management/documentjobs/info?documentJobId=${_id}&action=edit`
    }
  ],
  columns: ['name', '_id', 'width', 'height', 'createdAt', 'updatedAt'],
  filters: ['name', '_id', 'width', 'height'],
  sorters: ['name', 'width', 'height', 'createdAt', 'updatedAt'],
  properties: [
    {
      name: '_id',
      label: 'ID',
      type: 'id',
      objectType: 'documentJob',
      showCopy: true
    },
    {
      name: 'createdAt',
      label: 'Created At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'name',
      label: 'Name',
      required: true,
      type: 'text',
      columnWidth: 200,
      columnFixed: 'left',
      value: (objectData) => {
        return `${objectData?.documentTemplate?.name || 'No template'} (${objectData?.object?.name || 'No name'})`
      }
    },
    {
      name: 'updatedAt',
      label: 'Updated At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'objectType',
      label: 'Object Type',
      required: true,
      columnWidth: 150,
      type: 'objectType'
    },
    {
      name: 'object',
      label: 'Object',
      required: true,
      columnWidth: 150,
      type: 'object',
      objectType: (objectData) => {
        return objectData?.objectType
      }
    },
    {
      name: 'documentTemplate',
      label: 'Template',
      required: true,
      columnWidth: 150,
      type: 'object',
      objectType: 'documentTemplate',
      masterFilter: (objectData) => {
        return {
          active: true,
          global: false,
          objectType: objectData.objectType
        }
      }
    },
    {
      name: 'documentPrinter',
      label: 'Printer',
      required: true,
      columnWidth: 150,
      type: 'object',
      objectType: 'documentPrinter',
      masterFilter: () => {
        return {
          active: true,
          online: true
        }
      }
    }
  ]
}
