47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import type { ColumnDef } from '@tanstack/vue-table';
|
|
import { h } from 'vue';
|
|
import DataTableActions from '@/components/admin/finance/expenses/data-table-actions.vue';
|
|
import MediaThumbnailCell from '@/components/media/MediaThumbnailCell.vue';
|
|
import { DataTableColumnHeader } from '@/components/data-table';
|
|
import type { ExpenseListItem } from '@/types/expense';
|
|
|
|
export function createColumns(onEdit: (expense: ExpenseListItem) => void): ColumnDef<ExpenseListItem>[] {
|
|
return [
|
|
{
|
|
accessorKey: 'created_at_formatted',
|
|
enableSorting: true,
|
|
header: () => h(DataTableColumnHeader, { title: 'Tanggal', column: 'created_at' }),
|
|
},
|
|
{
|
|
accessorKey: 'amount_formatted',
|
|
enableSorting: true,
|
|
header: () => h(DataTableColumnHeader, { title: 'Jumlah', column: 'amount' }),
|
|
},
|
|
{
|
|
accessorKey: 'description',
|
|
enableSorting: true,
|
|
header: () => h(DataTableColumnHeader, { title: 'Keterangan', column: 'description' }),
|
|
},
|
|
{
|
|
id: 'photos',
|
|
enableSorting: false,
|
|
header: () => 'Foto',
|
|
cell: ({ row }) => h(MediaThumbnailCell, { items: row.original.photos ?? [] }),
|
|
},
|
|
{
|
|
accessorKey: 'created_by_name',
|
|
enableSorting: false,
|
|
header: () => 'Oleh',
|
|
},
|
|
{
|
|
id: 'actions',
|
|
enableSorting: false,
|
|
enableHiding: false,
|
|
cell: ({ row }) => h(DataTableActions, {
|
|
expense: row.original,
|
|
onEdit: () => onEdit(row.original),
|
|
}),
|
|
},
|
|
];
|
|
}
|