// Game services: Game Center (App Store) and Play Games Services (Google Play) side by side, from `games status --json` // (cli/games-status.ts): enabled, App ID capability, entitlement / APP_ID resource, ids, leaderboard and achievement // counts on the store vs the config, pending changes and findings. The sync buttons are the confirm-token writes // (dry run -> native dialog -> apply) of `apple game-center` and `play games`; the PGS setup is a console plan. import type { Project } from '../api'; import { t } from '../i18n'; import { useRead, useWrite } from '../store'; import { ConsolePlanButton } from './ConsolePlan'; import { StoreGlyph } from './icons'; import { Card, Chip, ErrorNotice, Skeleton } from './kit'; import { OpenLink } from './OpenLink'; import { WriteButton } from './WriteButton'; interface Finding { store: 'apple' | 'play'; level: 'error' | 'warn' | 'ok'; id: string; msg: string; fix?: string } interface Counts { leaderboards: number; achievements: number } export interface GameServicesStatus { apple: null | { capability: boolean | null; enabled: boolean; version: string | null; versionEnabled: boolean | null; config: Counts; changes: string[]; error?: string } & Counts; play: null | { appId: string | null; resource: string | null; config: Counts; changes: string[]; error?: string } & Counts; findings: Finding[]; links: { label: string; url: string }[]; } const tone = (l: Finding['level']) => (l === 'error' ? 'bad' : l === 'warn' ? 'warn' : 'ok'); const yesNo = (v: boolean | null | undefined) => (v === null || v === undefined ? {t('gs.unknown')} : {v ? t('gs.yes') : t('gs.no')}); export function GameServicesCard({ project }: { project: Project }) { const r = useRead(project.id, 'games.status', { network: true, title: t('gs.title') }); const w = useWrite(project.id); if (!r.data) return r.error ? : ; const s = r.data; if (!s.apple && !s.play && !s.findings.length) return null; const f = (store: 'apple' | 'play') => s.findings.filter(x => x.store === store); const count = (have: Counts, want: Counts) => t('gs.counts', { lb: have.leaderboards, lbWant: want.leaderboards, ach: have.achievements, achWant: want.achievements }); return (
{s.apple && (
{t('gs.gameCenter')}
{s.apple.error ? {s.apple.error} : (
{t('gs.enabled')}
{yesNo(s.apple.enabled)}
{t('gs.capability')}
{yesNo(s.apple.capability)}
{t('gs.version', { v: s.apple.version ?? '-' })}
{yesNo(s.apple.versionEnabled)}
{t('gs.items')}
{count(s.apple, s.apple.config)}
)} {f('apple').map(x => {x.msg})} {!!s.apple.changes.length && {t('gs.pending', { n: s.apple.changes.length })}: {s.apple.changes.slice(0, 4).join('; ')}}
{t('gs.syncApple')}
)} {s.play && (
{t('gs.playGames')}
{t('gs.projectId')}
{s.play.appId ? {s.play.appId} : {t('gs.notSet')}}
{t('gs.resource')}
{s.play.resource ? {s.play.resource} : {t('gs.notSet')}}
{!s.play.error && <>
{t('gs.items')}
{count(s.play, s.play.config)}
}
{s.play.error && {s.play.error}} {f('play').map(x => {x.msg})} {!!s.play.changes.length && {t('gs.pending', { n: s.play.changes.length })}: {s.play.changes.slice(0, 4).join('; ')}}
{t('gs.syncPlay')}
)}
{!!s.links.length &&
{s.links.map(l => {l.label})}
}
); }