import { ChevronRight, Info } from "lucide-react";
import { Link } from "react-router";
import { useEpisodeMappingPreview } from "~/api/episode-mapping.ts";
import { useEntityDetail } from "~/api/library.ts";
import { consolePath } from "~/components/console/nav.ts";
import { StatusBadge } from "~/components/console/status-badge.tsx";
import { Panel } from "~/components/library/parts.tsx";
import { absoluteGroups, groupMethodsText, mappingHref } from "./model.ts";
// 订阅详情的集数映射摘要 + 订阅表单的绝对集号提示(批次 4)。数据来自模拟预览(不带草稿 = 当前规则)。
/** 订阅的季:有季单元取它的季号,否则不按季过滤 */
function useSubscriptionSeason(entityId: string, seasonUnitId: string | null | undefined): number | null {
const entity = useEntityDetail(seasonUnitId ? entityId : undefined);
if (!seasonUnitId) return null;
return entity.data?.contentUnits.find((u) => u.id === seasonUnitId)?.seasonNumber ?? null;
}
export function SubscriptionMappingSummary({
entityId,
seasonUnitId,
}: {
entityId: string;
seasonUnitId?: string | null;
}) {
const season = useSubscriptionSeason(entityId, seasonUnitId);
const preview = useEpisodeMappingPreview(entityId, season != null ? { season } : {});
const p = preview.data;
if (!p?.applicable || (p.groups.length === 0 && p.seasons.seasons.length === 0)) return null;
const pending = p.groups.reduce((n, g) => n + g.pending, 0);
return (
还没有绑定到这一季的资源。
{p.groups.map((g) => (
) : (