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AAA,QAAyB7B,OAAO2B,EAAE1B,QAEjFG,EACGqB,QACAC,MACC,SAACC,EAAGC,G,OACFC,EAAAA,EAAAA,QAAyB7B,OAAO2B,EAAE1B,KAAO4B,EAAAA,EAAAA,QAAyB7B,OAAO4B,EAAE3B,UAEvF,CAACE,EAAcC,IAGjB,OACE,qB,SACGmB,EAAgCO,KAAI,SAACrC,EAASsC,G,OAC7C,SAACC,MAAG,CACFC,KAAK,SACLC,SAAU,EACVC,UAAWC,IAAAA,iBAEXC,QAAS,W,OAAMtB,EAAetB,EAAQQ,KACtCqC,WAAY,W,OAAMvB,EAAetB,EAAQQ,K,UAEzC,SAACsC,EAAAA,EAAe,CACdC,UAAWxC,OAAOP,EAAQQ,IAC1BwC,YAAajD,EAAsBC,EAASC,GAC5CgD,UAAW,GAA8B,OAA3BjD,EAAQkD,oBACtBC,YACEzC,EACI0C,EAAAA,GAAuB7C,OAAO+B,GAC9B/B,OAAO+B,EAAuB,GAEpCe,oBAAqBlD,EAAuBH,EAASC,EAAGG,GACxDkD,iBAAiB,EACjBpC,UAAWA,GAAaE,IAAmBpB,EAAQQ,MAfhDR,EAAQQ","sources":["webpack://_N_E/./src/components/chapters/RevelationOrderView.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/control-has-associated-label */\nimport { useMemo, useState } from 'react';\n\nimport { useRouter } from 'next/router';\nimport { Translate } from 'next-translate';\nimport useTranslation from 'next-translate/useTranslation';\n\nimport styles from './ChapterAndJuzList.module.scss';\n\nimport SurahPreviewRow from '@/dls/SurahPreview/SurahPreviewRow';\nimport usePersistPreferenceGroup from '@/hooks/auth/usePersistPreferenceGroup';\nimport { setIsReadingByRevelationOrder } from '@/redux/slices/revelationOrder';\nimport PreferenceGroup from '@/types/auth/PreferenceGroup';\nimport Chapter from '@/types/Chapter';\nimport { isLoggedIn } from '@/utils/auth/login';\nimport { QURAN_CHAPTERS_COUNT } from '@/utils/chapter';\nimport { logButtonClick } from '@/utils/eventLogger';\nimport { shouldUseMinimalLayout, toLocalizedNumber } from '@/utils/locale';\nimport { getSurahNavigationUrl } from '@/utils/navigation';\nimport REVELATION_ORDER from '@/utils/revelationOrder';\n\nconst MECCAN_SURAH_STRING_IDENTIFIER = 'makkah'; // the value is coming from the backend, ideally we would've set it up as an enum, but other pieces of the code are relying on this as a string, so we'll keep it as a string for now.\ntype RevelationOrderViewProps = {\n isDescending: boolean;\n chapters: Chapter[];\n};\n\nconst RevelationOrderView = ({ isDescending, chapters }: RevelationOrderViewProps) => {\n const { t, lang } = useTranslation();\n const router = useRouter();\n const {\n actions: { onSettingsChange },\n isLoading,\n } = usePersistPreferenceGroup();\n const [clickedSurahId, setClickedSurahId] = useState(null);\n\n const onSurahClicked = (surahId: string | number) => {\n if (isLoggedIn()) {\n setClickedSurahId(surahId);\n onSettingsChange(\n 'isReadingByRevelationOrder',\n true,\n setIsReadingByRevelationOrder(true),\n setIsReadingByRevelationOrder(false),\n PreferenceGroup.READING,\n () => {\n // navigate to the selected Surah on success\n router.push(getSurahNavigationUrl(surahId));\n },\n );\n } else {\n setIsReadingByRevelationOrder(true);\n router.push(getSurahNavigationUrl(surahId));\n }\n logButtonClick('revelation_ordering_surah');\n };\n\n const sortedChaptersByRevelationOrder = useMemo(\n () =>\n isDescending\n ? chapters\n .slice()\n .sort(\n (a, b) =>\n REVELATION_ORDER.indexOf(Number(b.id)) - REVELATION_ORDER.indexOf(Number(a.id)),\n )\n : chapters\n .slice()\n .sort(\n (a, b) =>\n REVELATION_ORDER.indexOf(Number(a.id)) - REVELATION_ORDER.indexOf(Number(b.id)),\n ),\n [isDescending, chapters],\n );\n\n return (\n <>\n {sortedChaptersByRevelationOrder.map((chapter, revelationOrderIndex) => (\n <div\n role=\"button\"\n tabIndex={0}\n className={styles.chapterContainer}\n key={chapter.id}\n onClick={() => onSurahClicked(chapter.id)}\n onKeyPress={() => onSurahClicked(chapter.id)}\n >\n <SurahPreviewRow\n chapterId={Number(chapter.id)}\n description={getChapterDescription(chapter, t)}\n surahName={`${chapter.transliteratedName}`}\n surahNumber={\n isDescending\n ? QURAN_CHAPTERS_COUNT - Number(revelationOrderIndex)\n : Number(revelationOrderIndex + 1)\n } // Show the number based on the revelation order instead of the surah number.\n translatedSurahName={getTranslatedSurahName(chapter, t, lang)}\n isMinimalLayout={false}\n isLoading={isLoading && clickedSurahId === chapter.id}\n />\n </div>\n ))}\n </>\n );\n};\n\nconst getChapterDescription = (chapter: Chapter, t: Translate) => {\n if (chapter.revelationPlace === MECCAN_SURAH_STRING_IDENTIFIER) {\n return t('common:meccan');\n }\n\n return t('common:medinan');\n};\n\nconst getTranslatedSurahName = (chapter: Chapter, t: Translate, lang: string) => {\n if (shouldUseMinimalLayout(lang)) {\n return `${t('common:surah')} ${toLocalizedNumber(Number(chapter.id), lang)}`;\n }\n return `${toLocalizedNumber(Number(chapter.id), lang)}: ${chapter.translatedName as string}`;\n};\n\nexport default RevelationOrderView;\n"],"names":["getChapterDescription","chapter","t","revelationPlace","getTranslatedSurahName","lang","shouldUseMinimalLayout","toLocalizedNumber","Number","id","translatedName","isDescending","chapters","useTranslation","router","useRouter","usePersistPreferenceGroup","actions","onSettingsChange","isLoading","useState","clickedSurahId","setClickedSurahId","onSurahClicked","surahId","isLoggedIn","setIsReadingByRevelationOrder","PreferenceGroup","push","getSurahNavigationUrl","logButtonClick","sortedChaptersByRevelationOrder","useMemo","slice","sort","a","b","REVELATION_ORDER","map","revelationOrderIndex","div","role","tabIndex","className","styles","onClick","onKeyPress","SurahPreviewRow","chapterId","description","surahName","transliteratedName","surahNumber","QURAN_CHAPTERS_COUNT","translatedSurahName","isMinimalLayout"],"sourceRoot":""}