refactor(FE): Update transaction subtype handling and labels

This commit is contained in:
rstubryan
2026-02-26 15:11:39 +07:00
parent 2476b6a4b4
commit c926a81756
3 changed files with 22 additions and 13 deletions
@@ -96,15 +96,27 @@ const InventoryAdjustmentTable = () => {
{ {
id: 'transaction_type', id: 'transaction_type',
header: 'Tipe Transaksi', header: 'Tipe Transaksi',
accessorFn: (row) => row.transaction_type ?? '-', accessorFn: (row) => row.transaction_subtype ?? '-',
cell: (row) => { cell: (row) => {
const type = row.row.original.increase; const subtype = row.row.original.transaction_subtype;
const label = const increase = row.row.original.increase;
type > 0 ? 'Peningkatan' : type <= 0 ? 'Penurunan' : '-';
const subtypeLabelMap: Record<string, string> = {
PURCHASE_IN: 'Pembelian',
MARKETING_OUT: 'Penjualan',
RECORDING_STOCK_OUT: 'Recording Stock',
RECORDING_DEPLETION_OUT: 'Recording Depletion',
RECORDING_EGG_IN: 'Recording Egg',
ADJUSTMENT_OUT: 'Penyesuaian',
};
const label = subtypeLabelMap[subtype] || subtype || '-';
return ( return (
<StatusBadge <StatusBadge
color={type > 0 ? 'success' : type <= 0 ? 'error' : 'neutral'} color={
increase > 0 ? 'success' : increase <= 0 ? 'error' : 'neutral'
}
text={label} text={label}
className={{ className={{
badge: 'whitespace-nowrap', badge: 'whitespace-nowrap',
@@ -269,7 +269,7 @@ const InventoryAdjustmentForm = ({
const transactionType = selectedTransactionType?.value; const transactionType = selectedTransactionType?.value;
if (transactionType === 'RECORDING') { if (transactionType === 'RECORDING') {
return TRANSACTION_SUBTYPE_OPTIONS.RECORDING; return [...TRANSACTION_SUBTYPE_OPTIONS.RECORDING];
} }
return []; return [];
@@ -289,8 +289,6 @@ const InventoryAdjustmentForm = ({
) { ) {
setQuantityLabel('Kurangi Stok'); setQuantityLabel('Kurangi Stok');
} else if ( } else if (
subtype === 'RECORDING_STOCK_IN' ||
subtype === 'RECORDING_DEPLETION_IN' ||
subtype === 'RECORDING_EGG_IN' || subtype === 'RECORDING_EGG_IN' ||
subtype === 'PURCHASE_IN' subtype === 'PURCHASE_IN'
) { ) {
+4 -5
View File
@@ -556,9 +556,8 @@ export const TRANSACTION_SUBTYPE_OPTIONS = {
PEMBELIAN: { label: 'Pembelian', value: 'PURCHASE_IN' }, PEMBELIAN: { label: 'Pembelian', value: 'PURCHASE_IN' },
PENJUALAN: { label: 'Penjualan', value: 'MARKETING_OUT' }, PENJUALAN: { label: 'Penjualan', value: 'MARKETING_OUT' },
RECORDING: [ RECORDING: [
{ label: 'Recording Stock Out', value: 'RECORDING_STOCK_OUT' }, { label: 'Recording Stock', value: 'RECORDING_STOCK_OUT' },
{ label: 'Recording Depletion Out', value: 'RECORDING_DEPLETION_OUT' }, { label: 'Recording Depletion', value: 'RECORDING_DEPLETION_OUT' },
{ label: 'Recording Depletion In', value: 'RECORDING_DEPLETION_IN' }, { label: 'Recording Egg', value: 'RECORDING_EGG_IN' },
{ label: 'Recording Egg In', value: 'RECORDING_EGG_IN' },
], ],
}; } as const;