Files
pedwfrontend/components/case/representation/utils/stepResolution.js
T
Robert Bond d05e54c020 Merged PR 2252: refactor(representations): extract journey step-resolution helpers (Slice R3,...
refactor(representations): extract journey step-resolution helpers (Slice R3, behaviour-preserving)

Related work items: #22441
2026-04-17 06:45:21 +00:00

74 lines
1.8 KiB
JavaScript

export const resolveJourneyStageFlags = ({
representationSubmit,
representationSubmitConfirmation
}) => {
const showCheckStage =
representationSubmit === true || representationSubmit === "true";
const showCompletionStage =
representationSubmitConfirmation === true ||
representationSubmitConfirmation === "true";
return {
showFormStage: !showCheckStage,
showCheckStage,
showCompletionStage
};
};
export const resolveRepresentationControlKey = ({
isLPA,
representationCapacity,
repDetailsCapacity,
appealType,
normalizeCapacity
}) => {
if (isLPA && (!representationCapacity || representationCapacity === "")) {
return {
controlKey: "lpa-capacity-selection",
normalizedCapacity: ""
};
}
const rawCapacity = representationCapacity || repDetailsCapacity || "false";
const normalizedCapacity = normalizeCapacity(rawCapacity.toLowerCase());
return {
controlKey: `capacity-${normalizedCapacity}`,
normalizedCapacity
};
};
export const resolveSubmitTransition = ({
representationType,
showQuestionnaireSection,
questionnaireCount
}) => {
if (representationType !== "Questionnaire") {
return "goToCheck";
}
if (
questionnaireCount !== 0 &&
showQuestionnaireSection < questionnaireCount
) {
return "advanceQuestionnaire";
}
return "goToCheck";
};
export const getQuestionnaireNextSection = (
currentSection,
questionnaireCount
) => {
if (questionnaireCount !== 0 && currentSection < questionnaireCount) {
return currentSection + 1;
}
return currentSection;
};
export const getQuestionnairePreviousSection = (currentSection) => {
return currentSection > 1 ? currentSection - 1 : currentSection;
};