// One app across both stores: header (icon, studio, ids, store state, pairing), then the tabs. A store-only app (no // app folder) shows its store reads (releases, health, reviews, TestFlight) read-only, with "Link a folder" and // "Start an app folder here" to make it a full app. import { type KeyboardEvent, useRef, useState } from 'react'; import { api, errorText } from '../api'; import { type Key, t } from '../i18n'; import { pairCandidates, type UnifiedApp, withIgnored, withLink, withPair, withStudio, withUnpair } from '../lib/identity'; import { storeNow } from '../lib/model'; import { type AppTab, TAB_ICON, TAB_KEY, tabsFor, useNav } from '../nav'; import { useData } from '../store'; import { Icon } from '../ui/icons'; import { AppIcon, Chip, Notice, PhaseChip, StoreBadge, StoreOnlyTag, StudioMark } from '../ui/kit'; import { CatalogTab } from './tabs/Catalog'; import { ChecksTab } from './tabs/Checks'; import { HealthTab } from './tabs/Health'; import { ListingsTab } from './tabs/Listings'; import { ReleasesTab } from './tabs/Releases'; import { ReviewsTab } from './tabs/Reviews'; import { TestFlightTab } from './tabs/TestFlight'; export const ascUrl = (appId: string | null | undefined): string => (appId ? `https://appstoreconnect.apple.com/apps/${encodeURIComponent(appId)}/distribution` : 'https://appstoreconnect.apple.com/apps'); export const PLAY_CONSOLE = 'https://play.google.com/console/'; const PAIRING: Record = { folder: 'pair.folder', manual: 'pair.manual', id: 'pair.id', close: 'pair.close', name: 'pair.name', single: 'pair.single' }; /** Pairing, studio and ignore controls of one app. */ function AppControls({ app }: { app: UnifiedApp }) { const d = useData(); const nav = useNav(); const cands = pairCandidates(app, d.apps); const canUnpair = !app.project && !!app.ios && !!app.android; return (
{t(PAIRING[app.pairing])} {cands.length > 0 && ( )} {canUnpair && }
); } function StoreOnlyBanner({ app }: { app: UnifiedApp }) { const d = useData(); const [busy, setBusy] = useState(false); const [profile, setProfile] = useState<'app' | 'game' | 'subscription-app'>('app'); const link = async (init: boolean) => { setBusy(true); try { const p = init ? await api.initProject(profile) : await api.addProject(); if (p) { await d.updateOverrides(o => withLink(o, app, p.id)); await d.reload(); d.toast({ kind: 'ok', title: t('app.linked', { name: p.name }), detail: init ? t('folders.startedDetail') : undefined }); } } catch (e) { d.toast({ kind: 'bad', title: t('app.linkFailed'), detail: errorText(e) }); } finally { setBusy(false); } }; return ( }> {t('app.storeOnlyTitle')} {t('app.storeOnlyText')} ); } export function AppView({ app, tab }: { app: UnifiedApp; tab: AppTab }) { const d = useData(); const nav = useNav(); const e = d.statusFor(app); const l = d.liveFor(app); const ios = e?.app?.platforms.ios ?? (app.ios ? { bundleId: app.ios.app.bundleId, ascAppId: app.ios.app.id } : null); const android = e?.app?.platforms.android ?? (app.android ? { packageName: app.android.app.id } : null); const name = (app.project && e?.app?.name) || app.name; const tabs = tabsFor(!!app.project); const tabRefs = useRef<(HTMLButtonElement | null)[]>([]); const studio = d.studios.find(s => s.id === app.studio) ?? null; const setTab = (x: AppTab) => nav.go({ screen: 'app', appId: app.key, tab: x }); const onKey = (ev: KeyboardEvent) => { const i = tabs.indexOf(tab); const j = ev.key === 'ArrowRight' ? i + 1 : ev.key === 'ArrowLeft' ? i - 1 : ev.key === 'Home' ? 0 : ev.key === 'End' ? tabs.length - 1 : null; if (j === null) return; ev.preventDefault(); const n = (j + tabs.length) % tabs.length; setTab(tabs[n]!); tabRefs.current[n]?.focus(); }; const all = l?.release.all ?? []; const iosNow = l ? storeNow(all, 'ios').now : null, androidNow = l ? storeNow(all, 'android').now : null; const open = (url: string) => { api.openExternal(url).catch(() => {}); }; return (

{name}

{e?.summary?.profile && app.project && {t(`profile.${e.summary.profile}` as 'profile.app')}} {!app.project && }
{iosNow && <>{iosNow.version}} {androidNow && <>{androidNow.version}}
{ios && } {android && }
{!app.project && }
{tabs.map((x, i) => ( ))}
{tab === 'releases' && } {tab === 'catalog' && app.project && } {tab === 'listings' && app.project && } {tab === 'health' && } {tab === 'reviews' && } {tab === 'testflight' && } {tab === 'checks' && app.project && }
); }