Refactor ShowDetail component to display loaded seasons: update season counting logic to return an array of loaded seasons, enhance UI to show the number of loaded seasons and their details, and update translations for new season information.
This commit is contained in:
@@ -73,15 +73,15 @@ export function ShowDetail({ showId }: { showId: string }) {
|
||||
|
||||
const selected = candidates.filter((c) => !deselected.has(c.asset.id))
|
||||
|
||||
// Сколько разных сезонов загружено — по распознанным SxxExx в именах серий.
|
||||
const seasonCount = useMemo(() => {
|
||||
if (!show) return 0
|
||||
const seasons = new Set<number>()
|
||||
// Какие сезоны загружены — по распознанным SxxExx в именах серий (отсортированы по возрастанию).
|
||||
const seasons = useMemo(() => {
|
||||
if (!show) return [] as number[]
|
||||
const set = new Set<number>()
|
||||
for (const e of show.episodes) {
|
||||
const se = parseEpisode(e.assetName ?? '')
|
||||
if (se) seasons.add(se.season)
|
||||
if (se) set.add(se.season)
|
||||
}
|
||||
return seasons.size
|
||||
return [...set].sort((a, b) => a - b)
|
||||
}, [show])
|
||||
|
||||
if (isLoading || !show) return <p className="text-muted-foreground">{t('common.loading')}</p>
|
||||
@@ -126,17 +126,24 @@ export function ShowDetail({ showId }: { showId: string }) {
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<h2 className="crt-glow text-xl font-semibold">{show.name}</h2>
|
||||
<Badge variant="muted">{t(`admin.shows.kinds.${show.kind}`)}</Badge>
|
||||
{show.kind === 'Series' && (
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<h2 className="crt-glow text-xl font-semibold">{show.name}</h2>
|
||||
<Badge variant="muted">{t(`admin.shows.kinds.${show.kind}`)}</Badge>
|
||||
{show.kind === 'Series' && (
|
||||
<Badge variant="muted">
|
||||
{t('admin.shows.seasons')}: {seasons.length}
|
||||
</Badge>
|
||||
)}
|
||||
<Badge variant="muted">
|
||||
{t('admin.shows.seasons')}: {seasonCount}
|
||||
{t('admin.shows.episodes')}: {show.episodes.length}
|
||||
</Badge>
|
||||
</div>
|
||||
{show.kind === 'Series' && seasons.length > 0 && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('admin.shows.loadedSeasons')}: {seasons.join(', ')}
|
||||
</p>
|
||||
)}
|
||||
<Badge variant="muted">
|
||||
{t('admin.shows.episodes')}: {show.episodes.length}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
{canAdd && (
|
||||
|
||||
Reference in New Issue
Block a user