Skip to content

Commit

Permalink
Assumptions (#1457)
Browse files Browse the repository at this point in the history
* 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
3 people authored Oct 4, 2024
1 parent f94f7d2 commit 66ace5c
Show file tree
Hide file tree
Showing 13 changed files with 703 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.8.0-alpha.6/dist/index.css" />

<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-components-css@0.0.2-beta.34/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.0.73-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.0.74-campaign/dist/index.css" />

<link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.0.50-microplan/dist/index.css" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2575,3 +2575,46 @@ $border-color: rgba(214, 213, 212, 1);
font-weight: bold;
font-size: 1.2em;
}

.mp-description{
margin-top: 2rem;
margin-bottom: 1rem;
}

.assumptions-label-field > div > span {
width: 20rem;
font-size: 1.2rem;
margin-right: 2rem;
font-weight: bold;
}

.delete-button {
display: flex;
cursor: pointer;
margin-left: 1rem;
font-size: 1.2rem;
}

.fieldv1-container{
display: flex;
justify-content: center;
width:30rem;
align-items: center;
}

.assumptionsForm-label-field{
display: flex;
flex-direction: column;
gap: 1.5rem;
align-items: start !important;
}
.assumptionsForm-label-field > div > span{
font-size: 1.5rem;
font-weight: bold;
}

.assumptionsForm-card{
background-color:#FAFAFA;
border: 1px solid #D6D5D4;
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import MicroplanDetails from "./components/MicroplanDetails";
import CampaignDetails from "./components/CampaignDetails";
import { ProviderContext } from "./utils/context";
import BoundarySelection from "./components/BoundarySelection";
import AssumptionsForm from "./components/AssumptionsForm";
import HypothesisWrapper from "./components/HypothesisWrapper";
import DataMgmtTable from "./components/DataMgmtTable";
import FileComponent from "./components/FileComponent";
Expand All @@ -17,6 +18,7 @@ import FormulaView from "./components/FormulaView";
import SummaryScreen from "./pages/employee/SummaryScreen";
import CampaignBoundary from "./components/CampaignBoundary";


export const MicroplanModule = ({ stateCode, userType, tenants }) => {
const { path, url } = useRouteMatch();
const tenantId = Digit.ULBService.getCurrentTenantId();
Expand Down Expand Up @@ -55,6 +57,7 @@ const componentsToRegister = {
CampaignDetails,
MicroplanDetails,
BoundarySelection,
AssumptionsForm,
HypothesisWrapper,
DataMgmtTable,
FileComponent,
Expand Down
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;




Loading

0 comments on commit 66ace5c

Please sign in to comment.