@@ -211,27 +211,23 @@ function _extractHeadlineForContraindicationsAspect(content: ContentApiVaccineRe
211211}
212212
213213const getFilteredContentForVaccine = ( vaccineType : VaccineType , apiContent : string ) : VaccinePageContent => {
214- switch ( vaccineType ) {
215- case VaccineType . WHOOPING_COUGH :
216- return getFilteredContentForWhoopingCoughVaccine ( apiContent ) ;
217- case VaccineType . FLU_IN_PREGNANCY :
218- return getFilteredContentForFluInPregnancyVaccine ( apiContent ) ;
219- case VaccineType . FLU_FOR_ADULTS :
220- return getFilteredContentForFluVaccine ( apiContent ) ;
221- case VaccineType . FLU_FOR_CHILDREN :
222- return getFilteredContentForFluForChildrenVaccine ( apiContent ) ;
223- case VaccineType . FLU_FOR_SCHOOL_AGED_CHILDREN :
224- return getFilteredContentForFluForSchoolAgedChildrenVaccine ( apiContent ) ;
225- case VaccineType . COVID_19 :
226- const standardVaccineContent = getFilteredContentForStandardVaccine ( apiContent ) ;
227- const additionalCovid19VaccineContent = getAdditionalContentForCovid19Vaccine ( ) ;
228- return {
229- ...standardVaccineContent ,
230- ...additionalCovid19VaccineContent ,
231- } ;
232- default :
233- return getFilteredContentForStandardVaccine ( apiContent ) ;
234- }
214+ const filteredContentBuilders = new Map ( [
215+ [ VaccineType . WHOOPING_COUGH , getFilteredContentForWhoopingCoughVaccine ] ,
216+ [ VaccineType . FLU_IN_PREGNANCY , getFilteredContentForFluInPregnancyVaccine ] ,
217+ [ VaccineType . FLU_FOR_ADULTS , getFilteredContentForFluVaccine ] ,
218+ [ VaccineType . FLU_FOR_CHILDREN , getFilteredContentForFluForChildrenVaccine ] ,
219+ [ VaccineType . FLU_FOR_SCHOOL_AGED_CHILDREN , getFilteredContentForFluForSchoolAgedChildrenVaccine ] ,
220+ [
221+ VaccineType . COVID_19 ,
222+ ( apiContent ) => {
223+ const standardVaccineContent = getFilteredContentForStandardVaccine ( apiContent ) ;
224+ const additionalCovid19VaccineContent = getAdditionalContentForCovid19Vaccine ( ) ;
225+ return { ...standardVaccineContent , ...additionalCovid19VaccineContent } ;
226+ } ,
227+ ] ,
228+ ] ) ;
229+ const filteredContentBuilder = filteredContentBuilders . get ( vaccineType ) || getFilteredContentForStandardVaccine ;
230+ return filteredContentBuilder ( apiContent ) ;
235231} ;
236232
237233const getFilteredContentForStandardVaccine = ( apiContent : string ) : VaccinePageContent => {
0 commit comments