Skip to content

Commit 3e54387

Browse files
VIA-304 SB Simplify styleHowToGetSection so we only need to add code for vaccines with specific needs.
1 parent 1a0a364 commit 3e54387

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/services/content-api/parsers/content-styling-service.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,20 @@ const extractHeadingAndContent = (text: string): HeadingWithContent => {
122122
}
123123
};
124124

125-
const styleHowToGetSection: Record<VaccineType, (section: VaccinePageSection, fragile: boolean) => StyledPageSection> =
126-
{
127-
[VaccineType.RSV]: styleHowToGetSectionForRsv,
128-
[VaccineType.RSV_PREGNANCY]: styleHowToGetSectionForRsvPregnancy,
129-
[VaccineType.TD_IPV_3_IN_1]: styleSection,
130-
[VaccineType.VACCINE_6_IN_1]: styleSection,
131-
[VaccineType.ROTAVIRUS]: styleSection,
132-
[VaccineType.HPV]: styleSection,
133-
[VaccineType.MENB_CHILDREN]: styleSection,
134-
[VaccineType.MMR]: styleSection,
135-
[VaccineType.PNEUMOCOCCAL]: styleSection,
136-
[VaccineType.SHINGLES]: styleSection,
137-
[VaccineType.MENACWY]: styleSection,
138-
[VaccineType.VACCINE_4_IN_1]: styleSection,
139-
[VaccineType.WHOOPING_COUGH]: styleSection,
140-
};
125+
const styleHowToGetSection = (
126+
vaccineType: VaccineType,
127+
section: VaccinePageSection,
128+
fragile: boolean,
129+
): StyledPageSection => {
130+
switch (vaccineType) {
131+
case VaccineType.RSV:
132+
return styleHowToGetSectionForRsv(section, fragile);
133+
case VaccineType.RSV_PREGNANCY:
134+
return styleHowToGetSectionForRsvPregnancy(section, fragile);
135+
default:
136+
return styleSection(section);
137+
}
138+
};
141139

142140
const getStyledContentForVaccine = async (
143141
vaccine: VaccineType,
@@ -150,7 +148,7 @@ const getStyledContentForVaccine = async (
150148
whatVaccineIsFor = styleSection(filteredContent.whatVaccineIsFor);
151149
}
152150
const whoVaccineIsFor: StyledPageSection = styleSection(filteredContent.whoVaccineIsFor);
153-
const howToGetVaccine: StyledPageSection = styleHowToGetSection[vaccine](filteredContent.howToGetVaccine, fragile);
151+
const howToGetVaccine: StyledPageSection = styleHowToGetSection(vaccine, filteredContent.howToGetVaccine, fragile);
154152
const vaccineSideEffects: StyledPageSection = styleSection(filteredContent.vaccineSideEffects);
155153
const webpageLink: URL = filteredContent.webpageLink;
156154

0 commit comments

Comments
 (0)