This commit is contained in:
ardiola
2025-04-11 22:28:26 +07:00
82 changed files with 3682 additions and 1501 deletions

View File

@ -137,19 +137,6 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
},
},
{
accessorFn: (row) => {
let status;
if (row.status === 'C') {
status = 'COMPLETE';
} else if (row.status === 'F') {
status = 'FAILED';
} else if (row.status === 'O') {
status = 'ON PROCESS';
} else {
status = 'PENDING';
}
return status;
},
accessorKey: 'status',
header: ({ column }) => <DataGridColumnHeader title="Status" column={column} />,
enableSorting: false,
@ -157,7 +144,37 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
meta: {
headerClassName: 'w-[250px]',
},
},
cell: ({ row }) => {
const statusCode = row.original.status;
let label = '';
let badgeClass = '';
switch (statusCode) {
case 'C':
label = 'COMPLETE';
badgeClass = 'bg-green-100 text-green-800';
break;
case 'F':
label = 'FAILED';
badgeClass = 'bg-red-100 text-red-800';
break;
case 'O':
label = 'ON PROCESS';
badgeClass = 'bg-blue-100 text-blue-800';
break;
default:
label = 'PENDING';
badgeClass = 'bg-gray-100 text-gray-800';
break;
}
return (
<span className={`px-3 py-1 rounded-full text-xs font-semibold ${badgeClass}`}>
{label}
</span>
);
},
},
{
accessorKey: 'description',
header: ({ column }) => <DataGridColumnHeader title="Description" column={column} />,
@ -169,7 +186,7 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
},
{
accessorKey: 'type.name',
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
header: ({ column }) => <DataGridColumnHeader title="Transaction Type" column={column} />,
enableSorting: false,
enableHiding: false,
meta: {
@ -227,11 +244,12 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
if (filter == undefined || filter.length == 0) {
const today = new Date();
const nextWeek = new Date();
nextWeek.setDate(today.getDate() + 7);
startdate = today.toISOString().split('T')[0];
enddate = nextWeek.toISOString().split('T')[0];
// Tanggal 1 di bulan sekarang
const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
startdate = firstDayOfMonth.toISOString().split('T')[0];
enddate = today.toISOString().split('T')[0];
} else if (filter != undefined || filter.length != 0) {
startdate = filter[0].value.from;
enddate = filter[0].value.to;