Skip to content

Commit 31dc071

Browse files
committed
magic numbers
1 parent 38a8a4c commit 31dc071

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

src/app/[locale]/account/profile/cohort-discovery-request/components/NhsSdeAccessStepper/NhsSdeAccessStepper.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ const HOW_TO_HREF = `${ABOUT_HREF}?tab=how-to-request-access`;
3737
const REGISTRATION_INFO_URL =
3838
"https://digital.nhs.uk/data-and-information/research-powered-by-data/sde-network";
3939

40+
const STEP = {
41+
EXISTING_ACCESS: 1,
42+
COMPLETE_FORM: 2,
43+
SUBMIT_STATUS: 3,
44+
APPLICATION_REVIEW: 4,
45+
ACCESS_DECISION: 5,
46+
DONE: 6,
47+
} as const;
48+
4049
const NhsSdeAccessStepper = () => {
4150
const t = useTranslations(TRANSLATION_PATH);
4251
const tCd = useTranslations("pages.account.profile.cohortDiscovery");
@@ -70,26 +79,26 @@ const NhsSdeAccessStepper = () => {
7079
const isResolvedNeg = !!nhs && NHS_SDE_NEGATIVE_STATUSES.includes(nhs);
7180

7281
const activeStep = (() => {
73-
if (!cdsApproved) return 1;
82+
if (!cdsApproved) return STEP.EXISTING_ACCESS;
7483
switch (nhs) {
7584
case NHS_SDE_STATUS.APPROVED:
76-
return 6;
85+
return STEP.DONE;
7786
case NHS_SDE_STATUS.REJECTED:
7887
case NHS_SDE_STATUS.EXPIRED:
7988
case NHS_SDE_STATUS.BANNED:
8089
case NHS_SDE_STATUS.SUSPENDED:
81-
return 5;
90+
return STEP.ACCESS_DECISION;
8291
case NHS_SDE_STATUS.APPROVAL_REQUESTED:
83-
return 4;
92+
return STEP.APPLICATION_REVIEW;
8493
case NHS_SDE_STATUS.IN_PROCESS:
85-
return formCompleted ? 3 : 2;
94+
return formCompleted ? STEP.SUBMIT_STATUS : STEP.COMPLETE_FORM;
8695
default:
87-
return applied ? 2 : 1;
96+
return applied ? STEP.COMPLETE_FORM : STEP.EXISTING_ACCESS;
8897
}
8998
})();
9099

91100
const circleFor = (index: number): CircleState => {
92-
if (index === 1) {
101+
if (index === STEP.EXISTING_ACCESS) {
93102
return cdsApproved ? STEP_STATE.COMPLETE : STEP_STATE.LOCKED;
94103
}
95104
if (index < activeStep) return STEP_STATE.COMPLETE;

0 commit comments

Comments
 (0)