// health/HealthKit.jsx // HealthKit permission flow & ongoing management UI. // // Three screens here: // 1. HealthKitIntro — pre-permission explainer. Shown once on first // launch (or after Settings → "Connect Apple Health"). // Bedtime gradient hero + 4 category rows + CTA. // 2. HealthKitSheet — the system sheet itself (Apple-owned). We mock it // so the prototype reads end-to-end. // 3. HealthKitManage — long-lived settings screen. Per-category state, // background-sync toggle, last sync, retry, sign out. // // Also exports HealthPartial — overview with a partial-permission banner. // ───────────────────────────────────────────────────────────── // 1. INTRO — explainer before the system prompt // ───────────────────────────────────────────────────────────── function HealthKitIntro({ dark = false }) { const cats = [ { ic: 'moon', c: 'var(--io-sleep)', t: 'Sleep', b: 'Asleep, in bed, sleep stages, time in bed' }, { ic: 'heart', c: 'var(--io-heart)', t: 'Heart', b: 'Resting, walking and active heart rate' }, { ic: 'activity', c: 'var(--io-activity)', t: 'Activity', b: 'Steps, distance, exercise and stand minutes' }, { ic: 'brain', c: 'var(--io-indigo)', t: 'Mindfulness',b: 'Mindful minutes — used in cognitive forecast' }, ]; return ( {/* gradient header — half-bleed at top */}
{/* tiny stars layer */}
{/* Health glyph in a soft halo */}
Connect Apple Health
Your body, on the same page.
Ordentus reads sleep, heart rate, activity and mindfulness from Apple Health and syncs them to your server in the background.
{/* category list */}
What we read
{cats.map((r, i) => (
{r.t}
{r.b}
))}
{/* footer assurances */}
Ordentus never writes back to Apple Health. Data is sent only to your own server — the one you signed into.
{/* CTAs */}
); } window.HealthKitIntro = HealthKitIntro; // ───────────────────────────────────────────────────────────── // 2. SYSTEM SHEET — Apple-owned. We mock it for the prototype only, // so the flow reads end-to-end. // ───────────────────────────────────────────────────────────── function HealthKitSheet({ dark = false }) { const cats = [ { name: 'Sleep Analysis', state: 'allow' }, { name: 'Heart Rate', state: 'allow' }, { name: 'Resting Heart Rate', state: 'allow' }, { name: 'Steps', state: 'allow' }, { name: 'Distance Walking + Running', state: 'allow' }, { name: 'Mindful Minutes', state: 'allow' }, { name: 'Active Energy', state: 'allow' }, ]; // dimmed parent return (
Sunday · Mar 16
} trailing={<>} />
{/* iOS Health permission sheet — full sheet, white in light, dark grouped in dark */}
{/* Header — Cancel · Health · ... */}
Cancel
Health Access
{/* Intro card */}
Ordentus
would like to access your Health data
Turn On All
Turn on all categories
Allow "Ordentus" to read
{cats.map((r, i) => (
{r.name}
))}
{/* Bottom action */}
); } window.HealthKitSheet = HealthKitSheet; // ───────────────────────────────────────────────────────────── // 3. MANAGE — long-lived settings screen // ───────────────────────────────────────────────────────────── function HealthKitManage({ dark = false, partial = false }) { const cats = partial ? [ { ic: 'moon', c: 'var(--io-sleep)', t: 'Sleep', s: 'Reading', on: true, detail: 'Last sample 5:06 AM' }, { ic: 'heart', c: 'var(--io-heart)', t: 'Heart rate', s: 'Reading', on: true, detail: 'Last sample 9:14 AM' }, { ic: 'activity', c: 'var(--io-activity)', t: 'Activity', s: 'Not granted', on: false, detail: 'Steps and exercise unavailable' }, { ic: 'brain', c: 'var(--io-indigo)', t: 'Mindfulness', s: 'Reading', on: true, detail: 'Last sample yesterday 7:30 PM' }, ] : [ { ic: 'moon', c: 'var(--io-sleep)', t: 'Sleep', s: 'Reading', on: true, detail: 'Last sample 5:06 AM' }, { ic: 'heart', c: 'var(--io-heart)', t: 'Heart rate', s: 'Reading', on: true, detail: 'Last sample 9:14 AM' }, { ic: 'activity', c: 'var(--io-activity)', t: 'Activity', s: 'Reading', on: true, detail: 'Last sample 8:32 AM' }, { ic: 'brain', c: 'var(--io-indigo)', t: 'Mindfulness', s: 'Reading', on: true, detail: 'Last sample yesterday 7:30 PM' }, ]; return ( {/* Hero status */}
{partial ? 'Some categories aren\'t shared' : 'Syncing in the background'}
{partial ? 'Open Apple Health to share the missing categories with Ordentus.' : 'Last sync 14 minutes ago · 1,284 samples in the last 24h.'}
{cats.map((r, i) => (
{r.t}
{r.s} · {r.detail}
{r.on ?
: Open Health }
))}
Live sync
Cellular sync
Server
portal.l.workers.dev
Last sync
14 min ago · 1,284 samples
Ordentus reads from Apple Health and writes to your own server only. Permissions can also be changed anytime in Settings → Health → Data Access & Devices → Ordentus.
); } window.HealthKitManage = HealthKitManage; // ───────────────────────────────────────────────────────────── // 4. PARTIAL — Overview with a permission banner // ───────────────────────────────────────────────────────────── function HealthKitPartial({ dark = false }) { return (
Activity not shared
Steps and exercise are missing from Apple Health.
} /> ); } window.HealthKitPartial = HealthKitPartial;