diff --git a/micro-ui/web/micro-ui-internals/example/public/index.html b/micro-ui/web/micro-ui-internals/example/public/index.html index 7213309f10b..fce42aa9383 100644 --- a/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/micro-ui/web/micro-ui-internals/example/public/index.html @@ -11,6 +11,7 @@ DIGIT + diff --git a/micro-ui/web/micro-ui-internals/packages/css/package.json b/micro-ui/web/micro-ui-internals/packages/css/package.json index 8392623cabe..547a7dc63d5 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-css", - "version": "1.0.7-microplan", + "version": "1.0.8-microplan", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss b/micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss index 30afa23ac73..1a544e7708e 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss +++ b/micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss @@ -1,3 +1,22 @@ +$box-shadow-color: #00000029; +$border-color: rgba(214, 213, 212, 1); +$highlight-color: rgba(244, 119, 56, 1); +$highlight-color: rgba(244, 119, 56, 1); +$border-color: rgba(214, 213, 212, 1); + + +.navigator-componet-not-found { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + padding: 2rem; + font-weight: 700; + font-size: 2rem; + color: rgb(0, 0, 0); +} + + .modal-header { width: 30rem; font-weight: 700; @@ -96,7 +115,7 @@ background-color: #ffffff; border-top-left-radius: 0.5rem; border-bottom-left-radius: 0.5rem; - box-shadow: 0px 1px 2px 0px #00000029; + box-shadow: 0 0.063rem 0.125rem 0 $box-shadow-color; } .upload-section-options-active, @@ -104,7 +123,7 @@ min-height: 3.7rem; display: flex; align-items: center; - border-bottom: 1px rgba(214, 213, 212, 1) solid; + border-bottom: 0.063rem $border-color solid; cursor: pointer; p { @@ -165,7 +184,7 @@ color: rgba(177, 180, 182, 1); margin: 0 0.625rem; font-size: 1.25rem; - padding-top: 0px; + padding-top: 0; font-weight: 500; } @@ -202,7 +221,7 @@ align-items: center !important; min-width: 13.5rem; height: 2.5rem; - border: 1px rgba(244, 119, 56, 1) solid; + border: 0.063rem $highlight-color solid; .icon { display: flex; @@ -234,7 +253,7 @@ flex-wrap: wrap; .upload-option-container-selected { - border: 2px rgba(244, 119, 56, 1) solid; + border: 0.125rem $highlight-color solid; color: rgba(244, 119, 56, 1); } } @@ -255,7 +274,10 @@ cursor: pointer; &:hover { - border: 2px rgba(244, 119, 56, 1) solid; + border: 0.125rem $highlight-color solid; + p{ + color: rgba(244, 119, 56, 1); + } } p { @@ -263,13 +285,13 @@ } .upload-option-selected { - border: 0.125rem rgba(244, 119, 56, 1) solid; + border: 0.125rem $highlight-color solid; color: rgba(244, 119, 56, 1); } .select-button { justify-self: end; - border: 1px solid rgba(244, 119, 56, 1); + border: 0.063rem solid $highlight-color; background-color: rgba(255, 255, 255, 1); width: 11rem; height: 2.5rem; @@ -285,7 +307,7 @@ align-items: center !important; justify-self: end; justify-content: center; - border: 1px solid rgba(244, 119, 56, 1); + border: 0.063rem solid $highlight-color; background-color: rgba(244, 119, 56, 1); width: 11rem; height: 2.5rem; @@ -300,7 +322,7 @@ min-width: 90%; min-height: 10rem; padding-top: 0.625; - border: 1px rgba(214, 213, 212, 1); + border: 0.063rem $border-color; margin: 1rem 0; display: flex !important; flex-direction: column; @@ -332,7 +354,7 @@ } .uploaded-file { - border: 1px solid rgba(214, 213, 212, 1); + border: 0.063rem solid $border-color; min-height: 4.75rem; background-color: rgb(256, 252, 252); display: flex !important; @@ -376,7 +398,7 @@ margin-left: 1rem; min-width: 9rem; height: 2.5rem; - border: 1px rgba(244, 119, 56, 1) solid; + border: 0.063rem $highlight-color solid; background-color: white; cursor: pointer; } @@ -423,7 +445,7 @@ } .file-upload-error-container { - border: 1px solid rgba(214, 213, 212, 1); + border: 0.063rem solid $border-color; min-height: 4.75rem; display: flex !important; flex-direction: column; @@ -609,7 +631,7 @@ padding: 1rem 0.5rem; display: flex; flex-direction: column; - gap: 20px; + gap: 1.25rem; background-color: white !important; border: 0.063rem rgba(0, 0, 0, 0.16) solid !important; border-radius: 0.25rem; @@ -633,8 +655,8 @@ &::-webkit-scrollbar-thumb { background: rgba(177, 180, 182, 1); - border-radius: 10px; - border: 2px solid #f0f0f0; + border-radius: 0.625rem; + border: 0.125rem solid #f0f0f0; } &::-webkit-scrollbar-thumb:hover { @@ -643,18 +665,18 @@ h3 { background-color: #f4f4f4; - padding: 10px; + padding: 0.625rem; margin: 0; } .excel-table { width: 100%; - border: 1px solid #ccc; + border: 0.063rem solid #ccc; border-collapse: collapse; th, td { - border: 1px solid #ccc; + border: 0.063rem solid #ccc; padding: 8px; font-family: Arial, sans-serif; font-size: 14px; @@ -764,7 +786,10 @@ width: 100%; background-color: rgb(255, 255, 255); padding: 1.3rem; + margin-top: 1.3rem; height: 33.5rem; + border-radius: 0.25rem; + box-shadow: 0 0.063rem 0.125rem 0 rgba(0, 0, 0, 0.16); .add-icon { background-color: rgba(244, 119, 56, 1); @@ -821,8 +846,8 @@ &::-webkit-scrollbar-thumb { background: rgba(177, 180, 182, 1); - border-radius: 10px; - border: 2px solid #f0f0f0; + border-radius: 10; + border: 0.125rem solid #f0f0f0; } &::-webkit-scrollbar-thumb:hover { @@ -913,13 +938,13 @@ align-items: center; } - .select-and-input-wrapper-first{ + .select-and-input-wrapper-first { margin-top: 0.8rem; width: 100%; display: flex; align-items: center; } - + .headerbar { padding: 0; @@ -979,7 +1004,7 @@ -webkit-appearance: none; -moz-appearance: none; width: 100%; - border: 1px solid rgba(80, 90, 95, 1); + border: 0.063rem solid rgba(80, 90, 95, 1); background-color: rgb(255, 255, 255, 0); padding: 0.5rem; font-weight: 400; @@ -1013,7 +1038,7 @@ align-items: center; justify-content: center; background: rgba(255, 255, 255, 1); - border: 0.063rem solid rgba(244, 119, 56, 1); + border: 0.063rem solid $highlight-color; p { color: rgba(244, 119, 56, 1); @@ -1031,6 +1056,7 @@ .rule-engine-section { display: flex; flex-direction: column; + margin-top: 1.3rem; .rule-engine-body { font-family: Roboto; @@ -1041,7 +1067,8 @@ background-color: rgb(255, 255, 255); padding: 1.3rem; height: 33.5rem; - + box-shadow: 0 0.063rem 0.125rem 0 rgba(0, 0, 0, 0.16); + border-radius: 0.25rem; .heading { padding: 0.5rem 0; @@ -1079,8 +1106,8 @@ &::-webkit-scrollbar-thumb { background: rgba(177, 180, 182, 1); - border-radius: 10px; - border: 2px solid #f0f0f0; + border-radius: 10; + border: 0.125rem solid #f0f0f0; } &::-webkit-scrollbar-thumb:hover { @@ -1171,14 +1198,14 @@ align-items: center; } - .select-and-input-wrapper-first{ + .select-and-input-wrapper-first { margin-top: 0rem; width: 100%; display: flex; align-items: center; } - - .user-input-wrapper{ + + .user-input-wrapper { width: 100%; } @@ -1225,7 +1252,7 @@ -webkit-appearance: none; -moz-appearance: none; width: 100%; - border: 1px solid rgba(80, 90, 95, 1); + border: 0.063rem solid rgba(80, 90, 95, 1); background-color: rgb(255, 255, 255, 0); padding: 0.5rem; font-weight: 400; @@ -1274,7 +1301,7 @@ align-items: center; justify-content: center; background: rgba(255, 255, 255, 1); - border: 0.063rem solid rgba(244, 119, 56, 1); + border: 0.063rem solid $highlight-color; p { color: rgba(244, 119, 56, 1); @@ -1341,24 +1368,39 @@ } } } +} +.create-microplan { - .next-previous-bar { - display: flex; - bottom: 0; - left: 0; - /* Adjust as needed */ - width: 100%; - /* Adjust as needed */ - background-color: #ffffff; - /* Adjust as needed */ - padding: 10px; - /* Adjust as needed */ - box-shadow: rgba(0, 0, 0, 0.16) 0 -2px 8px; - max-width: 480px; - z-index: 100; - text-align: right; + .custom-action-bar, + .custom-action-bar-no-first-button { + padding: 1.5rem 1.5rem 1.5rem 5.3rem; + display: flex !important; + justify-content: space-between; + align-items: center; + height: 5.5rem; + + .custom-button { + width: 12.5rem; + border: 0.063rem red solid; + display: flex; + justify-content: center; + align-items: center; + + h2 { + width: fit-content !important; + } + + .icon { + margin: 0 0 0 1rem !important; + } + } + + } + + .custom-action-bar-no-first-button { + justify-content: end; } } \ No newline at end of file diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/package.json b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/package.json index cd4d15c13cd..fd11e2155a4 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/package.json @@ -19,6 +19,7 @@ }, "dependencies": { "@cyntler/react-doc-viewer": "1.10.3", + "@egovernments/digit-ui-components": "^0.0.1-beta.2", "@egovernments/digit-ui-react-components": "1.8.1-beta.9", "@egovernments/digit-ui-svg-components": "1.0.5", "@rjsf/core": "5.10.0", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/ComonComponents.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/ComonComponents.js index d9673022197..104a01c1993 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/ComonComponents.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/ComonComponents.js @@ -2,7 +2,6 @@ import { Close, FileDownload } from "@egovernments/digit-ui-svg-components"; import React from "react"; import { useTranslation } from "react-i18next"; - export const ButtonType1 = (props) => { return (
@@ -14,9 +13,11 @@ export const ButtonType1 = (props) => { export const ButtonType2 = (props) => { return (
-
- -
+ {props.showDownloadIcon && ( +
+ +
+ )}

{props.text}

); @@ -24,10 +25,8 @@ export const ButtonType2 = (props) => { export const ModalHeading = (props) => { return ( -

+

{props.label}

); }; - - \ No newline at end of file diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanningCard.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanningCard.js index ed86f7c5e70..3a04615bbf2 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanningCard.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/MicroplanningCard.js @@ -38,7 +38,7 @@ const MicroplanningCard = () => { }, ]; - + links = links.filter((link) => (link?.roles && link?.roles?.length > 0 ? Digit.Utils.didEmployeeHasAtleastOneRole(link?.roles) : true)); const propsForModuleCard = { diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Nagivator.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Nagivator.js new file mode 100644 index 00000000000..0d8dace9f80 --- /dev/null +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Nagivator.js @@ -0,0 +1,157 @@ +import { ActionBar, Stepper, Toast } from "@egovernments/digit-ui-components"; +import PropTypes from 'prop-types'; +import React, { useState, useEffect, useCallback } from "react"; +import { useTranslation } from "react-i18next"; +import { Button } from "@egovernments/digit-ui-react-components"; +import { ArrowBack, ArrowForward } from "@egovernments/digit-ui-svg-components"; + +/** + * + * @param { config: Object, checkDataCompleteness: boolean, components: Object, childProps: Object, stepNavigationActive: boolean } props + * @returns + * + */ +// Main component for creating a microplan +const Navigator = (props) => { + // States + const [currentPage, setCurrentPage] = useState(); + const [toast, setToast] = useState(); + const [navigationEvent, setNavigationEvent] = useState(); + /** + * checkDataCompletion + * "true": check for data completeness + * "false": do nothing + * "valid": data is present move to the respective step + * "invalid": whole or a part of the data is missing + */ + const [checkDataCompletion, setCheckDataCompletion] = useState("false"); + + const { t } = useTranslation(); + + // Effect to set initial current page when timeline options change + useEffect(() => { + if (!props.config || props.config.length === 0) return; + setCurrentPage(props.config[0]); + }, [props.config]); + + // Effect to handle data completion validation and show toast + useEffect(() => { + if (checkDataCompletion === "false" || checkDataCompletion === "true" || checkDataCompletion === "valid") return; + if (checkDataCompletion === "invalid") setToast(t("COMMON_PLEASE_FILL_ALL_THE_FIELDS")); + setCheckDataCompletion("false"); + }, [checkDataCompletion]); + + // Effect to handle navigation events and transition between steps + useEffect(() => { + if (checkDataCompletion !== "valid" || navigationEvent === undefined) return; + if (navigationEvent && navigationEvent.name === "next") nextStep(); + else if (navigationEvent && navigationEvent.name === "step" && navigationEvent.step) onStepClick(navigationEvent.step); + setCheckDataCompletion("false"); + setNavigationEvent(undefined); + }, [navigationEvent, checkDataCompletion]); + + // Function to navigate to the next step + const nextStep = useCallback(() => { + if (!currentPage) return; + if (currentPage?.id + 1 > props.config.length - 1) return; + setCurrentPage((previous) => props.config[previous?.id + 1]); + }, [currentPage]); + + // Function to navigate to the previous step + const previousStep = useCallback(() => { + setCurrentPage((previous) => props.config[previous?.id - 1]); + }, []); + + // Function to handle step click and navigate to the selected step + const onStepClick = useCallback((index) => { + const newCurrentPage = props.config.find((item) => item.id === index); + setCurrentPage(newCurrentPage); + }); + + // Function to handle next button click + const nextbuttonClickHandler = useCallback(() => { + if (props.checkDataCompleteness && LoadCustomComponent({component:props.components[currentPage?.component]}) !== null) { + setCheckDataCompletion("true"); + setNavigationEvent({ name: "next" }); + } else nextStep(); + }, [props.checkDataCompleteness,nextStep]); + + // Function to handle step click + const stepClickHandler = useCallback( + (index) => { + if(!props.stepNavigationActive) return; + if (props.checkDataCompleteness && LoadCustomComponent({component:props.components[currentPage?.component]}) !== null) { + setCheckDataCompletion("true"); + setNavigationEvent({ name: "step", step: index }); + } else { + onStepClick(index); + } + }, + [props.checkDataCompleteness,props.stepNavigationActive,onStepClick] + ); + + return ( +
+ {/* Stepper component */} + t(item.name))} + direction="horizontal" + onStepClick={stepClickHandler} + /> + + {/* Load custom component based on current page */} + {LoadCustomComponent({component:props.components[currentPage?.component]}) !== null ? ( + + ) : ( +
{t("COMMON_DATA_NOT_PRESENT")}
+ )} + + {/* Action bar */} + + {/* Back button */} + {currentPage?.id > 0 && ( + + + + {/* Toast notification */} + {toast && setToast(undefined)} />} +
+ ); +}; + +// Component to load custom component based on current page +const LoadCustomComponent = (props) => { + if (props && !props.component) return null; + const secondaryProps = props.secondaryProps; + return ; +}; +LoadCustomComponent.propTypes = { + component: PropTypes.elementType.isRequired, + secondaryProps: PropTypes.object, + }; +export default Navigator; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/TimelineMicroplan.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/TimelineMicroplan.js deleted file mode 100644 index a5a140cde70..00000000000 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/TimelineMicroplan.js +++ /dev/null @@ -1,25 +0,0 @@ -import React from "react"; -import { useTranslation } from "react-i18next"; -import { TickMark } from "@egovernments/digit-ui-react-components"; -import { timeLineOptions } from "../configs/timeLineOptions.json"; - -let actions = timeLineOptions; -const TimelineMicroplan = ({ currentStep = 0, onStepClick }) => { - const { t } = useTranslation(); - const isMobile = window.Digit.Utils.browser.isMobile(); - return ( -
- {actions.map((data) => ( -
onStepClick(data?.id)}> -
- {data?.id < currentStep ? : data?.id + 1} - {t(data?.name)} -
- {data?.id < actions.length - 1 && } -
- ))} -
- ); -}; - -export default TimelineMicroplan; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/CreateMicroplan.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/CreateMicroplan.js index f7ae6ea793f..496d1ef2d21 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/CreateMicroplan.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/CreateMicroplan.js @@ -1,11 +1,16 @@ -import { FormComposerV2 } from "@egovernments/digit-ui-react-components"; +// import { ActionBar, FormComposerV2 } from "@egovernments/digit-ui-react-components"; +// import { ActionBar, Button, Stepper} from "@egovernments/digit-ui-components"; +import { ActionBar, Stepper, Toast } from "@egovernments/digit-ui-components"; + import React, { useState, useEffect, useCallback } from "react"; import { useTranslation } from "react-i18next"; -import TimelineMicroplan from "../../components/TimelineMicroplan"; import { timeLineOptions } from "../../configs/timeLineOptions.json"; import Upload from "./Upload"; import Hypothesis from "./Hypothesis"; import RuleEngine from "./RuleEngine"; +import { Button } from "@egovernments/digit-ui-react-components"; +import { ArrowBack, ArrowForward } from "@egovernments/digit-ui-svg-components"; +import Navigator from "../../components/Nagivator"; export const components = { Upload, @@ -13,40 +18,30 @@ export const components = { RuleEngine, }; +// Main component for creating a microplan const CreateMicroplan = () => { - const [currentPage, setCurrentPage] = useState(); - useEffect(() => { - if (!timeLineOptions || timeLineOptions.length === 0) return; - setCurrentPage(timeLineOptions[0]); - }, [timeLineOptions]); + // States + const [microplanData, setMicroplanData] = useState(); - const nextStep = useCallback(() => { - setCurrentPage((previous) => timeLineOptions[previous?.id + 1]); - }, []); + const { t } = useTranslation(); - const previousStep = useCallback(() => { - setCurrentPage((previous) => timeLineOptions[previous?.id - 1]); + // useEffect to store data in session storage + useEffect(() => { + if (!microplanData) return; + Digit.SessionStorage.set("microplanData", microplanData); + }, [microplanData]); + + // useEffect to store data in session storage + useEffect(() => { + const data = Digit.SessionStorage.get("microplanData"); + setMicroplanData(data); }, []); return ( -
- ""} /> - - 0 ? true : false} - secondaryLabel={"PREVIOUS"} - onSecondayActionClick={previousStep} - label={currentPage?.id < timeLineOptions.length - 1 ? "NEXT" : "SUBMIT"} - /> +
+
); }; -const LoadCustomComponent = (props) => { - if (!props.component) return null; - return ; -}; export default CreateMicroplan; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Guidelines.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Guidelines.js index 312a1df37ff..d5d0b070afd 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Guidelines.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Guidelines.js @@ -1,20 +1,30 @@ -import React from 'react' -import { useTranslation } from 'react-i18next' -const Guidelines = () => { - const {t} = useTranslation() +import React from "react"; +import { useTranslation } from "react-i18next"; +import { Link } from "react-router-dom"; +const Guidelines = ({ path }) => { + const { t } = useTranslation(); + // const newPath = String(window.contextPath).split("/") + // console.log(newPath) // Keeping inline style for now because design for this screen is not given yet return ( -
{t("CREATE_MICROPLAN_GUIDELINES")}
- ) -} + +
+ {t("CREATE_MICROPLAN_GUIDELINES")} +
+ + ); +}; -export default Guidelines \ No newline at end of file +export default Guidelines; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Hypothesis.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Hypothesis.js index eed559ff8f0..f547668c565 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Hypothesis.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/Hypothesis.js @@ -17,7 +17,7 @@ const initialAssumptions = [ }, ]; -const Hypothesis = ({ campaignType = "SMC" }) => { +const Hypothesis = ({ campaignType = "SMC", microplanData, setMicroplanData, checkDataCompletion, setCheckDataCompletion }) => { const { t } = useTranslation(); // States @@ -27,14 +27,33 @@ const Hypothesis = ({ campaignType = "SMC" }) => { const [itemForDeletion, setItemForDeletion] = useState(); const [exampleOption, setExampleOption] = useState(""); - // Fetching data using custom MDMS hook - const { isLoading, data } = Digit.Hooks.useCustomMDMS("mz", "hcm-microplanning", [ - { name: "hypothesisAssumptions" }, - ]); + // UseEffect to extract data on first render + useEffect(() => { + if (!microplanData || !microplanData.hypothesis) return; + setAssumptions(microplanData.hypothesis); + }, []); + + // UseEffect for checking completeness of data before moveing to next section + useEffect(() => { + if (!assumptions || checkDataCompletion !== "true" || !setCheckDataCompletion) return; + let check = assumptions.every((item) => Object.values(item).every((data) => data !== "")); + check = check && assumptions.length !== 0; + if (check) setCheckDataCompletion("valid"); + else setCheckDataCompletion("invalid"); + }, [checkDataCompletion]); + + // UseEffect to store current data + useEffect(() => { + if (!assumptions || !setMicroplanData) return; + setMicroplanData((previous) => ({ ...previous, hypothesis: assumptions })); + }, [assumptions]); + + // Fetching data using custom MDMS hook + const { isLoading, data } = Digit.Hooks.useCustomMDMS("mz", "hcm-microplanning", [{ name: "hypothesisAssumptions" }]); // useEffect to initialise the data from MDMS useEffect(() => { - if(!data || !data["hcm-microplanning"]) return; + if (!data || !data["hcm-microplanning"]) return; let hypothesisAssumptions = data["hcm-microplanning"]["hypothesisAssumptions"]; if (!hypothesisAssumptions) return; @@ -71,7 +90,9 @@ const Hypothesis = ({ campaignType = "SMC" }) => { t={t} /> {/* delete conformation */} @@ -81,7 +102,7 @@ const Hypothesis = ({ campaignType = "SMC" }) => { LeftButtonHandler={deleteAssumptionHandlerCallback} RightButtonHandler={closeModal} footerLeftButtonBody={} - footerRightButtonBody={} + footerRightButtonBody={} header={} bodyText={t("HYPOTHESIS_INSTRUCTIONS_DELETE_ENTRY_CONFIRMATION")} /> @@ -130,7 +151,7 @@ const InterractableSection = React.memo(
-

{t("KEY")}

+

{t("KEY")}

{t("VALUE")}

@@ -142,8 +163,8 @@ const InterractableSection = React.memo(
- {assumptions.map((item,index) => ( -
+ {assumptions.map((item, index) => ( +
{ +import { Toast } from "@egovernments/digit-ui-components"; + +const Upload = ({ + MicroplanName = "default", + campaignType = "SMC", + microplanData, + setMicroplanData, + checkDataCompletion, + setCheckDataCompletion, +}) => { const { t } = useTranslation(); // Fetching data using custom MDMS hook @@ -42,6 +50,42 @@ const Upload = ({ MicroplanName = "default", campaignType = "SMC" }) => { const [previewUploadedData, setPreviewUploadedData] = useState(); const [uploadGuideLines, setUploadGuideLines] = useState(); + // UseEffect for checking completeness of data before moveing to next section + useEffect(() => { + if (!fileDataList || checkDataCompletion !== "true" || !setCheckDataCompletion) return; + const valueList = fileDataList ? Object.values(fileDataList) : []; + if (valueList.length !== 0 && fileDataList.Microplanning_Population && fileDataList.Microplanning_Population.error === null) + setCheckDataCompletion("valid"); + else setCheckDataCompletion("invalid"); + }, [checkDataCompletion]); + + // UseEffect to store current data + useEffect(() => { + if (!fileDataList || !setMicroplanData) return; + setMicroplanData((previous) => ({ ...previous, upload: fileDataList })); + }, [fileDataList]); + + // UseEffect to extract data on first render + useEffect(() => { + if (!microplanData || !microplanData.upload) return; + setFileDataList(microplanData.upload); + }, []); + + // UseEffect to add a event listener for keyboard + useEffect(() => { + window.addEventListener("keydown", handleKeyPress); + + return () => window.removeEventListener("keydown", handleKeyPress); + }, [modal]); + + const handleKeyPress = (event) => { + if (modal !== "upload-guidelines") return; + if (event.key === "x" || event.key === "Escape") { + // Perform the desired action when "x" or "esc" is pressed + if (modal === "upload-guidelines") setModal("none"); + } + }; + // Effect to update sections and selected section when data changes useEffect(() => { if (data) { @@ -49,11 +93,15 @@ const Upload = ({ MicroplanName = "default", campaignType = "SMC" }) => { let schemas = data["hcm-microplanning"]["schemas"]; let UIConfiguration = data["hcm-microplanning"]["UIConfiguration"]; // let uploadSections = Config["UploadConfiguration"]; - const uploadGuideLinesList = UIConfiguration.find((item) => item.name === "uploadGuideLines").UploadGuideLineInstructions; - setUploadGuideLines(uploadGuideLinesList); - setValidationSchemas(schemas); - setSelectedSection(uploadSections.length > 0 ? uploadSections[0] : null); - setSections(uploadSections); + if (UIConfiguration) { + const uploadGuideLinesList = UIConfiguration.find((item) => item.name === "uploadGuideLines").UploadGuideLineInstructions; + setUploadGuideLines(uploadGuideLinesList); + } + if (schemas) setValidationSchemas(schemas); + if (uploadSections) { + setSelectedSection(uploadSections.length > 0 ? uploadSections[0] : null); + setSections(uploadSections); + } } }, [data]); @@ -382,7 +430,10 @@ const Upload = ({ MicroplanName = "default", campaignType = "SMC" }) => { const deleteFile = () => { // Digit.SessionStorage.del(fileData.id); setResourceMapping([]); - setFileDataList({ ...fileDataList, [fileData.id]: undefined }); + setFileDataList((previous) => { + delete previous[fileData.id]; + return previous; + }); setFileData(undefined); setDataPresent(false); setUploadedFileError(null); @@ -544,7 +595,7 @@ const Upload = ({ MicroplanName = "default", campaignType = "SMC" }) => { RightButtonHandler={() => UploadFileClickHandler(true)} sections={sections} footerLeftButtonBody={} - footerRightButtonBody={} + footerRightButtonBody={} header={} bodyText={t("INSTRUCTIONS_DOWNLOAD_TEMPLATE_FOR_" + selectedSection.code + "_" + selectedFileType.code)} /> @@ -612,18 +663,18 @@ const Upload = ({ MicroplanName = "default", campaignType = "SMC" }) => { popupStyles={{ width: "calc(100% - 6rem)" }} closeModal={closeModal} hideSubmit={true} - headerBarMainStyle={{ width: "100%", margin: 0, padding:0}} - header={} + headerBarMainStyle={{ width: "100%", margin: 0, padding: 0 }} + header={} body={} /> )} {loaderActivation && } - {toast && toast.state === "success" && setToast(null)} />} + {toast && toast.state === "success" && setToast(null)} />} {toast && toast.state === "error" && ( - setToast(null)} style={{ zIndex: "9999999" }} error /> + setToast(null)} error /> )} {toast && toast.state === "warning" && ( - setToast(null)} style={{ zIndex: "9999999" }} warning /> + setToast(null)} warning /> )} {previewUploadedData && (
@@ -643,10 +694,7 @@ const UploadSection = ({ item, selected, setSelectedSection }) => { }; return ( -
+
@@ -682,18 +730,30 @@ const UploadComponents = ({ item, selected, uploadOptions, selectedFileType, sel // Component for rendering individual upload option container const UploadOptionContainer = ({ item, selectedFileType, selectFileTypeHandler }) => { + const [isHovered, setIsHovered] = useState(false); + + const handleMouseEnter = () => { + setIsHovered(true); + }; + + const handleMouseLeave = () => { + setIsHovered(false); + }; + return (

{t(item.code)}

{t("INSTRUCTION_PREREQUISITES_2")}

{t("PROCEDURE")}

- {uploadGuideLines.map((item) => ( -

{t(item)}

+ {uploadGuideLines.map((item, index) => ( +

+ {t(item)} +

))} - {/* {points.map((item) => ( -

{item}

- ))} */}
); }; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js index c800118f164..679807ce7b5 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/pages/employee/index.js @@ -63,7 +63,6 @@ const App = ({ path }) => { clearSessionFormDataView(); } }, [location]); - return (
diff --git a/micro-ui/web/public/index.html b/micro-ui/web/public/index.html index 05dd94771ba..73fce04e7bd 100644 --- a/micro-ui/web/public/index.html +++ b/micro-ui/web/public/index.html @@ -12,9 +12,10 @@ type="text/css" /> +