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

export const DocumentPrinter = {
  name: 'documentPrinter',
  label: 'Document Printer',
  prefix: 'DPR',
  icon: DocumentPrinterIcon,
  actions: [
    {
      name: 'info',
      label: 'Info',
      default: true,
      row: true,
      icon: InfoCircleIcon,
      url: (_id) =>
        `/dashboard/management/documentprinters/info?documentPrinterId=${_id}`
    },

    {
      name: 'reload',
      label: 'Reload',
      icon: ReloadIcon,
      url: (_id) =>
        `/dashboard/management/documentprinters/info?documentPrinterId=${_id}&action=reload`
    },
    {
      name: 'edit',
      label: 'Edit',
      row: true,
      icon: EditIcon,
      url: (_id) =>
        `/dashboard/management/documentprinters/info?documentPrinterId=${_id}&action=edit`
    }
  ],
  columns: [
    'name',
    '_id',
    'documentSize',
    'documentSize._id',
    'createdAt',
    'updatedAt'
  ],
  filters: ['name', '_id'],
  sorters: ['name', 'documentSize', 'createdAt', 'updatedAt'],
  properties: [
    {
      name: '_id',
      label: 'ID',
      type: 'id',
      objectType: 'documentPrinter',
      showCopy: true
    },
    {
      name: 'createdAt',
      label: 'Created At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'name',
      label: 'Name',
      required: true,
      type: 'text',
      columnWidth: 200,
      columnFixed: 'left'
    },
    {
      name: 'updatedAt',
      label: 'Updated At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'documentSize',
      label: 'Document Size',
      required: true,
      type: 'object',
      objectType: 'documentSize'
    },
    {
      name: 'documentSize._id',
      label: 'Document Size ID',
      type: 'id',
      objectType: 'documentSize',
      showCopy: true,
      showHyperlink: true
    },
    {
      name: 'active',
      label: 'Active',
      required: true,
      type: 'bool'
    },
    {
      name: 'tags',
      label: 'Tags',
      required: false,
      type: 'tags'
    },
    { name: 'global', label: 'Global', required: false, type: 'bool' },
    {
      name: 'parent',
      label: 'Parent',
      required: false,
      type: 'object',
      objectType: 'documentPrinter',
      disabled: (documentPrinter) => {
        if (documentPrinter.global == true) {
          documentPrinter.parent = null
        }
        return documentPrinter.global
      }
    },
    {
      name: 'parent._id',
      label: 'Parent ID',
      required: false,
      type: 'id',
      objectType: 'documentPrinter'
    }
  ]
}
