// The header of one app section (docs IA): the section's name, one line on what it is for, the single next step // derived from state that is already read (lib/sections.ts), and the sub views as a segmented control (only when the // section has more than one). import type { ListingsResult, StoreRelease } from '../api'; import { t } from '../i18n'; import type { UnifiedApp } from '../lib/identity'; import type { Attention } from '../lib/model'; import { sectionNext } from '../lib/sections'; import { type AppSection, type AppTab, SECTION_ICON, SECTION_KEY, TAB_ICON, TAB_KEY } from '../nav'; import { useCachedRead, useData } from '../store'; import type { GameServicesStatus } from '../ui/GameServicesCard'; import { Icon } from '../ui/icons'; const PURPOSE: Record = { release: 'sec.release.for', store: 'sec.store.for', revenue: 'sec.revenue.for', players: 'sec.players.for', health: 'sec.health.for', }; export function SectionHead({ app, section, tab, subs, att, all, next, unsaved, editCount, onTab }: { app: UnifiedApp; section: AppSection; tab: AppTab; subs: AppTab[]; att: Attention[]; all: StoreRelease[]; next: string | null; unsaved: number; editCount: (t: AppTab) => number; onTab: (t: AppTab) => void; }) { const d = useData(); const e = d.statusFor(app); const pid = app.project && !app.project.missing ? app.project.id : null; // cached reads only: the header never starts a store call const listings = useCachedRead(section === 'store' ? pid : null, 'project.listings'); const reviews = useCachedRead<{ reply?: unknown }[]>(section === 'players' ? app.target : null, 'reviews.list', { days: 30 }); const games = useCachedRead(section === 'players' && subs.includes('games') ? pid : null, 'games.status'); const validate = useCachedRead<{ findings?: { level: string }[] }>(section === 'health' || section === 'release' ? pid : null, 'validate'); const n = sectionNext(section, { project: !!app.project, att, all, next, summary: e?.summary ?? null, catalog: (d.liveFor(app) ?? e)?.catalog ?? null, unsaved, listings, reviews: Array.isArray(reviews) ? reviews : null, readiness: validate?.findings ? validate.findings.filter(f => f.level === 'blocker').length : null, games: games ? { changes: (games.apple?.changes.length ?? 0) + (games.play?.changes.length ?? 0), blockers: games.findings.filter(f => f.level === 'error').length, apiOff: !!games.playApiDisabled } : null, }); return (

{t(SECTION_KEY[section])}

{t(PURPOSE[section])}

{n.text} {n.tab && n.tab !== tab && }
{subs.length > 1 && (
{subs.map(x => { const c = editCount(x); return ( ); })}
)}
); }