updated
This commit is contained in:
@@ -11,6 +11,12 @@ export type PersonHistoryEntry = {
|
||||
showId: number;
|
||||
seasonId: number;
|
||||
seasonNumber: number;
|
||||
partner?: {
|
||||
id: number;
|
||||
name: string;
|
||||
birthDate?: string;
|
||||
imageUri: string | null;
|
||||
} | null;
|
||||
};
|
||||
|
||||
const PERSON_API_BASE = "http://45.157.177.99:8080/persons";
|
||||
@@ -28,11 +34,25 @@ export async function getPersonHistory(
|
||||
console.warn("History expected array, got:", data);
|
||||
return [];
|
||||
}
|
||||
return (data as PersonHistorySeasonRaw[]).map((s) => ({
|
||||
showId: s.show,
|
||||
seasonId: s.seasonId,
|
||||
seasonNumber: s.seasonNumber,
|
||||
}));
|
||||
return (data as PersonHistorySeasonRaw[]).map((season) => {
|
||||
const me = season.seasonParticipants.find(
|
||||
(p) => p.person.personId === personId
|
||||
);
|
||||
let partner: PersonHistoryEntry["partner"] = null;
|
||||
if (me?.partner?.person) {
|
||||
partner = {
|
||||
id: me.partner.person.personId,
|
||||
name: me.partner.person.name,
|
||||
imageUri: me.partner.person.imageUrl ?? null,
|
||||
};
|
||||
}
|
||||
return {
|
||||
showId: season.show,
|
||||
seasonId: season.seasonId,
|
||||
seasonNumber: season.seasonNumber,
|
||||
partner,
|
||||
};
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("getPersonHistory error:", e);
|
||||
return [];
|
||||
|
||||
@@ -58,7 +58,7 @@ export async function getSeason(
|
||||
: undefined,
|
||||
imageUri:
|
||||
p.person.imageUrl ??
|
||||
"https://via.placeholder.com/300x400.png?text=No+Image",
|
||||
`https://i.pravatar.cc/300?img=${Math.random() * 70}`,
|
||||
})
|
||||
);
|
||||
return {
|
||||
|
||||
@@ -52,6 +52,8 @@ export async function getShows(): Promise<Show[]> {
|
||||
concept: s.concept,
|
||||
running: s.running,
|
||||
logoUri: s.logoUrl ?? "",
|
||||
startDate: s.startDate,
|
||||
endDate: s.endDate,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error("Fetch error:", error);
|
||||
|
||||
Reference in New Issue
Block a user