import type { Config } from '~/components/pub/my-ui/data-table'
import type { Patient } from '~/models/patient'
import { defineAsyncComponent } from 'vue'

const lampiranBtn = defineAsyncComponent(() => import('../_common/print-btn.vue'))

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

  headers: [
    [
      { label: 'Tanggal/Jam' },
      { label: 'Dokter' },
      { label: 'Tempat Layanan' },
      { label: 'KSM' },
      { label: 'Tanggal/Jam' },
      { label: 'Tujuan' },
      { label: 'Dokter' },
      { label: 'Berkas' },
    ],
  ],

  keys: ['birth_date', 'person.name', 'person.name', 'person.name', 'person.name', 'birth_date','person.name', 'action', ],

  parses: {
    birth_date: (rec: unknown): unknown => {
      const { person } = rec as Patient

      if (typeof person.birthDate == 'object' && person.birthDate) {
        return (person.birthDate as Date).toLocaleDateString('id-ID')
      } else if (typeof person.birthDate == 'string') {
        return (person.birthDate as string).substring(0, 10)
      }
      return person.birthDate
    },
  },

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

  htmls: {
    
  },
}
