dstpabuaran.com/resources/js/pages/admin/finance/cash-account/columns.tsx
Yoga Pangestu 166419134f Refactor component imports for consistency and organization
- Updated import paths for various components to align with new directory structure.
- Changed imports from 'row-actions', 'confirm-dialog', 'image-preview-button', and 'file-upload' to their respective new locations in 'data-display', 'dialogs', and 'inputs'.
- Adjusted imports in multiple pages including purchase, restock, transaction, category, customer, product, raw-material, supplier, roles, and settings.
- Ensured all relevant components are imported from their new locations to maintain functionality.
2026-08-07 13:48:46 +07:00

81 lines
2.5 KiB
TypeScript

import type { ColumnDef } from '@tanstack/react-table';
import { Pencil, Trash2 } from 'lucide-react';
import { RowActions } from '@/components/data-display';
export type CashAccount = {
id: number;
name: string;
balance: number;
formatted_balance: string;
};
type CreateColumnsParams = {
handleEdit: (cashAccount: CashAccount) => void;
handleDeleteClick: (cashAccount: CashAccount) => void;
can: (permission: string) => boolean;
};
export function createCashAccountColumns(
params: CreateColumnsParams,
): ColumnDef<CashAccount>[] {
const { handleEdit, handleDeleteClick, can } = params;
const columns: ColumnDef<CashAccount>[] = [
{
accessorKey: 'name',
header: () => <span>Nama</span>,
cell: ({ row }) => (
<span className="font-medium">
{row.getValue('name') as string}
</span>
),
},
{
accessorKey: 'formatted_balance',
header: () => <span>Saldo</span>,
cell: ({ row }) => (
<span className="font-medium">
{row.getValue('formatted_balance') as string}
</span>
),
},
];
if (can('cash.update') || can('cash.delete')) {
columns.push({
id: 'actions',
header: () => <span className="block text-center">Aksi</span>,
meta: {
className: 'w-[100px] text-center',
headerClassName: 'w-[100px] text-center',
},
cell: ({ row }) => {
const cashAccount = row.original;
return (
<RowActions
actions={[
{
label: 'Edit',
icon: <Pencil className="h-4 w-4" />,
show: can('cash.update'),
onClick: () => handleEdit(cashAccount),
},
{
label: 'Hapus',
icon: (
<Trash2 className="h-4 w-4 text-destructive" />
),
show: can('cash.delete'),
onClick: () => handleDeleteClick(cashAccount),
},
]}
/>
);
},
});
}
return columns;
}