mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add episodes count on the front
This commit is contained in:
parent
bb456738f0
commit
c621c45695
@ -44,6 +44,10 @@ export const SeasonP = ResourceP.merge(ImagesP).extend({
|
||||
* The ending date of this season.
|
||||
*/
|
||||
endDate: zdate().nullable(),
|
||||
/**
|
||||
* The number of episodes available on kyoo of this season.
|
||||
*/
|
||||
episodesCount: z.number(),
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -35,18 +35,18 @@ import { useTranslation } from "react-i18next";
|
||||
import { ComponentType } from "react";
|
||||
import MenuIcon from "@material-symbols/svg-400/rounded/menu-fill.svg";
|
||||
|
||||
type SeasonProcessed = Season & { href: string };
|
||||
|
||||
export const SeasonHeader = ({
|
||||
isLoading,
|
||||
seasonNumber,
|
||||
name,
|
||||
seasons,
|
||||
slug,
|
||||
}: {
|
||||
isLoading: boolean;
|
||||
seasonNumber?: number;
|
||||
name?: string;
|
||||
seasons?: Season[];
|
||||
slug: string;
|
||||
seasons?: SeasonProcessed[];
|
||||
}) => {
|
||||
const { css } = useYoshiki();
|
||||
const { t } = useTranslation();
|
||||
@ -75,8 +75,8 @@ export const SeasonHeader = ({
|
||||
{seasons?.map((x) => (
|
||||
<Menu.Item
|
||||
key={x.seasonNumber}
|
||||
label={`${x.seasonNumber}: ${x.name}`}
|
||||
href={`/show/${slug}?season=${x.seasonNumber}`}
|
||||
label={`${x.seasonNumber}: ${x.name} (${x.episodesCount})`}
|
||||
href={x.href}
|
||||
/>
|
||||
))}
|
||||
</Menu>
|
||||
@ -86,14 +86,21 @@ export const SeasonHeader = ({
|
||||
);
|
||||
};
|
||||
|
||||
SeasonHeader.query = (slug: string): QueryIdentifier<Season> => ({
|
||||
SeasonHeader.query = (slug: string): QueryIdentifier<Season, SeasonProcessed> => ({
|
||||
parser: SeasonP,
|
||||
path: ["shows", slug, "seasons"],
|
||||
params: {
|
||||
// Fetch all seasons at one, there won't be hundred of thems anyways.
|
||||
limit: 0,
|
||||
},
|
||||
infinite: true,
|
||||
infinite: {
|
||||
value: true,
|
||||
map: (seasons) =>
|
||||
seasons.reduce((acc, x) => {
|
||||
if (x.episodesCount == 0) return acc;
|
||||
return [...acc, { ...x, range: null, href: `/show/${slug}?season=${x.seasonNumber}` }];
|
||||
}, [] as SeasonProcessed[]),
|
||||
},
|
||||
});
|
||||
|
||||
export const EpisodeList = <Props,>({
|
||||
@ -135,7 +142,6 @@ export const EpisodeList = <Props,>({
|
||||
name={sea?.name}
|
||||
seasonNumber={sea?.seasonNumber}
|
||||
seasons={seasons}
|
||||
slug={slug}
|
||||
/>
|
||||
)}
|
||||
<EpisodeLine
|
||||
|
Loading…
x
Reference in New Issue
Block a user