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: 100 },
    { width: 250 },
    { width: 100 },
    { width: 100 },
    { width: 50 },
  ],

  headers: [
    [
      { label: 'Kode' },
      { label: 'Nama' },
      { label: 'Stok' },
      { label: 'Satuan' },
      { label: '' },
    ],
  ],

  keys: ['code', 'name', 'stock', 'uom_code', 'action'],

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

  parses: {
    name: (rec: unknown): unknown => {
      const recX = rec as SmallDetailDto
      return `${recX.name}`.trim()
    },
    uom_code: (rec: unknown): unknown => {
      const recX = rec as SmallDetailDto
      return recX.uom_code
    },
  },

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

  htmls: {},
}
