- Added roles property to Employee type and a new column for displaying employee roles in the employee table. - Updated leave request columns to use formatted start and end dates instead of raw date strings. - Enhanced leave request index to accept filter options for status dynamically. - Refactored transaction index to support dynamic filter options for status, channel, and payment type. - Introduced AGENTS.md for session notes detailing model relationships, casting, scopes, reorganizations, and conventions.
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import type { ColumnDef } from '@tanstack/react-table';
|
|
import { Pencil, Trash2 } from 'lucide-react';
|
|
import { RowActions } from '@/components/row-actions';
|
|
|
|
export type CashAccount = {
|
|
id: number;
|
|
name: string;
|
|
balance: number;
|
|
formatted_balance: string;
|
|
};
|
|
|
|
type CreateColumnsParams = {
|
|
handleEdit: (cashAccount: CashAccount) => void;
|
|
handleDeleteClick: (cashAccount: CashAccount) => void;
|
|
};
|
|
|
|
export function createCashAccountColumns(
|
|
params: CreateColumnsParams,
|
|
): ColumnDef<CashAccount>[] {
|
|
const { handleEdit, handleDeleteClick } = params;
|
|
|
|
return [
|
|
{
|
|
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>
|
|
),
|
|
},
|
|
{
|
|
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" />,
|
|
onClick: () => handleEdit(cashAccount),
|
|
},
|
|
{
|
|
label: 'Hapus',
|
|
icon: (
|
|
<Trash2 className="h-4 w-4 text-destructive" />
|
|
),
|
|
onClick: () => handleDeleteClick(cashAccount),
|
|
},
|
|
]}
|
|
/>
|
|
);
|
|
},
|
|
},
|
|
];
|
|
}
|