/* ============================================================= CoreIQ Office — Store setup (onboarding) The front door for a new site: confirm the organisation's trading name / legal name / ABN, the site's address + registration numbers (PBS approval, AHPRA), seed the built-in RBAC roles, and manage operators. Everything writes to the real tenant rows and flows to the tills via PowerSync. PINs are never handled here — an operator's PIN is established on the till itself. ============================================================= */ const { useState: suUseState, useEffect: suUseEffect } = React; function SetupField({ label, value, onChange, placeholder, required, type }) { return ( ); } function StoreSetupScreen() { const [state, setState] = suUseState(null); const [err, setErr] = suUseState(null); const [busy, setBusy] = suUseState(false); const [savedMsg, setSavedMsg] = suUseState(null); // Drafts (uncontrolled by server state until Save). const [orgDraft, setOrgDraft] = suUseState(null); const [siteDraft, setSiteDraft] = suUseState(null); const [opDraft, setOpDraft] = suUseState({ firstName: "", lastName: "", email: "", loginCode: "", roleId: "" }); const load = () => window.OfficeAPI.getOnboarding() .then((d) => { setState(d); setOrgDraft({ ...d.organisation }); setSiteDraft(d.sites[0] ? { ...d.sites[0] } : null); setErr(null); }) .catch((e) => setErr(String(e.message || e))); suUseEffect(() => { load(); }, []); const flash = (msg) => { setSavedMsg(msg); setTimeout(() => setSavedMsg(null), 2500); }; const run = (p, done) => { setBusy(true); p.then((d) => { if (d && d.onboarding) { setState(d.onboarding); setOrgDraft({ ...d.onboarding.organisation }); setSiteDraft(d.onboarding.sites[0] ? { ...d.onboarding.sites[0] } : null); } setErr(null); setBusy(false); if (done) done(d); }).catch((e) => { setErr(String(e.message || e)); setBusy(false); }); }; if (err && !state) return
No roles yet. Seed the standard set (Owner, Manager, Pharmacist, Cashier) — they can be tuned later.
Operators sync to the tills. A PIN is set on the till at first sign-in — it is never entered here.
{state.operators.length > 0 ? (| Name | Login code | Role | Status | ||
|---|---|---|---|---|---|
| {o.displayName || `${o.firstName} ${o.lastName}`} | {o.loginCode || "—"} | {o.email || "—"} | {o.isActive ? "Active" : "Inactive"} |
No operators yet.
)}Seed roles first, then add operators.
: null}