import type { Config, RecComponent } from '~/components/pub/my-ui/data-table'
import { defineAsyncComponent } from 'vue'

type SmallDetailDto = any

const statusBadge = defineAsyncComponent(() => import('./status-badge.vue'))
const verifyButton = defineAsyncComponent(() => import('./verify-button.vue'))

export const config: Config = {
  cols: [
    { width: 120 },
    { width: 150 },
    { width: 150 },
    { width: 150 },
    { width: 150 },
    { width: 180 },
    { width: 150 },
    { width: 100 },
  ],

  headers: [
    [
      { label: 'TANGGAL MASUK' },
      { label: 'PJ BERKAS RM' },
      { label: 'DOKTER' },
      { label: 'JENIS RUANGAN' },
      { label: 'JENIS TINDAKAN' },
      { label: 'TANGGAL JADWAL TINDAKAN' },
      { label: 'STATUS' },
      { label: 'AKSI' },
    ],
  ],

  keys: [
    'tanggalMasuk',
    'pjBerkasRm',
    'dokter',
    'jenisRuangan',
    'jenisTindakan',
    'tanggalJadwalTindakan',
    'status',
    'action',
  ],

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

  parses: {
    parent: (rec: unknown): unknown => {
      const recX = rec as SmallDetailDto
      return recX.parent?.name || '-'
    },
  },

  components: {
    status(rec, idx) {
      const res: RecComponent = {
        idx,
        rec: rec as object,
        component: statusBadge,
      }
      return res
    },
    action(rec, idx) {
      const res: RecComponent = {
        idx,
        rec: rec as object,
        component: verifyButton,
      }
      return res
    },
  },

  htmls: {},
}

