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
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user