Skip to content

Commit

Permalink
fix search bar results for genres
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedriad1 committed Sep 25, 2024
1 parent 783bb92 commit 5b746c8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/app/_components/navbar/search-bar/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import ComingSoonModal from "@/components/coming-soon-modal";
import type { SearchType } from "@/types/search";
import { CommandEmpty } from "@/components/ui/command";
import type { GenreDocument } from "@/types/genre";

const getHref = (document: GlobalSearchDocument) => {
if (document.type === "book") {
Expand Down Expand Up @@ -61,14 +62,16 @@ export default function SearchBarResults({
const hits = results?.hits ?? [];

const items = hits.map((result) => {
const primaryName =
getPrimaryLocalizedText(result.document.primaryNames, pathLocale) ??
(result.document as any).name;
const names =
result.document.primaryNames ??
(result.document as unknown as GenreDocument).nameTranslations;

const secondaryName = getSecondaryLocalizedText(
result.document.primaryNames,
pathLocale,
);
const primaryName =
pathLocale === "en" &&
(result.document as unknown as GenreDocument).transliteration
? (result.document as unknown as GenreDocument).transliteration
: getPrimaryLocalizedText(names, pathLocale);
const secondaryName = getSecondaryLocalizedText(names, pathLocale);

const finalPrimaryName = primaryName ?? secondaryName;
const finalSecondaryName = primaryName ? secondaryName : null;
Expand Down

0 comments on commit 5b746c8

Please sign in to comment.