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',
header: 'Tipe Transaksi',
accessorFn: (row) => row.transaction_type ?? '-',
accessorFn: (row) => row.transaction_subtype ?? '-',
cell: (row) => {
const type = row.row.original.increase;
const label =
type > 0 ? 'Peningkatan' : type <= 0 ? 'Penurunan' : '-';
const subtype = row.row.original.transaction_subtype;
const increase = row.row.original.increase;
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 (
<StatusBadge
color={type > 0 ? 'success' : type <= 0 ? 'error' : 'neutral'}
color={
increase > 0 ? 'success' : increase <= 0 ? 'error' : 'neutral'
}
text={label}
className={{
badge: 'whitespace-nowrap',
@@ -269,7 +269,7 @@ const InventoryAdjustmentForm = ({
const transactionType = selectedTransactionType?.value;
if (transactionType === 'RECORDING') {
return TRANSACTION_SUBTYPE_OPTIONS.RECORDING;
return [...TRANSACTION_SUBTYPE_OPTIONS.RECORDING];
}
return [];
@@ -289,8 +289,6 @@ const InventoryAdjustmentForm = ({
) {
setQuantityLabel('Kurangi Stok');
} else if (
subtype === 'RECORDING_STOCK_IN' ||
subtype === 'RECORDING_DEPLETION_IN' ||
subtype === 'RECORDING_EGG_IN' ||
subtype === 'PURCHASE_IN'
) {
+4 -5
View File
@@ -556,9 +556,8 @@ export const TRANSACTION_SUBTYPE_OPTIONS = {
PEMBELIAN: { label: 'Pembelian', value: 'PURCHASE_IN' },
PENJUALAN: { label: 'Penjualan', value: 'MARKETING_OUT' },
RECORDING: [
{ label: 'Recording Stock Out', value: 'RECORDING_STOCK_OUT' },
{ label: 'Recording Depletion Out', value: 'RECORDING_DEPLETION_OUT' },
{ label: 'Recording Depletion In', value: 'RECORDING_DEPLETION_IN' },
{ label: 'Recording Egg In', value: 'RECORDING_EGG_IN' },
{ label: 'Recording Stock', value: 'RECORDING_STOCK_OUT' },
{ label: 'Recording Depletion', value: 'RECORDING_DEPLETION_OUT' },
{ label: 'Recording Egg', value: 'RECORDING_EGG_IN' },
],
};
} as const;