Skip to content

Commit

Permalink
FEATURE/HCMPRE-1704 : Removing current validation from assumptions an… (
Browse files Browse the repository at this point in the history
#2122)

* FEATURE/HCMPRE-1704 : Removing current validation from assumptions and making sure the flow works as expected( for mixed strat, regis and dist can be same)

* FEATURE/HCMPRE-1704 : Review updates
  • Loading branch information
Swathi-eGov authored and nipunarora-eGov committed Jan 15, 2025
1 parent bd7920c commit a9deaad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ const AssumptionsForm = ({ onSelect, ...props }) => {
setSelectedRegistrationProcess(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationProcess);
},[props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm])

const filteredOptions = resourceDistributionStrategyCode === "MIXED"
? optionsForProcesses.filter(option => option.resourceDistributionStrategyName !== "Fixed post & House-to-House")
: optionsForProcesses;

if (isLoadingPlanObject) {
return <Loader />
Expand All @@ -102,7 +99,7 @@ const AssumptionsForm = ({ onSelect, ...props }) => {
variant="select-dropdown"
t={t}
isMandatory={true}
option={filteredOptions.map(item => ({
option={optionsForProcesses.map(item => ({
code: item.resourceDistributionStrategyCode,
value: item.resourceDistributionStrategyName,
}))}
Expand All @@ -128,7 +125,7 @@ const AssumptionsForm = ({ onSelect, ...props }) => {
variant="select-dropdown"
t={t}
isMandatory={true}
option={filteredOptions.map(item => ({
option={optionsForProcesses.map(item => ({
code: item.resourceDistributionStrategyCode,
value: item.resourceDistributionStrategyName,
}))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const BoundarySelection = ({ onSelect, props: customProps, ...props }) => {
const [statusMap, setStatusMap] = useState({});
const [executionCount, setExecutionCount] = useState(0);
const [updateBoundary, setUpdateBoundary] = useState(true);
const [isStatusMapLoading, setIsStatusMapLoading] = useState(false);
const handleBoundaryChange = (value) => {
setBoundaryOptions(value?.boundaryOptions);
setSelectedData(value?.selectedData);
Expand Down Expand Up @@ -58,10 +59,19 @@ const BoundarySelection = ({ onSelect, props: customProps, ...props }) => {


useEffect(() => {
// Show loader before updating statusMap
setIsStatusMapLoading(true);
if (selectedData && selectedData.length >= 0) {
setStatusMap(() => Digit.Utils.microplanv1.createStatusMap(selectedData, boundaryHierarchy))
const newStatusMap = Digit.Utils.microplanv1.createStatusMap(selectedData, boundaryHierarchy);
setStatusMap(newStatusMap);
// Hide loader after updating statusMap
setIsStatusMapLoading(false);
}
}, [selectedData, boundaryHierarchy])
return () => {
// Cleanup function to prevent state updates if component unmounts during loading
setIsStatusMapLoading(false);
};
}, [selectedData, boundaryHierarchy]);


useEffect(() => {
Expand Down Expand Up @@ -94,7 +104,7 @@ const BoundarySelection = ({ onSelect, props: customProps, ...props }) => {

return (
<>
<BoundaryKpi data={statusMap} />
{isStatusMapLoading ? <Loader /> : <BoundaryKpi data={statusMap} />}
<CardNew className={"selecting-boundary-card"}>
<Header styles={{ margin: "0rem" }}>{t(`MICROPLAN_SELECT_BOUNDARY`)}</Header>
<p className="boundary-selection-description">{t(`MICROPLAN_SELECT_BOUNDARIES_DESCRIPTION`)}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const formValidator = (formData, key, state, t) => {
}

const processesAreValid = formData?.selectedRegistrationProcess?.code && formData?.selectedDistributionProcess?.code;
if (processesAreValid && (formData?.selectedRegistrationProcess.code === formData?.selectedDistributionProcess.code)) {
if (processesAreValid && (formData?.selectedRegistrationProcess.code === formData?.selectedDistributionProcess.code) && (formData?.selectedRegistrationProcess.code !== "MIXED")) {
return { key: "error", label: "ERROR_REGISTRATION_AND_DISTRIBUTION_ARE_SAME" }; // Customize as needed
}

Expand Down

0 comments on commit a9deaad

Please sign in to comment.