diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx index f73ab265..8f7fb3d9 100644 --- a/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx +++ b/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx @@ -40,6 +40,9 @@ const TransferToLayingDetailModal = () => { ? transferToLayingResponse.data : undefined; + const isTransferToLayingApproved = + transferToLaying?.approval.step_number === 2; + const { data: transferToLayingApprovalResponse } = useSWR( transferToLayingId ? ['approval-transfer-to-laying', transferToLayingId] @@ -55,9 +58,9 @@ const TransferToLayingDetailModal = () => { const detailModal = useModal(); - const totalEnteredChickenForTransfer = + const maxSourceQuantity = transferToLaying?.sources.reduce( - (acc, item) => acc + Number(item.qty), + (acc, item) => acc + Number(item.product_warehouse.quantity), 0 ) ?? 0; @@ -67,8 +70,9 @@ const TransferToLayingDetailModal = () => { 0 ) ?? 0; + // Sisa transfer = Max available dari kandang asal - Total yang sudah diisi di kandang tujuan const totalAvailableChickenForTransfer = - totalEnteredChickenForTransfer - totalTransferedChicken; + maxSourceQuantity - totalTransferedChicken; const closeModalHandler = (shouldPushToRoute: boolean = true) => { if (shouldPushToRoute) { @@ -161,11 +165,34 @@ const TransferToLayingDetailModal = () => { {/* Source Kandang */}