From a80e065cdb0634ba1f940ddb12fb3695cf42d841 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Wed, 14 Aug 2024 08:13:14 +0200 Subject: [PATCH] fix: formatting of specials season number --- components/ItemCardText.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/components/ItemCardText.tsx b/components/ItemCardText.tsx index f089ab72..3096a907 100644 --- a/components/ItemCardText.tsx +++ b/components/ItemCardText.tsx @@ -7,6 +7,17 @@ type ItemCardProps = { item: BaseItemDto; }; +function seasonNameToIndex(seasonName: string | null | undefined) { + if (!seasonName) return -1; + if (seasonName.startsWith("Season")) { + return parseInt(seasonName.replace("Season ", "")); + } + if (seasonName.startsWith("Specials")) { + return 0; + } + return -1; +} + export const ItemCardText: React.FC = ({ item }) => { return ( @@ -17,9 +28,8 @@ export const ItemCardText: React.FC = ({ item }) => { style={{ flexWrap: "wrap" }} className="flex text-xs opacity-50 break-all" > - {`S${item.SeasonName?.replace( - "Season ", - "" + {`S${seasonNameToIndex( + item?.SeasonName, )}:E${item.IndexNumber?.toString()}`}{" "} {item.Name}