From aeccc994aa2798f41a2b8fe2770ea296dffa63cf Mon Sep 17 00:00:00 2001 From: amirhossein-haerian Date: Mon, 24 Jun 2024 09:18:30 +0200 Subject: [PATCH] fix(KUI-1196): change ternary conditional statement to normal conditional state using function --- public/js/app/components/statistics/AnalysesSummary.jsx | 7 ++++++- public/js/app/components/statistics/MemosSummary.jsx | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/public/js/app/components/statistics/AnalysesSummary.jsx b/public/js/app/components/statistics/AnalysesSummary.jsx index 2e989966..09cdba70 100644 --- a/public/js/app/components/statistics/AnalysesSummary.jsx +++ b/public/js/app/components/statistics/AnalysesSummary.jsx @@ -36,12 +36,17 @@ function Captions({ school, year, seasons }) { }, } = useLanguage() + function getSchoolName(schoolName) { + if (schoolName === 'allSchools') return statisticsLabels[schoolName] + return schoolName + } + const seasonsStr = seasons.map(season => seasonLib.labelSeason(season, languageIndex)).join(', ') return ( - {`: ${school === 'allSchools' ? statisticsLabels[school] : school}`} + {`: ${getSchoolName(school)}`} diff --git a/public/js/app/components/statistics/MemosSummary.jsx b/public/js/app/components/statistics/MemosSummary.jsx index ad10b8fb..166ea51e 100644 --- a/public/js/app/components/statistics/MemosSummary.jsx +++ b/public/js/app/components/statistics/MemosSummary.jsx @@ -69,6 +69,11 @@ function Captions({ school, year, periods }) { languageIndex, } = useLanguage() + function getSchoolName(schoolName) { + if (schoolName === 'allSchools') return statisticsLabels[schoolName] + return schoolName + } + const periodsLabels = periods.map(period => periodsLib.labelPeriod(period, languageIndex, false)) const uniqquePeriodsLabels = [...new Set(periodsLabels)] const periodsStr = uniqquePeriodsLabels.join(', ') @@ -76,7 +81,7 @@ function Captions({ school, year, periods }) { - {`: ${school === 'allSchools' ? statisticsLabels[school] : school}`} + {`: ${getSchoolName(school)}`}