Skip to content

Commit

Permalink
Formcomposer action bar fixes (#1862)
Browse files Browse the repository at this point in the history
* added serving facility

* form composer action bar fix

---------

Co-authored-by: NabeelAyubee <nayubi7@gmail.com>
  • Loading branch information
nabeelmd-eGov and NabeelAyubee authored Nov 20, 2024
1 parent 01451ee commit 0de2079
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ const FormulaConfigWrapper = ({ onSelect, props: customProps }) => {
useEffect(() => {
window.addEventListener("isFormulaLastStep", isFormulaLastStep);
return () => {
Digit.Utils.microplanv1.updateUrlParams({ isFormulaLastVerticalStep: null });
Digit.Utils.microplanv1.updateUrlParams({ formulaInternalKey: null });
window.removeEventListener("isFormulaLastStep", isFormulaLastStep);
};
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ const UserAccessWrapper = ({ onSelect, props: customProps, setupCompleted }) =>
return () => {
window.removeEventListener("verticalStepper", moveToPreviousStep);
window.removeEventListener("isLastStep", isLastStep);
Digit.Utils.microplanv1.updateUrlParams({ isLastVerticalStep: null });
Digit.Utils.microplanv1.updateUrlParams({ internalKey: null });
};
}, [internalKey]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => {
const [active, setActive] = useState(0);
const [showToast, setShowToast] = useState(false);
const [showPopUp, setShowPopUp] = useState(false);
const { campaignId, microplanId, key, ...queryParams } = Digit.Hooks.useQueryParams();
const { campaignId, microplanId, key, isFormulaLastVerticalStep, isLastVerticalStep, ...queryParams } = Digit.Hooks.useQueryParams();
const setupCompleted = queryParams?.["setup-completed"];
const [shouldUpdate, setShouldUpdate] = useState(false);
const [currentKey, setCurrentKey] = useState(() => {
Expand Down Expand Up @@ -271,8 +271,8 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => {
};

const onStepClick = (step) => {
if(setupCompleted){
return
if (setupCompleted) {
return;
}
if (step > currentStep) return;
const filteredSteps = microplanConfig?.[0].form.filter((item) => item.stepCount === String(step + 1));
Expand Down Expand Up @@ -328,10 +328,15 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => {
}

const getNextActionLabel = () => {
if (filteredConfig?.[0]?.form?.[0]?.body?.[0]?.isLast) {
if (isLastVerticalStep && isLastVerticalStep === "false") {
return null;
} else if (isFormulaLastVerticalStep && isFormulaLastVerticalStep === "false") {
return null;
} else if (filteredConfig?.[0]?.form?.[0]?.body?.[0]?.isLast) {
return t("MP_COMPLETE_SETUP");
} else {
return t("MP_SAVE_PROCEED");
}
return t("MP_SAVE_PROCEED");
};

if (loader) {
Expand Down Expand Up @@ -372,10 +377,10 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => {
label={getNextActionLabel()}
/>
{setupCompleted ? (
<ActionBar style={{ zIndex: "19" }} setactionFieldsToRight
actionFields={[
<Button label={t("GO_BACK_TO_MY_MICROPLAN")} onClick={() => history.goBack()} />
]}
<ActionBar
style={{ zIndex: "19" }}
setactionFieldsToRight
actionFields={[<Button label={t("GO_BACK_TO_MY_MICROPLAN")} onClick={() => history.goBack()} />]}
/>
) : null}
{showToast && (
Expand Down

0 comments on commit 0de2079

Please sign in to comment.