diff --git a/app/pages/admin/business-types/columns.ts b/app/pages/admin/business-types/columns.ts index 718bc3c..2861a80 100644 --- a/app/pages/admin/business-types/columns.ts +++ b/app/pages/admin/business-types/columns.ts @@ -13,7 +13,6 @@ import { export interface BusinessType { id: string - code: string name: string description: string | null is_active: boolean | number @@ -23,11 +22,10 @@ export function copy(id: string) { navigator.clipboard.writeText(id) } -const nameAndCodeFilter: FilterFn = (row, _columnId, filterValue) => { +const nameFilter: FilterFn = (row, _columnId, filterValue) => { const search = (filterValue as string).toLowerCase() const name = (row.original.name as string).toLowerCase() - const code = (row.original.code as string).toLowerCase() - return name.includes(search) || code.includes(search) + return name.includes(search) } const booleanFilter: FilterFn = (row, columnId, filterValue) => { @@ -44,27 +42,17 @@ export function getColumns(callbacks: { onToggleStatus: (businessType: BusinessType, value: boolean) => void }): ColumnDef[] { return [ - { - accessorKey: 'code', - header: ({ column }) => { - return h(Button, { - variant: 'ghost', - onClick: () => column.toggleSorting(column.getIsSorted() === 'asc'), - }, () => ['Kode', h(ArrowUpDown, { class: 'ml-2 h-4 w-4' })]) - }, - cell: ({ row }) => h('div', { class: 'font-medium' }, row.getValue('code')), - }, { id: 'name_search', - accessorFn: row => `${row.name} ${row.code}`, + accessorFn: row => row.name, header: ({ column }) => { return h(Button, { variant: 'ghost', onClick: () => column.toggleSorting(column.getIsSorted() === 'asc'), }, () => ['Nama', h(ArrowUpDown, { class: 'ml-2 h-4 w-4' })]) }, - cell: ({ row }) => h('div', {}, row.original.name), - filterFn: nameAndCodeFilter, + cell: ({ row }) => h('div', { class: 'font-medium' }, row.original.name), + filterFn: nameFilter, enableHiding: false, }, { diff --git a/app/pages/admin/business-types/index.vue b/app/pages/admin/business-types/index.vue index 42ed875..d6ff727 100644 --- a/app/pages/admin/business-types/index.vue +++ b/app/pages/admin/business-types/index.vue @@ -57,12 +57,11 @@ const formMode = ref('create') const selectedBusinessType = ref(null) interface FormData { - code: string name: string description: string } -const form = ref({ code: '', name: '', description: '' }) +const form = ref({ name: '', description: '' }) // --- Loading states --- const formLoading = ref(false) @@ -75,7 +74,7 @@ const formTitle = computed(() => formMode.value === 'create' ? 'Tambah Jenis Bis function openCreateForm() { formMode.value = 'create' selectedBusinessType.value = null - form.value = { code: '', name: '', description: '' } + form.value = { name: '', description: '' } formOpen.value = true } @@ -83,7 +82,6 @@ function handleEdit(bt: BusinessType) { formMode.value = 'edit' selectedBusinessType.value = bt form.value = { - code: bt.code, name: bt.name, description: bt.description ?? '', } @@ -116,8 +114,8 @@ const columns = computed(() => getColumns({ onEdit: handleEdit, onDelete: handle // --- CRUD operations --- async function handleFormSubmit() { - if (!form.value.code.trim() || !form.value.name.trim()) { - toast.error('Kode dan nama wajib diisi') + if (!form.value.name.trim()) { + toast.error('Nama wajib diisi') return } @@ -127,7 +125,6 @@ async function handleFormSubmit() { await $fetch(`${config.public.apiBase}/business-types`, { method: 'POST', body: { - code: form.value.code.trim(), name: form.value.name.trim(), description: form.value.description.trim() || null, }, @@ -137,7 +134,6 @@ async function handleFormSubmit() { await $fetch(`${config.public.apiBase}/business-types/${selectedBusinessType.value!.id}`, { method: 'PUT', body: { - code: form.value.code.trim(), name: form.value.name.trim(), description: form.value.description.trim() || null, }, @@ -195,7 +191,7 @@ function resetFilters(table: any) { // --- Reset on dialog close --- watch(formOpen, (val) => { if (!val) { - form.value = { code: '', name: '', description: '' } + form.value = { name: '', description: '' } selectedBusinessType.value = null } }) @@ -232,7 +228,7 @@ watch(deleteOpen, (val) => {