From 43a4a0e6ee6840fd744778ce55fbf6a97da57598 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 29 Oct 2023 21:34:48 +0100 Subject: [PATCH] Fix seasons list when there is no items --- front/packages/models/src/resources/show.ts | 7 +++++-- front/packages/ui/src/details/season.tsx | 22 ++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/front/packages/models/src/resources/show.ts b/front/packages/models/src/resources/show.ts index 4c0cbe979..ee8489160 100644 --- a/front/packages/models/src/resources/show.ts +++ b/front/packages/models/src/resources/show.ts @@ -35,7 +35,8 @@ export enum Status { Planned = "Planned", } -export const ShowP = withImages(ResourceP.extend({ +export const ShowP = withImages( + ResourceP.extend({ /** * The title of this show. */ @@ -84,7 +85,9 @@ export const ShowP = withImages(ResourceP.extend({ * The list of seasons of this show. */ seasons: z.array(SeasonP).optional(), - }), "shows") + }), + "shows", +) .transform((x) => { if (!x.thumbnail && x.poster) { x.thumbnail = { ...x.poster }; diff --git a/front/packages/ui/src/details/season.tsx b/front/packages/ui/src/details/season.tsx index 7e0d276d5..3ee7ba91c 100644 --- a/front/packages/ui/src/details/season.tsx +++ b/front/packages/ui/src/details/season.tsx @@ -72,13 +72,15 @@ export const SeasonHeader = ({ {isLoading ? : name} - {seasons?.map((x) => ( - - ))} + {seasons + ?.filter((x) => x.episodesCount > 0) + .map((x) => ( + + ))}
@@ -96,10 +98,7 @@ SeasonHeader.query = (slug: string): QueryIdentifier => infinite: { value: true, map: (seasons) => - seasons.reduce((acc, x) => { - if (x.episodesCount == 0) return acc; - return [...acc, { ...x, href: `/show/${slug}?season=${x.seasonNumber}` }]; - }, [] as SeasonProcessed[]), + seasons.map((x) => ({ ...x, href: `/show/${slug}?season=${x.seasonNumber}` })), }, }); @@ -134,6 +133,7 @@ export const EpisodeList = ({ const sea = item?.firstOfSeason ? seasons?.find((x) => x.seasonNumber === item.seasonNumber) : null; + console.log(sea, seasons); return ( <> {item.firstOfSeason && (