From 6f470d46196c6eaaa9125f6de02215f22c77e537 Mon Sep 17 00:00:00 2001 From: Jabar Jeremy <24471994+jabahum@users.noreply.github.com> Date: Mon, 8 Jan 2024 12:39:31 +0300 Subject: [PATCH] U4X-297 : Complete and Submit for review buttons don't work (#53) * U4X-297 : Complete and Submit for review buttons don't work * fix : fix onComplete * fix : onSubmit for review --- src/stock-items/types.ts | 3 + .../add-stock-operation.component.tsx | 86 ++++--------------- .../stock-operation-submission.component.tsx | 18 ++-- .../stock-operation.utils.tsx | 14 +++ ...ck-operations-approve-button.component.tsx | 1 + ...ions-approve-dispatch-button.component.tsx | 1 + ...ock-operations-cancel-button.component.tsx | 1 + ...k-operations-complete-button.component.tsx | 1 + ...ns-completed-dispatch-button.component.tsx | 1 + .../stock-operations-dialog.component.tsx | 20 ++++- ...perations-issue-stock-button.component.tsx | 1 + ...ock-operations-reject-button.component.tsx | 1 + ...ock-operations-return-button.component.tsx | 1 + 13 files changed, 74 insertions(+), 75 deletions(-) diff --git a/src/stock-items/types.ts b/src/stock-items/types.ts index ac3ba980..c05501dc 100644 --- a/src/stock-items/types.ts +++ b/src/stock-items/types.ts @@ -3,3 +3,6 @@ import { StockOperationDTO } from "../core/api/types/stockOperation/StockOperati export type SaveStockItem = (item: StockItemDTO) => Promise; export type SaveStockOperation = (item: StockOperationDTO) => Promise; +export type SaveStockOperationAction = ( + item: StockOperationDTO +) => Promise; diff --git a/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx b/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx index 5fee0891..6e93ccfb 100644 --- a/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +++ b/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx @@ -9,7 +9,10 @@ import { AddStockOperationProps } from "./types"; import { useInitializeStockOperations } from "./add-stock-operation.resource"; import { AccordionSkeleton } from "@carbon/react"; import { closeOverlay } from "../../core/components/overlay/hook"; -import { addOrEditStockOperation } from "../stock-operation.utils"; +import { + addOrEditStockOperation, + showActionDialogButton, +} from "../stock-operation.utils"; import StockOperationApprovalButton from "../stock-operations-dialog/stock-operations-approve-button.component"; import StockOperationRejectButton from "../stock-operations-dialog/stock-operations-reject-button.component"; import StockOperationReturnButton from "../stock-operations-dialog/stock-operations-return-button.component"; @@ -18,18 +21,6 @@ import StockOperationPrintButton from "../stock-operations-dialog/stock-operatio import StockOperationApproveDispatchButton from "../stock-operations-dialog/stock-operations-approve-dispatch-button.component"; import StockOperationCompleteDispatchButton from "../stock-operations-dialog/stock-operations-completed-dispatch-button.component"; import StockOperationIssueStockButton from "../stock-operations-dialog/stock-operations-issue-stock-button.component"; -import { - OperationType, - StockOperationType, - StockOperationTypeCanCapturePurchasePrice, - StockOperationTypeIsNegativeQtyAllowed, - StockOperationTypeIsQuantityOptional, - StockOperationTypeRequiresActualBatchInformation, - StockOperationTypeRequiresBatchUuid, - StockOperationTypeRequiresDispatchAcknowledgement, - StockOperationTypeRequiresStockAdjustmentReason, - operationFromString, -} from "../../core/api/types/stockOperation/StockOperationType"; const AddStockOperation: React.FC = (props) => { const { t } = useTranslation(); @@ -44,21 +35,8 @@ const AddStockOperation: React.FC = (props) => { ); const [selectedIndex, setSelectedIndex] = useState(0); - const [stockOperationType, setStockOperationType] = useState< - StockOperationType | null | undefined - >(null); - const [isNegativeQtyAllowed, setIsNegativeQtyAllowed] = useState(false); - const [requiresBatchUuid, setRequiresBatchUuid] = useState(false); - const [requiresActualBatchInformation, setRequiresActualBatchInformation] = - useState(false); - const [isQuantityOptional, setIsQuantityOptional] = useState(false); - const [canCapturePurchasePrice, setCanCapturePurchasePrice] = useState(false); - const [requireStockAdjustmentReason, setRequireStockAdjustmentReason] = - useState(false); const [requiresDispatchAcknowledgement, setRequiresDispatchAcknowledgement] = useState(false); - const [allowExpiredBatchNumbers, setAllowExpiredBatchNumbers] = - useState(false); if (isLoading) return ; if (isError) { @@ -130,14 +108,18 @@ const AddStockOperation: React.FC = (props) => { onGoBack: () => { setSelectedIndex(1); }, - onComplete: () => { - // TODO: Update + onComplete: async () => { + await showActionDialogButton("Complete", false, props?.model); }, - onSubmit: () => { - // TODO: Update + onSubmit: async () => { + await showActionDialogButton("Submit", false, props?.model); }, - onDispatch: () => { - // TODO: Update + onDispatch: async () => { + await showActionDialogButton( + "Dispatch Approval", + false, + props?.model + ); }, }} /> @@ -146,39 +128,6 @@ const AddStockOperation: React.FC = (props) => { }, ]; - // const currentStockOperationType = props.operations?.find( - // (p) => p.uuid === props.operation?.uuid - // ); - - // console.info("data operations-->", props); - - // console.info("data-->", currentStockOperationType); - // const operationType: OperationType = operationFromString( - // currentStockOperationType?.operationType ?? "" - // ); - - // setStockOperationType(currentStockOperationType); - // setIsNegativeQtyAllowed( - // StockOperationTypeIsNegativeQtyAllowed(operationType) - // ); - // setRequiresBatchUuid(StockOperationTypeRequiresBatchUuid(operationType)); - // setRequiresActualBatchInformation( - // StockOperationTypeRequiresActualBatchInformation(operationType) - // ); - // setIsQuantityOptional(StockOperationTypeIsQuantityOptional(operationType)); - // setCanCapturePurchasePrice( - // StockOperationTypeCanCapturePurchasePrice(operationType) - // ); - // setRequireStockAdjustmentReason( - // StockOperationTypeRequiresStockAdjustmentReason(operationType) - // ); - // setRequiresDispatchAcknowledgement( - // StockOperationTypeRequiresDispatchAcknowledgement(operationType) - // ); - // setAllowExpiredBatchNumbers( - // currentStockOperationType?.allowExpiredBatchNumbers ?? false - // ); - return ( <>
= (props) => {
)} - - {canPrint && ( + {(props.model?.permission?.isRequisitionAndCanIssueStock || + props.model?.operationType === "stockissue" || + props.model?.operationType === "requisition" || + props.model?.operationType === "receipt" || + props.model?.operationType === "transferout") && (
diff --git a/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx b/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx index 75f32e24..290f7462 100644 --- a/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx +++ b/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx @@ -1,7 +1,10 @@ import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO"; -import { SaveStockOperation } from "../../stock-items/types"; +import { + SaveStockOperation, + SaveStockOperationAction, +} from "../../stock-items/types"; import { StockOperationType } from "../../core/api/types/stockOperation/StockOperationType"; import { InitializeResult } from "./types"; import { @@ -31,9 +34,9 @@ interface StockOperationSubmissionProps { actions: { onGoBack: () => void; onSave?: SaveStockOperation; - onComplete: () => void; - onSubmit: () => void; - onDispatch: () => void; + onComplete: SaveStockOperationAction; + onSubmit: SaveStockOperationAction; + onDispatch: SaveStockOperationAction; }; } @@ -98,6 +101,7 @@ const StockOperationSubmission: React.FC = ({ )} @@ -136,6 +142,7 @@ const StockOperationSubmission: React.FC = ({ name="save" type="button" className="submitButton" + style={{ margin: "4px" }} disabled={isSaving} onClick={async () => { setIsSaving(true); @@ -150,6 +157,7 @@ const StockOperationSubmission: React.FC = ({ {!isSaving && (