-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* microplan assumptions * minor changes * whole assumptions screens * added boolean false back * PACKAGE.CSS CHANGE * Refactor UI elements to support localization * minor changes * Update health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/Hypothesis.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * minor change in setupmicroplan --------- Co-authored-by: Nipun Arora <aroranipun1@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
f94f7d2
commit 66ace5c
Showing
13 changed files
with
703 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
...ro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsForm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import React, { useState, useEffect, Fragment } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { Card, Header, LabelFieldPair } from "@egovernments/digit-ui-react-components"; | ||
import { Dropdown, RadioButtons } from "@egovernments/digit-ui-components"; | ||
import { useMyContext } from "../utils/context"; | ||
|
||
const AssumptionsForm = ({ onSelect, ...props }) => { | ||
const { state } = useMyContext(); | ||
const { t } = useTranslation(); | ||
const optionsForProcesses = state.ResourceDistributionStrategy; | ||
const optionsForRegistrationDistributionMode = state.RegistrationAndDistributionHappeningTogetherOrSeparately; | ||
const [selectedRegistrationProcess, setSelectedRegistrationProcess] = useState(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationProcess || false); | ||
const [selectedDistributionProcess, setSelectedDistributionProcess] = useState(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedDistributionProcess || false); | ||
const [selectedRegistrationDistributionMode, setSelectedRegistrationDistributionMode] = useState(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationDistributionMode || false); | ||
const [executionCount, setExecutionCount] = useState(0); | ||
const resourceDistributionStrategyCode = props?.props?.sessionData?.CAMPAIGN_DETAILS?.campaignDetails?.distributionStrat?.resourceDistributionStrategyCode; | ||
|
||
useEffect(() => { | ||
if (executionCount < 5) { | ||
onSelect(props.props.name, {selectedRegistrationProcess,selectedDistributionProcess,selectedRegistrationDistributionMode}) | ||
setExecutionCount((prevCount) => prevCount + 1); | ||
} | ||
}); | ||
|
||
|
||
useEffect(()=>{ | ||
|
||
if(resourceDistributionStrategyCode === "MIXED"){ | ||
onSelect(props.props.name, {selectedRegistrationProcess,selectedDistributionProcess,selectedRegistrationDistributionMode}) | ||
return; | ||
} | ||
|
||
onSelect(props.props.name,{selectedRegistrationDistributionMode} ) | ||
|
||
},[selectedDistributionProcess, selectedRegistrationDistributionMode, selectedRegistrationProcess, resourceDistributionStrategyCode]) | ||
|
||
|
||
|
||
|
||
const filteredOptions = resourceDistributionStrategyCode === "MIXED" | ||
? optionsForProcesses.filter(option => option.resourceDistributionStrategyName !== "Fixed post & House-to-House") | ||
: optionsForProcesses; | ||
|
||
|
||
return ( | ||
<Card> | ||
<Header>{t("PROVIDE_DETAILS")}</Header> | ||
<p className="mp-description">{t("ANSWER_TO_PROVIDE_ESTIMATE")}</p> | ||
|
||
{/* Show dropdowns only if the code is MIXED */} | ||
{resourceDistributionStrategyCode === "MIXED" && ( | ||
<> | ||
{/* Dropdown for Registration Process */} | ||
<Card className="assumptionsForm-card"> | ||
<LabelFieldPair className="assumptionsForm-label-field"> | ||
<div style={{ width: "100%" }}> | ||
<span>{t("REGISTRATION_PROCESS")} </span> | ||
<span className="mandatory-span" style={{ marginLeft: "0rem" }}>*</span> | ||
</div> | ||
<Dropdown | ||
variant="select-dropdown" | ||
t={t} | ||
isMandatory={true} | ||
option={filteredOptions.map(item => ({ | ||
code: item.resourceDistributionStrategyCode, | ||
value: item.resourceDistributionStrategyName, | ||
}))} | ||
select={(value) => { | ||
setSelectedRegistrationProcess(value); | ||
}} | ||
selected={selectedRegistrationProcess} | ||
optionKey="code" | ||
showToolTip={true} | ||
style={{ width: "25rem" }} | ||
/> | ||
</LabelFieldPair> | ||
</Card> | ||
|
||
{/* Dropdown for Distribution Process */} | ||
<Card className="assumptionsForm-card"> | ||
<LabelFieldPair className="assumptionsForm-label-field"> | ||
<div style={{ width: "100%" }}> | ||
<span>{t("DISTRIBUTION_PROCESS")} </span> | ||
<span className="mandatory-span" style={{ marginLeft: "0rem" }}>*</span> | ||
</div> | ||
<Dropdown | ||
variant="select-dropdown" | ||
t={t} | ||
isMandatory={true} | ||
option={filteredOptions.map(item => ({ | ||
code: item.resourceDistributionStrategyCode, | ||
value: item.resourceDistributionStrategyName, | ||
}))} | ||
select={(value) => { | ||
setSelectedDistributionProcess(value); | ||
}} | ||
selected={selectedDistributionProcess} | ||
optionKey="code" | ||
showToolTip={true} | ||
style={{ width: "25rem" }} | ||
/> | ||
</LabelFieldPair> | ||
</Card> | ||
</> | ||
)} | ||
|
||
{/* Show radio buttons only if the code is HOUSE_TO_HOUSE or FIXED_POST */} | ||
{["HOUSE_TO_HOUSE", "FIXED_POST", "MIXED"].includes(resourceDistributionStrategyCode) && ( | ||
<Card className="assumptionsForm-card"> | ||
<LabelFieldPair className="assumptionsForm-label-field"> | ||
<div style={{ width: "100%" }}> | ||
<span>{t("REGISTRATION_AND_DISTRIBUTION")} </span> | ||
<span className="mandatory-span" style={{ marginLeft: "0rem" }}>*</span> | ||
</div> | ||
<RadioButtons | ||
isMandatory={true} | ||
additionalWrapperClass="custom-box" | ||
innerStyles={{ borderBottom: "0.063rem solid rgba(214, 213, 212, 1)" }} | ||
options={optionsForRegistrationDistributionMode?.map(item => ({ | ||
code: item.registrationAndDistributionHappeningTogetherOrSeparatelyCode, | ||
value: item.registrationAndDistributionHappeningTogetherOrSeparatelyName, | ||
}))} | ||
optionsKey="code" | ||
style={{ display: "flex", gap: "15rem" }} | ||
onSelect={(value) => { | ||
setSelectedRegistrationDistributionMode(value); | ||
}} | ||
selectedOption={selectedRegistrationDistributionMode} | ||
/> | ||
</LabelFieldPair> | ||
</Card> | ||
)} | ||
</Card> | ||
); | ||
}; | ||
|
||
export default AssumptionsForm; | ||
|
||
|
||
|
||
|
Oops, something went wrong.