Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formcomposer action bar fixes #1862

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 });
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
};
}, [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();
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
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;
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
}
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");
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
}
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()} />]}
/>
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
) : null}
{showToast && (
Expand Down