mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
fix: get real max quantity in target project flock kandang
This commit is contained in:
+11
-13
@@ -176,6 +176,11 @@ export const getFilledTransferToLayingFormInitialValues = async (
|
||||
initialValues?.from_project_flock.id as number
|
||||
);
|
||||
|
||||
const mappedFlockDestinationKandangsMaxTargetQty =
|
||||
await TransferToLayingApi.getMappedFlockKandangsMaxTargetQty(
|
||||
initialValues?.to_project_flock.id as number
|
||||
);
|
||||
|
||||
const formattedFlockSourceKandangs = initialValues?.sources
|
||||
? initialValues.sources.map((sourceKandang) => ({
|
||||
kandang: {
|
||||
@@ -197,20 +202,8 @@ export const getFilledTransferToLayingFormInitialValues = async (
|
||||
maxTotalQuantity += item.quantity;
|
||||
});
|
||||
|
||||
const flockDestination = await ProjectFlockApi.getSingle(
|
||||
initialValues?.to_project_flock.id as number
|
||||
);
|
||||
|
||||
const formattedFlockDestinationKandangs = initialValues?.targets
|
||||
? initialValues.targets.map((targetKandang) => {
|
||||
const kandang = isResponseSuccess(flockDestination)
|
||||
? flockDestination?.data?.kandangs.find(
|
||||
(kandang) =>
|
||||
String(kandang.project_flock_kandang_id) ===
|
||||
String(targetKandang.target_project_flock_kandang.id)
|
||||
)
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
kandang: {
|
||||
value: targetKandang.target_project_flock_kandang.id,
|
||||
@@ -218,7 +211,12 @@ export const getFilledTransferToLayingFormInitialValues = async (
|
||||
},
|
||||
quantity: targetKandang.qty,
|
||||
|
||||
maxQuantity: kandang?.capacity ?? 0,
|
||||
maxQuantity:
|
||||
(mappedFlockDestinationKandangsMaxTargetQty &&
|
||||
mappedFlockDestinationKandangsMaxTargetQty[
|
||||
targetKandang.target_project_flock_kandang.id
|
||||
].max_target_qty) ??
|
||||
0,
|
||||
};
|
||||
})
|
||||
: [];
|
||||
|
||||
Reference in New Issue
Block a user