From cb95b335d236bf7e4dee863174156bae6a49c545 Mon Sep 17 00:00:00 2001 From: "sumathi.thirumani" Date: Thu, 30 Nov 2023 19:37:22 -0800 Subject: [PATCH] changes to avoid default reset of data. --- .../FOI/FOIRequest/OIPCDetails/oipcHook.js | 12 ++++++++++-- .../components/FOI/customComponents/requestflag.scss | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/oipcHook.js b/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/oipcHook.js index 851651746..eb24abdd6 100644 --- a/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/oipcHook.js +++ b/forms-flow-web/src/components/FOI/FOIRequest/OIPCDetails/oipcHook.js @@ -32,10 +32,12 @@ const useOIPCHook = () => { } const [oipcData, setOipcData] = useState(requestDetails.oipcdetails); const [isOIPCReview, setIsOIPCReview] = useState(requestDetails.isoipcreview); - + const [resettoInitial, setResettoInitial] = useState(false); useEffect(() => { + if (resettoInitial == false) { const stagedOIPCData = stageOIPCData(isOIPCReview, requestDetails.oipcdetails); setOipcData(stagedOIPCData); + } }, [isOIPCReview]) //OIPC Functions @@ -59,11 +61,17 @@ const useOIPCHook = () => { }) } const removeOIPC = (oipcId) => { + if (oipcData.length == 1) { + setOipcData([]); + setResettoInitial(true) + } + else { setOipcData((prev) => { const previousOIPCData = [...prev]; - return previousOIPCData.filter(oipc => oipcId !== oipc.id); + return previousOIPCData.filter(oipc => oipcId !== oipc.id); }); } + } const updateOIPC = (newOIPCObj) => { setOipcData((prev) => { const previousOIPCData = [...prev]; diff --git a/forms-flow-web/src/components/FOI/customComponents/requestflag.scss b/forms-flow-web/src/components/FOI/customComponents/requestflag.scss index f9ac8c120..7df546c97 100644 --- a/forms-flow-web/src/components/FOI/customComponents/requestflag.scss +++ b/forms-flow-web/src/components/FOI/customComponents/requestflag.scss @@ -1,6 +1,5 @@ .request-flag { - margin-left: -50px; padding-top: 50px; .request-flag-dropdown-all {