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'))

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

  headers: [
    [
      { label: 'Kode' },
      { label: 'Name' },
      { label: 'Golongan' },
      { label: 'Metode Pemberian' },
      { label: 'Satuan' },
      { label: 'Stok' },
      { label: 'Aksi' },
    ],
  ],

  keys: ['code', 'name', 'group', 'method', 'unit', 'stock', 'action'],

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

  parses: {
    group: (rec: unknown): unknown => {
      return (rec as SmallDetailDto).medicineGroup?.name || '-'
    },
    method: (rec: unknown): unknown => {
      return (rec as SmallDetailDto).medicineMethod?.name || '-'
    },
    unit: (rec: unknown): unknown => {
      return (rec as SmallDetailDto).uom?.name || '-'
    },
  },

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

  htmls: {},
}
