mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Refactor subtype label mapping and fix depletion subtype
value
This commit is contained in:
@@ -14,6 +14,7 @@ import { useTableFilter } from '@/services/hooks/useTableFilter';
|
||||
import { InventoryAdjustment } from '@/types/api/inventory/adjustment';
|
||||
import StatusBadge from '@/components/helper/StatusBadge';
|
||||
import InventoryAdjustmentTableSkeleton from '@/components/pages/inventory/adjustment/skeleton/InventoryAdjustmentTableSkeleton';
|
||||
import { TRANSACTION_SUBTYPE_OPTIONS } from '@/config/constant';
|
||||
|
||||
const InventoryAdjustmentTable = () => {
|
||||
const {
|
||||
@@ -102,16 +103,23 @@ const InventoryAdjustmentTable = () => {
|
||||
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 getSubtypeLabel = (subtypeValue: string): string => {
|
||||
if (subtypeValue === TRANSACTION_SUBTYPE_OPTIONS.PEMBELIAN.value) {
|
||||
return TRANSACTION_SUBTYPE_OPTIONS.PEMBELIAN.label;
|
||||
}
|
||||
if (subtypeValue === TRANSACTION_SUBTYPE_OPTIONS.PENJUALAN.value) {
|
||||
return TRANSACTION_SUBTYPE_OPTIONS.PENJUALAN.label;
|
||||
}
|
||||
const recordingOption = TRANSACTION_SUBTYPE_OPTIONS.RECORDING.find(
|
||||
(opt) => opt.value === subtypeValue
|
||||
);
|
||||
if (recordingOption) {
|
||||
return recordingOption.label;
|
||||
}
|
||||
return subtypeValue || '-';
|
||||
};
|
||||
|
||||
const label = subtypeLabelMap[subtype] || subtype || '-';
|
||||
const label = getSubtypeLabel(subtype);
|
||||
|
||||
return (
|
||||
<StatusBadge
|
||||
|
||||
@@ -295,9 +295,9 @@ const InventoryAdjustmentForm = ({
|
||||
(opt) => opt.value === 'RECORDING_EGG_IN'
|
||||
);
|
||||
} else if (isChickenProduct) {
|
||||
// Produk ayam: hanya RECORDING_DEPLETION_OUT
|
||||
// Produk ayam: hanya RECORDING_DEPLETION_IN
|
||||
return allRecordingOptions.filter(
|
||||
(opt) => opt.value === 'RECORDING_DEPLETION_OUT'
|
||||
(opt) => opt.value === 'RECORDING_DEPLETION_IN'
|
||||
);
|
||||
} else {
|
||||
// Produk non-telur dan non-ayam (PAKAN, OVK, dll): hanya RECORDING_STOCK_OUT
|
||||
|
||||
@@ -624,7 +624,7 @@ export const TRANSACTION_SUBTYPE_OPTIONS = {
|
||||
PENJUALAN: { label: 'Penjualan', value: 'MARKETING_OUT' },
|
||||
RECORDING: [
|
||||
{ label: 'Recording Stock', value: 'RECORDING_STOCK_OUT' },
|
||||
{ label: 'Recording Depletion', value: 'RECORDING_DEPLETION_OUT' },
|
||||
{ label: 'Recording Depletion', value: 'RECORDING_DEPLETION_IN' },
|
||||
{ label: 'Recording Egg', value: 'RECORDING_EGG_IN' },
|
||||
],
|
||||
} as const;
|
||||
|
||||
Reference in New Issue
Block a user