import NoteIcon from '../../components/Icons/NoteIcon'
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import EditIcon from '../../components/Icons/EditIcon'
import CheckIcon from '../../components/Icons/CheckIcon'
import XMarkIcon from '../../components/Icons/XMarkIcon'

export const Note = {
  name: 'note',
  label: 'Note',
  labelPlural: 'Notes',
  prefix: 'NTE',
  icon: NoteIcon,
  actions: [
    {
      name: 'info',
      label: 'Info',
      default: true,
      row: true,
      icon: InfoCircleIcon,
      url: (_id) => `/dashboard/management/notes/info?noteId=${_id}`
    },
    {
      name: 'edit',
      label: 'Edit',
      icon: EditIcon,
      visible: (objectData) => {
        return !(objectData?._isEditing && objectData?._isEditing == true)
      }
    },
    {
      name: 'cancelEdit',
      label: 'Cancel Edits',
      icon: XMarkIcon,
      visible: (objectData) => {
        return objectData?._isEditing && objectData?._isEditing == true
      }
    },
    {
      name: 'finishEdit',
      label: 'Save Edits',
      icon: CheckIcon,
      visible: (objectData) => {
        return objectData?._isEditing && objectData?._isEditing == true
      }
    }
  ],
  columns: [
    '_reference',
    'user',
    'parentType',
    'parent',
    'noteType',
    'createdAt',
    'updatedAt'
  ],
  filters: [
    '_id',
    'user',
    'user._id',
    'parentType',
    'parent',
    'parent._id',
    'noteType',
    'noteType._id',
    'createdAt',
    'updatedAt',
    '_reference'
  ],
  sorters: ['createdAt', 'updatedAt', 'parentType', 'noteType'],
  properties: [
    {
      name: '_id',
      label: 'ID',
      type: 'id',
      objectType: 'note',
      showCopy: true
    },
    {
      name: 'createdAt',
      label: 'Created At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: '_reference',
      label: 'Reference',
      type: 'reference',
      columnFixed: 'left',
      objectType: 'note',
      showCopy: true,
      readOnly: true,
      columnWidth: 180
    },
    {
      name: 'updatedAt',
      label: 'Updated At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'user',
      label: 'User',
      type: 'object',
      objectType: 'user',
      showHyperlink: true
    },
    {
      name: 'parentType',
      label: 'Parent Type',
      type: 'objectType',
      required: true
    },
    {
      name: 'parent',
      label: 'Parent',
      type: 'object',
      objectType: (objectData) => {
        return objectData.parentType
      },
      showHyperlink: true,
      required: true
    },
    {
      name: 'content',
      label: 'Content',
      type: 'markdown',
      required: true,
      span: 2
    },
    {
      name: 'noteType',
      label: 'Note Type',
      type: 'object',
      objectType: 'noteType',
      showHyperlink: true,
      required: true
    }
  ]
}
