import type { Config } 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'))

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

  headers: [
    [
      { label: 'Kode' },
      { label: 'Nama' },
      { label: 'Lantai' },
      { label: '' },
    ],
  ],

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

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

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

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

  htmls: {},
}
