import type {
  Col,
  KeyLabel,
  RecComponent,
  RecStrFuncComponent,
  RecStrFuncUnknown,
  Th,
} from '~/components/pub/custom-ui/data/types'
import { defineAsyncComponent } from 'vue'

type SmallDetailDto = any

const action = defineAsyncComponent(() => import('~/components/pub/custom-ui/data/dropdown-action-dud.vue'))

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

export const header: Th[][] = [
  [
    { label: 'Kode' },
    { label: 'Name' },
    { label: 'Kategori' },
    { label: 'Golongan' },
    { label: 'Metode Pemberian' },
    { label: 'Bentuk' },
    { label: 'Stok' },
    { label: 'Aksi' },
  ],
]

export const keys = ['code', 'name', 'category', 'group', 'method', 'unit', 'total', 'action']

export const delKeyNames: KeyLabel[] = [
  { key: 'code', label: 'Kode' },
  { key: 'name', label: 'Nama' },
]

export const funcParsed: RecStrFuncUnknown = {
  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 || '-'
  },
}

export const funcComponent: RecStrFuncComponent = {
  action: (rec: unknown, idx: number): RecComponent => {
    const res: RecComponent = {
      idx,
      rec: rec as object,
      component: action,
    }
    return res
  },
}

export const funcHtml: RecStrFuncUnknown = {
  // (_rec) {
  //   return '-'
  // },
}
