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-ud.vue'))

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

  headers: [[
    { label: 'Kode' },
    { label: 'Nama' },
    { label: 'Divisi Induk' },
    { label: '' },
  ]],

  keys: ['code', 'name', 'parent', '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: {
    action(rec, idx) {
      const res: RecComponent = {
        idx,
        rec: rec as object,
        component: action,
        props: {
          size: 'sm',
        },
      }
      return res
    },
  },

  htmls: {},
}