From 94790fbd78b112939b331b79189af9c21e49c737 Mon Sep 17 00:00:00 2001 From: "Aditya @ArchLinux" <132184385+adityadeshlahre@users.noreply.github.com> Date: Tue, 6 Aug 2024 02:11:53 +0530 Subject: [PATCH] fix(batchTestReAssignemnt/Cancelation): page console.error fixed --- .../BatchTestReassignmentAndCancelation.js | 104 +++++++++++------- .../BatchTestReassignmentRestController.java | 2 +- 2 files changed, 68 insertions(+), 38 deletions(-) diff --git a/frontend/src/components/admin/BatchTestReassignmentAndCancellation/BatchTestReassignmentAndCancelation.js b/frontend/src/components/admin/BatchTestReassignmentAndCancellation/BatchTestReassignmentAndCancelation.js index 3e6ccd37a..78ec58294 100644 --- a/frontend/src/components/admin/BatchTestReassignmentAndCancellation/BatchTestReassignmentAndCancelation.js +++ b/frontend/src/components/admin/BatchTestReassignmentAndCancellation/BatchTestReassignmentAndCancelation.js @@ -71,8 +71,6 @@ function BatchTestReassignmentAndCancelation() { [], ); const [jsonWad, setJsonWad] = useState({ - // current: "HIV+rapid+test+HIV", - // sampleType: "Plasma", current: "", sampleType: "", changeNotStarted: [], @@ -83,6 +81,7 @@ function BatchTestReassignmentAndCancelation() { noChangeTechReject: [], noChangeBioReject: [], noChangeNotValidated: [], + replace: "", }); const [changesToShow, setChangesToShow] = useState(false); @@ -289,8 +288,8 @@ function BatchTestReassignmentAndCancelation() { } else { updatedArray.splice(index, 1); } - const isChecked = updatedArray.includes(id); - const noChangeArray = + let isChecked = updatedArray.includes(id); + let noChangeArray = prevJsonWad[`noChange${capitalizeFirstLetter(sectionKey)}`]; const noChangeIndex = noChangeArray.indexOf(id); @@ -333,8 +332,9 @@ function BatchTestReassignmentAndCancelation() { (item) => item.id === selectedTestId, ); + let updatedList; if (existingIndex !== -1) { - const updatedList = [...sampleTestTypeToGetTagList]; + updatedList = [...sampleTestTypeToGetTagList]; updatedList.splice(existingIndex, 1); setSampleTestTypeToGetTagList(updatedList); } else { @@ -342,17 +342,31 @@ function BatchTestReassignmentAndCancelation() { id: selectedTestId, name: testName, }; - setSampleTestTypeToGetTagList([ - ...sampleTestTypeToGetTagList, - selectedTest, - ]); + updatedList = [...sampleTestTypeToGetTagList, selectedTest]; + setSampleTestTypeToGetTagList(updatedList); } + + const updatedReplace = updatedList.map((item) => item.id).join(","); + setJsonWad((prevJsonWad) => ({ + ...prevJsonWad, + replace: updatedReplace, + })); }; function handleRemoveSampleTypeListSelectIdTestTag(indexToRemove) { - setSampleTestTypeToGetTagList((prevTags) => - prevTags.filter((_, index) => index !== indexToRemove), - ); + setSampleTestTypeToGetTagList((prevTags) => { + const updatedTags = prevTags.filter( + (_, index) => index !== indexToRemove, + ); + + const updatedReplace = updatedTags.map((item) => item.id).join(","); + setJsonWad((prevJsonWad) => ({ + ...prevJsonWad, + replace: updatedReplace, + })); + + return updatedTags; + }); } useEffect(() => { @@ -500,6 +514,20 @@ function BatchTestReassignmentAndCancelation() { checked={replaceWith} onChange={() => { setReplaceWith(!replaceWith); + if (replaceWith) { + setJsonWad((prevJsonWad) => ({ + ...prevJsonWad, + replace: "", + })); + } else { + const selectedTestIds = sampleTestTypeToGetTagList + .map((item) => item.id) + .join(","); + setJsonWad((prevJsonWad) => ({ + ...prevJsonWad, + replace: selectedTestIds, + })); + } }} />
@@ -598,9 +626,7 @@ function BatchTestReassignmentAndCancelation() { { handleCheckboxChange(item.id, "notStarted"); @@ -641,9 +667,7 @@ function BatchTestReassignmentAndCancelation() { { handleCheckboxChange(item.id, "techReject"); @@ -684,9 +708,7 @@ function BatchTestReassignmentAndCancelation() { { handleCheckboxChange(item.id, "bioReject"); @@ -727,9 +749,7 @@ function BatchTestReassignmentAndCancelation() { { handleCheckboxChange(item.id, "notValidated"); @@ -752,7 +772,7 @@ function BatchTestReassignmentAndCancelation() { setChangesToShow(true); setBatchTestPost((prevBatchTestPost) => ({ ...prevBatchTestPost, - jsonWad: jsonWad, + jsonWad: JSON.stringify(jsonWad), })); }} type="button" @@ -802,7 +822,7 @@ function BatchTestReassignmentAndCancelation() { item && (

- + {item.labNo}
) @@ -821,7 +841,7 @@ function BatchTestReassignmentAndCancelation() { item && (

- + {item.labNo}
) @@ -840,7 +860,7 @@ function BatchTestReassignmentAndCancelation() { item && (

- + {item.labNo}
) @@ -859,7 +879,7 @@ function BatchTestReassignmentAndCancelation() { item && (

- + {item.labNo}
) @@ -887,7 +907,7 @@ function BatchTestReassignmentAndCancelation() { item && (

- + {item.labNo}
) @@ -906,7 +926,7 @@ function BatchTestReassignmentAndCancelation() { item && (

- + {item.labNo}
) @@ -925,7 +945,7 @@ function BatchTestReassignmentAndCancelation() { item && (

- + {item.labNo}
) @@ -944,7 +964,7 @@ function BatchTestReassignmentAndCancelation() { item && (

- + {item.labNo}
) @@ -957,7 +977,13 @@ function BatchTestReassignmentAndCancelation() {
+ ); } export default injectIntl(BatchTestReassignmentAndCancelation); - -// post call checkup -// batchTestReassignmentPostCall final call pending diff --git a/src/main/java/org/openelisglobal/test/controller/rest/BatchTestReassignmentRestController.java b/src/main/java/org/openelisglobal/test/controller/rest/BatchTestReassignmentRestController.java index b50c77e96..77e0f2cc5 100644 --- a/src/main/java/org/openelisglobal/test/controller/rest/BatchTestReassignmentRestController.java +++ b/src/main/java/org/openelisglobal/test/controller/rest/BatchTestReassignmentRestController.java @@ -71,7 +71,7 @@ public BatchTestReassignmentForm showBatchTestReassignmentUpdate(HttpServletRequ formValidator.validate(form, result); if (result.hasErrors()) { - saveErrors(result); + // saveErrors(result); // return findForward(FWD_FAIL_INSERT, form); return form; }