mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -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.
|
* The ending date of this season.
|
||||||
*/
|
*/
|
||||||
endDate: zdate().nullable(),
|
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 { ComponentType } from "react";
|
||||||
import MenuIcon from "@material-symbols/svg-400/rounded/menu-fill.svg";
|
import MenuIcon from "@material-symbols/svg-400/rounded/menu-fill.svg";
|
||||||
|
|
||||||
|
type SeasonProcessed = Season & { href: string };
|
||||||
|
|
||||||
export const SeasonHeader = ({
|
export const SeasonHeader = ({
|
||||||
isLoading,
|
isLoading,
|
||||||
seasonNumber,
|
seasonNumber,
|
||||||
name,
|
name,
|
||||||
seasons,
|
seasons,
|
||||||
slug,
|
|
||||||
}: {
|
}: {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
seasonNumber?: number;
|
seasonNumber?: number;
|
||||||
name?: string;
|
name?: string;
|
||||||
seasons?: Season[];
|
seasons?: SeasonProcessed[];
|
||||||
slug: string;
|
|
||||||
}) => {
|
}) => {
|
||||||
const { css } = useYoshiki();
|
const { css } = useYoshiki();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -75,8 +75,8 @@ export const SeasonHeader = ({
|
|||||||
{seasons?.map((x) => (
|
{seasons?.map((x) => (
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
key={x.seasonNumber}
|
key={x.seasonNumber}
|
||||||
label={`${x.seasonNumber}: ${x.name}`}
|
label={`${x.seasonNumber}: ${x.name} (${x.episodesCount})`}
|
||||||
href={`/show/${slug}?season=${x.seasonNumber}`}
|
href={x.href}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Menu>
|
</Menu>
|
||||||
@ -86,14 +86,21 @@ export const SeasonHeader = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
SeasonHeader.query = (slug: string): QueryIdentifier<Season> => ({
|
SeasonHeader.query = (slug: string): QueryIdentifier<Season, SeasonProcessed> => ({
|
||||||
parser: SeasonP,
|
parser: SeasonP,
|
||||||
path: ["shows", slug, "seasons"],
|
path: ["shows", slug, "seasons"],
|
||||||
params: {
|
params: {
|
||||||
// Fetch all seasons at one, there won't be hundred of thems anyways.
|
// Fetch all seasons at one, there won't be hundred of thems anyways.
|
||||||
limit: 0,
|
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,>({
|
export const EpisodeList = <Props,>({
|
||||||
@ -135,7 +142,6 @@ export const EpisodeList = <Props,>({
|
|||||||
name={sea?.name}
|
name={sea?.name}
|
||||||
seasonNumber={sea?.seasonNumber}
|
seasonNumber={sea?.seasonNumber}
|
||||||
seasons={seasons}
|
seasons={seasons}
|
||||||
slug={slug}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<EpisodeLine
|
<EpisodeLine
|
||||||
|
Loading…
x
Reference in New Issue
Block a user