Skip to content

Commit

Permalink
Changes to supervisor start flow
Browse files Browse the repository at this point in the history
  • Loading branch information
nipunarora-eGov committed Oct 23, 2024
1 parent a0eb114 commit ac758c4
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import { Card, CardHeader } from "@egovernments/digit-ui-react-components";

const ActivityHomeCard = (props) => {
const ActivityHomeCard = ({onClickCard=()=>{},...props}) => {
const { t } = useTranslation();
const history = useHistory();

Expand All @@ -24,6 +24,7 @@ const ActivityHomeCard = (props) => {
}} // Adding margin to each card
onClick={() => {
if (!i.disable) { // Check if disabled
onClickCard(i)
i.link ? history.push(i.link) : location.assign(i.locate);
}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const ROLES = {

const MicroplanCard = () => {
const { t } = useTranslation();

const userInfo = Digit.UserService.getUser();
const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code);
// Check if at least one role of supervisor is there
const isSupervisorLoggedIn = userRoles.some(role => ROLES.SUPERVISOR.includes(role));
const generateLink = (labelKey, pathSuffix,roles=ROLES.MICROPLAN) => {
return {
label: t(labelKey),
Expand All @@ -36,7 +39,7 @@ const MicroplanCard = () => {

const propsForModuleCard = {
Icon: <SVG.UpdateExpense fill="white" height="50" width="50" />,
moduleName: t("MICROPLAN_MODULE_SETUP"),
moduleName: isSupervisorLoggedIn ? t("MICROPLAN_MODULE_PROCESS") :t("MICROPLAN_MODULE_SETUP"),
kpis: [],
links: links,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ const createUpdatePlanProject = async (req) => {
setCurrentKey((prev) => prev + 1);
setCurrentStep((prev) => prev + 1);
window.dispatchEvent(new Event("isLastStep"));
Digit.Utils.microplanv1.updateUrlParams({ isLastVerticalStep:null });
Digit.Utils.microplanv1.updateUrlParams({ internalKey:null });
return {
triggeredFrom,
};
Expand Down Expand Up @@ -379,11 +381,11 @@ const createUpdatePlanProject = async (req) => {

const planResFormula = await updatePlan(updatedPlanObjFormula);
if(planResFormula?.PlanConfiguration?.[0]?.id){

setCurrentKey((prev) => prev + 1);
setCurrentStep((prev) => prev + 1);
window.dispatchEvent(new Event("isFormulaLastStep"))

Digit.Utils.microplanv1.updateUrlParams({ isFormulaLastVerticalStep:null });
Digit.Utils.microplanv1.updateUrlParams({ formulaInternalKey:null });
return {
triggeredFrom,
};
Expand Down Expand Up @@ -498,6 +500,22 @@ const createUpdatePlanProject = async (req) => {
}
};
const planResForCompleteSetup = await updatePlan(updatedReqForCompleteSetup);
// const updatedReqForCompleteSetupNextAction = {
// ...fetchedPlanForSummary,
// workflow: {
// action: "START_DATA_APPROVAL",
// // "assignes": null,
// // "comments": null,
// // "verificationDocuments": null,
// // "rating": null
// },
// additionalDetails:{
// ...fetchedPlanForSummary.additionalDetails,
// setupCompleted:true,//we can put this in url when we come from microplan search screen to disable routing to other screens -> Only summary screen should show, or only allowed screens should show
// }
// };
// const planResForCompleteSetupNextAction = await updatePlan(updatedReqForCompleteSetupNextAction);

//here do cleanup activity and go to next screen

if (planResForCompleteSetup?.PlanConfiguration?.[0]?.id) {
Expand All @@ -523,6 +541,8 @@ const createUpdatePlanProject = async (req) => {
setCurrentKey((prev) => prev + 1);
setCurrentStep((prev) => prev + 1);
window.dispatchEvent(new Event("isLastStep"));
Digit.Utils.microplanv1.updateUrlParams({ isLastVerticalStep:null });
Digit.Utils.microplanv1.updateUrlParams({ internalKey:null });
return {
triggeredFrom,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,69 @@ const ChooseActivity = () => {
name: t("VALIDATE_N_APPROVE_POPULATION_DATA"),
link: `pop-inbox?campaignId=${campaignId}&microplanId=${microplanId}`,
icon: <SVG.Population height="36" width="36" />,
disable: isCardDisabled(["POPULATION_DATA_APPROVER", "ROOT_POPULATION_DATA_APPROVER"], workflowData, ["EXECUTION_TO_BE_DONE","CENSUS_DATA_APPROVAL_IN_PROGRESS"])
disable: isCardDisabled(["POPULATION_DATA_APPROVER", "ROOT_POPULATION_DATA_APPROVER"], workflowData, ["EXECUTION_TO_BE_DONE","CENSUS_DATA_APPROVAL_IN_PROGRESS"]),
optionKey: "VALIDATE_N_APPROVE_POPULATION_DATA"
},
{
name: t("ASSIGN_FACILITIES_TO_VILLAGE"),
link: `assign-facilities-to-villages?campaignId=${campaignId}&microplanId=${microplanId}`,
icon: <SVG.AssignmentTurnedIn height="36" width="36" />,
disable: isCardDisabled(["FACILITY_CATCHMENT_MAPPER", "ROOT_FACILITY_CATCHMENT_MAPPER"], workflowData, ["CENSUS_DATA_APPROVED"])
disable: isCardDisabled(["FACILITY_CATCHMENT_MAPPER", "ROOT_FACILITY_CATCHMENT_MAPPER"], workflowData, ["CENSUS_DATA_APPROVED"]),
optionKey: "ASSIGN_FACILITIES_TO_VILLAGE"
},
{
name: t("VALIDATE_N_APPROVE_MICROPLAN_ESTIMATIONS"),
link: `plan-inbox?campaignId=${campaignId}&microplanId=${microplanId}`,
icon: <SVG.FactCheck height="36" width="36" />,
disable: isCardDisabled(["PLAN_ESTIMATION_APPROVER", "ROOT_PLAN_ESTIMATION_APPROVER"], workflowData, ["RESOURCE_ESTIMATION_IN_PROGRESS"])
disable: isCardDisabled(["PLAN_ESTIMATION_APPROVER", "ROOT_PLAN_ESTIMATION_APPROVER"], workflowData, ["RESOURCE_ESTIMATION_IN_PROGRESS"]),
optionKey: "VALIDATE_N_APPROVE_MICROPLAN_ESTIMATIONS"
},
{
name: t("GEOSPATIAL_MAP_VIEW"),
link: null,
icon: <SVG.LocationOn height="36" width="36" />,
disable: isCardDisabled([], workflowData)
disable: isCardDisabled([], workflowData),
optionKey: "GEOSPATIAL_MAP_VIEW"
},
{
name: t("VIEW_MICROPLAN_ESTIMATIONS"),
link: `pop-inbox?campaignId=${campaignId}&microplanId=${microplanId}`,
icon: <SVG.Visibility height="36" width="36" />,
disable: isCardDisabled(["MICROPLAN_VIEWER"], workflowData)
disable: isCardDisabled(["MICROPLAN_VIEWER"], workflowData),
optionKey: "VIEW_MICROPLAN_ESTIMATIONS"
}
];

const updatePlan = async (req) => {
const planRes = await Digit.CustomService.getResponse({
url: "/plan-service/config/_update",
body: {
PlanConfiguration: req,
},
});
return planRes;
};

const onClickCard = async (card) => {
try {
if(card.optionKey==="VALIDATE_N_APPROVE_POPULATION_DATA" && planObject.status==="EXECUTION_TO_BE_DONE"){
// here update plan config
await updatePlan({
...planObject,
workflow:{
action:"START_DATA_APPROVAL"
}
});
}
} catch (error) {
console.error("ERROR_OCCURED_WHILE_UPDATING_PLAN");
console.error(error);
}
}

return (
<React.Fragment>
<ActivityHomeCard title={t("SELECT_AN_ACTIVITY_TO_CONTINUE")} module={activityCardData}/>
<ActivityHomeCard title={t("SELECT_AN_ACTIVITY_TO_CONTINUE")} module={activityCardData} onClickCard={onClickCard}/>
</React.Fragment>
);
}
Expand Down

0 comments on commit ac758c4

Please sign in to comment.