Skip to content

Commit

Permalink
Fix wrong icons
Browse files Browse the repository at this point in the history
  • Loading branch information
osamasayed committed Jan 1, 2025
1 parent 076d95f commit af92c08
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/utils/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,55 +112,58 @@ export const getSearchNavigationResult = (
result: SearchNavigationResult,
t: Translate,
locale: string,
): SearchNavigationResult & { name: string } => {
const { key, resultType } = result;
): SearchNavigationResult => {
const { key, isArabic, isTransliteration } = result;
const resultType = getResultType(result);
const resultSuffix = getResultSuffix(resultType, key as string, locale, chaptersData);
let returnedResult = null;
let returnedResult = {
isTransliteration,
isArabic,
resultType,
key,
} as SearchNavigationResult;

if (resultType === SearchNavigationType.JUZ) {
const juzNumber = idToJuzNumber(key as string);

returnedResult = {
...returnedResult,
name: `${t('common:juz')} ${toLocalizedNumber(Number(juzNumber), locale)}`,
key: juzNumber,
resultType: SearchNavigationType.JUZ,
};
}

if (resultType === SearchNavigationType.PAGE) {
const pageNumber = idToPageNumber(key as string);

returnedResult = {
...returnedResult,
name: `${t('common:page')} ${toLocalizedNumber(Number(pageNumber), locale)}`,
key: pageNumber,
resultType: SearchNavigationType.PAGE,
};
}

if (resultType === SearchNavigationType.RUB_EL_HIZB) {
returnedResult = {
...returnedResult,
name: `${t('common:rub')} ${toLocalizedNumber(Number(key), locale)}`,
key,
resultType: SearchNavigationType.RUB_EL_HIZB,
};
}

if (resultType === SearchNavigationType.HIZB) {
returnedResult = {
...returnedResult,
name: `${t('common:hizb')} ${toLocalizedNumber(Number(key), locale)}`,
key,
resultType: SearchNavigationType.HIZB,
};
}

if (resultType === SearchNavigationType.RANGE) {
const { surah, from, to } = getVerseNumberRangeFromKey(key as string);
returnedResult = {
...returnedResult,
name: `${t('common:surah')} ${
getChapterData(chaptersData, `${surah}`).transliteratedName
} ${t('common:ayah')} ${toLocalizedNumber(from, locale)} - ${toLocalizedNumber(to, locale)}`,
key,
resultType: SearchNavigationType.RANGE,
};
}

Expand All @@ -170,19 +173,17 @@ export const getSearchNavigationResult = (
resultType === SearchNavigationType.TRANSLATION
) {
returnedResult = {
...returnedResult,
name: result.name,
key,
resultType,
};
}

if (resultType === SearchNavigationType.SURAH) {
returnedResult = {
...returnedResult,
name: `${t('common:surah')} ${
getChapterData(chaptersData, key as string).transliteratedName
}`,
key,
resultType: SearchNavigationType.SURAH,
};
}

Expand Down

0 comments on commit af92c08

Please sign in to comment.