import type { Config } from '~/components/pub/my-ui/data-table'
import type { Patient } from '~/models/patient'
import { defineAsyncComponent } from 'vue'
import { educationCodes, genderCodes } from '~/lib/constants'
import { calculateAge } from '~/lib/utils'

const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-dud.vue'))

export const config: Config = {
  cols: [{width: 180}, {}, {}, {}, {}, {width: 30},],

  headers: [
    [
      { label: 'Tgl Rencana Kontrol' },
      { label: 'Spesialis' },
      { label: 'Sub Spesialis' },
      { label: 'DPJP' },
      { label: 'Status SEP' },
      { label: 'Action' },
    ],
  ],

  keys: ['date', 'specialist.name', 'subspecialist.name', 'doctor.employee.person.name', 'sep_status', 'action'],

  delKeyNames: [
    { key: 'code', label: 'Kode' },
    { key: 'name', label: 'Nama' },
  ],

  parses: {
    date: (rec: unknown): unknown => {
      const date = (rec as any).date
      if (typeof date == 'object' && date) {
        return (date as Date).toLocaleDateString('id-ID')
      } else if (typeof date == 'string') {
        return (date as string).substring(0, 10)
      }
      return date
    },
    specialist_subspecialist: (rec: unknown): unknown => {
      return '-'
    },
    dpjp: (rec: unknown): unknown => {
      // const { person } = rec as Patient
      return '-'
    },
  },

  components: {
    action(rec, idx) {
      return {
        idx,
        rec: rec as object,
        component: action,
      }
    },
  },

  htmls: {
    sep_status(_rec) {
      return 'SEP Internal'
    },
  },
}
