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

type SmallDetailDto = any

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

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

  headers: [[{ label: 'Kode' }, { label: 'Nama (FHIR)' }, { label: 'Nama (ID)' }, { label: '' }]],

  keys: ['code', 'name', 'indName', 'action'],

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

  parses: {},

  components: {
    action(rec, idx) {
      const res: RecComponent = {
        idx,
        rec: rec as object,
        component: action,
      }
      return res
    },
    status(rec, idx) {
      const recX = rec as SmallDetailDto
      if (recX.status_code === null) {
        recX.status_code = 0
      }
      const res: RecComponent = {
        idx,
        rec: rec as object,
        component: statusBadge,
      }
      return res
    },
  },

  htmls: {
    patient_address(_rec) {
      return '-'
    },
  },
}
