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: 'Karyawan' },
      { label: 'Status Kepala' },
      { label: '' },
    ],
  ],

  keys: ['code', 'name', 'division', 'employee', 'head', 'action'],

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

  parses: {
    division: (rec: unknown): unknown => {
      const recX = rec as SmallDetailDto
      return recX.division?.name || '-'
    },
    employee: (rec: unknown): unknown => {
      const recX = rec as SmallDetailDto
      return recX.employee?.name || '-'
    },
    head: (rec: unknown): unknown => {
      const recX = rec as SmallDetailDto
      return recX.headStatus ? 'Ya' : 'Tidak'
    },
  },

  components: {
    action(rec, idx) {
      const res: RecComponent = {
        idx,
        rec: rec as object,
        component: action,
        props: {
          size: 'sm',
        },
      }
      return res
    },
  },

  htmls: {},
}
