import FilamentStockIcon from '../../components/Icons/FilamentStockIcon'
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'

export const FilamentStock = {
  name: 'filamentStock',
  label: 'Filament Stock',
  prefix: 'FLS',
  icon: FilamentStockIcon,
  actions: [
    {
      name: 'info',
      label: 'Info',
      default: true,
      row: true,
      icon: InfoCircleIcon,
      url: (_id) =>
        `/dashboard/inventory/filamentstocks/info?filamentStockId=${_id}`
    }
  ],
  columns: [
    '_id',
    'state',
    'currentWeight',
    'startingWeight',
    'filament',
    'filament._id',
    'createdAt',
    'updatedAt'
  ],
  filters: ['_id'],
  sorters: ['createdAt', 'updatedAt'],
  properties: [
    {
      name: '_id',
      label: 'ID',
      type: 'id',
      columnFixed: 'left',
      objectType: 'filamentStock',
      showCopy: true
    },
    {
      name: 'createdAt',
      label: 'Created At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'state',
      label: 'State',
      type: 'state',
      objectType: 'filamentStock',
      readOnly: true
    },
    {
      name: 'updatedAt',
      label: 'Updated At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'filament',
      label: 'Filament',
      type: 'object',
      objectType: 'filament',
      readOnly: true,
      initial: true,
      required: true
    },
    {
      name: 'filament._id',
      label: 'Filament ID',
      type: 'id',
      objectType: 'filament',
      showHyperlink: true,
      readOnly: true
    },
    {
      name: 'currentWeight',
      label: 'Current Weight',
      type: 'netGross',
      suffix: 'g',
      readOnly: true,
      required: true,
      columnWidth: 300,
      value: (objectData) => {
        if (!objectData.currentWeight) {
          return objectData?.startingWeight
        } else {
          return objectData.currentWeight
        }
      }
    },
    {
      name: 'startingWeight',
      label: 'Starting Weight',
      type: 'netGross',
      suffix: 'g',
      readOnly: true,
      initial: true,
      required: true,
      columnWidth: 300,
      difference: (objectData) => {
        return objectData?.filament?.emptySpoolWeight
      }
    }
  ]
}
