refactor(FE-311): Use latest_approval instead of approval

This commit is contained in:
rstubryan
2025-12-08 18:14:38 +07:00
parent ce75eb25d7
commit a7d884b5f0
2 changed files with 8 additions and 9 deletions
@@ -61,7 +61,7 @@ const PurchaseOrderStaffApprovalForm = ({
return 'add';
}
const currentStep = initialValues?.approval?.step_number || 1;
const currentStep = initialValues?.latest_approval?.step_number || 1;
switch (currentStep) {
case 1:
@@ -77,7 +77,7 @@ const PurchaseOrderStaffApprovalForm = ({
// Step 4+ (Penerimaan Barang dan selesai), tidak boleh edit kalau sudah disetujui
return 'edit';
}
}, [rawDataApprovals, propType, initialValues?.approval?.step_number]);
}, [rawDataApprovals, propType, initialValues?.latest_approval?.step_number]);
const router = useRouter();
const searchParams = useSearchParams();
@@ -93,16 +93,16 @@ const PurchaseOrderStaffApprovalForm = ({
// ===== UTILITY FUNCTIONS =====
const canUpdatePurchaseItems = useMemo(() => {
if (!initialValues?.approval) return false;
if (!initialValues?.latest_approval) return false;
const currentStep = initialValues.approval.step_number;
const currentStep = initialValues.latest_approval.step_number;
return currentStep >= 3;
}, [initialValues?.approval]);
}, [initialValues?.latest_approval]);
const canShowDeleteAddButtons = useMemo(() => {
if (!initialValues?.approval) return false;
if (!initialValues?.latest_approval) return false;
const currentStep = initialValues.approval.step_number;
const currentStep = initialValues.latest_approval.step_number;
// Step 2 (Staff Purchase) dengan mode 'add' tidak boleh add/delete items
// User hanya boleh input harga dan total harga untuk items yang sudah ada
@@ -112,7 +112,7 @@ const PurchaseOrderStaffApprovalForm = ({
// Step 3 (Manager Purchase) boleh add/delete items
return currentStep === 3;
}, [initialValues?.approval, type]);
}, [initialValues?.latest_approval, type]);
const isRepeaterInputError = (
idx: number,
-1
View File
@@ -61,7 +61,6 @@ export type BasePurchase = {
location?: Location;
warehouse?: Warehouse;
items?: PurchaseItem[];
approval?: BaseApproval;
latest_approval?: BaseApproval;
};