import type { Config } from '~/components/pub/my-ui/data-table'
import { defineAsyncComponent } from 'vue'

const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-print.vue'))
const statusBadge = defineAsyncComponent(() => import('~/components/pub/my-ui/badge/status-badge.vue'))

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

  headers: [
    [
      { label: 'Tgl Diterbitkan' },
      { label: 'Kode Obat' },
      { label: 'Nama Obat' },
      { label: 'Signa' },
      { label: 'Jumlah' },
      { label: 'Durasi Pemberian' },
      { label: 'status' },
      { label: 'Action' },
    ],
  ],

  keys: ['date', 'name1', 'name2', 'name3', 'name4', 'name5', 'status', 'action'],

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

  parses: {
    date: (rec: unknown): unknown => {
      const date = (rec as any).date
      if (typeof date == 'object' && date) {
        return (date as Date).toLocaleDateString('id-ID')
      } else if (typeof date == 'string') {
        return (date as string).substring(0, 10)
      }
      return date
    },
  },

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

  htmls: {

  },
}
