This commit is contained in:
DevOFVictory
2025-10-23 17:58:16 +02:00
parent 52f2e241a7
commit f21f20a4fd
9 changed files with 566 additions and 108 deletions

50
utils/searchMapping.ts Normal file
View File

@@ -0,0 +1,50 @@
import { AutoCompleteItem } from "@/apis/autoCompleteApi";
export const getIconName = (type: AutoCompleteItem["type"]) => {
switch (type) {
case "PERSON":
return "user";
case "SHOW":
return "television";
case "YEAR":
case "CUSTOM":
return "calendar";
default:
return "tag";
}
};
// Helpers that adapt backend searchApi payloads (as in the prompt) to UI types used in our components
export function mapApiPersonToUI(data: any) {
return {
id: data?.id ?? data?.personId,
personId: data?.personId ?? data?.id,
name: data?.name ?? "",
birthDate: data?.birthDate ?? null,
imageUrl: data?.imageUrl ?? null,
};
}
export function mapApiSeasonToUI(data: any) {
return {
seasonId: data?.seasonId ?? data?.id,
showId: data?.showId,
startDate: data?.startDate ?? null,
endDate: data?.endDate ?? null,
seasonNumber: data?.seasonNumber ?? null,
participants: data?.seasonParticipants ?? data?.participants ?? [],
moderators: data?.moderators ?? [],
teams: data?.teams ?? [],
} as any;
}
export function mapApiShowToUI(data: any) {
return {
showId: data?.showId ?? data?.id,
title: data?.title ?? data?.name ?? `Show #${data?.showId ?? data?.id ?? "?"}`,
description: data?.description ?? "",
genre: data?.genre ?? "",
thumbnailUrl: data?.thumbnailUrl ?? data?.imageUrl ?? "",
running: data?.running ?? false,
} as any;
}