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: 'Nama' },
      { label: 'Bentuk' },
      { label: 'Freq' },
      { label: 'Dosis' },
      { label: 'Interval' },
      { label: 'Total' },
      { label: '' },
    ],
  ],

  keys: ['name', 'uom_code', 'frequency', 'multiplier', 'interval', 'total', 'action'],

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

  parses: {
    cateogry: (rec: unknown): unknown => {
      return (rec as SmallDetailDto).medicineCategory?.name || '-'
    },
    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).medicineUnit?.name || '-'
    },
  },

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

  htmls: {},
}
