feat(doctor): add status badge component for doctor list

Replace hardcoded status text with a reusable status badge component to improve consistency and maintainability. Remove console.log statement and adjust column widths in the list configuration.
This commit is contained in:
Khafid Prayoga
2025-08-19 16:40:53 +07:00
parent 3e6e773313
commit 1b84ce3c62
2 changed files with 41 additions and 13 deletions
+12 -13
View File
@@ -4,11 +4,7 @@ import { defineAsyncComponent } from 'vue'
type SmallDetailDto = any
const action = defineAsyncComponent(() => import('~/components/pub/nav/dropdown-action-dud.vue'))
const doctorStatus = {
0: 'Tidak Aktif',
1: 'Aktif',
}
const statusBadge = defineAsyncComponent(() => import('./status-badge.vue'))
export const cols: Col[] = [
{ width: 100 },
@@ -19,10 +15,10 @@ export const cols: Col[] = [
{},
{},
{},
{ width: 120 },
{ width: 100 },
{ width: 100 },
{ width: 100 },
{ width: 50 },
{},
{},
]
export const header: Th[][] = [
@@ -59,7 +55,6 @@ export const delKeyNames: KeyLabel[] = [
export const funcParsed: RecStrFuncUnknown = {
name: (rec: unknown): unknown => {
console.log(rec)
const recX = rec as SmallDetailDto
return `${recX.frontTitle} ${recX.name} ${recX.endTitle}`.trim()
},
@@ -78,10 +73,6 @@ export const funcParsed: RecStrFuncUnknown = {
const recX = rec as SmallDetailDto
return Number(recX.outPatient_itemPrice.price).toLocaleString('id-ID')
},
status: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
return doctorStatus[recX.status_code as keyof typeof doctorStatus]
},
}
export const funcComponent: RecStrFuncComponent = {
@@ -93,6 +84,14 @@ export const funcComponent: RecStrFuncComponent = {
}
return res
},
status(rec, idx) {
const res: RecComponent = {
idx,
rec: rec as object,
component: statusBadge,
}
return res
},
}
export const funcHtml: RecStrFuncUnknown = {
@@ -0,0 +1,29 @@
<script setup lang="ts">
import { Badge } from '~/components/pub/ui/badge'
const props = defineProps<{
rec: any
idx?: number
}>()
const doctorStatus = {
0: 'Tidak Aktif',
1: 'Aktif',
}
const statusText = computed(() => {
return doctorStatus[props.rec.status_code as keyof typeof doctorStatus]
})
const badgeVariant = computed(() => {
return props.rec.status_code === 1 ? 'default' : 'destructive'
})
</script>
<template>
<div class="flex justify-center">
<Badge :variant="badgeVariant">
{{ statusText }}
</Badge>
</div>
</template>