import { useState } from 'react' import { api, message } from '../bridge.js' import * as Icon from '../ui/icons.jsx' import logo from '../assets/loyaly-mark.png' // Linking this PC to a shop — the first thing that happens on a new install, // and until now the one thing the app could not do. // // It comes BEFORE sign-in on purpose. The installer standing at a new counter // has an installation code and, quite often, no account of their own yet; the // PC's identity is not a person's identity. The endpoint behind this is // deliberately unauthenticated for the same reason — requiring a login first // would mean shipping a password to every shop that installs the software. export default function Setup({ onDone, onCancel }) { const [code, setCode] = useState('') const [busy, setBusy] = useState(null) const [error, setError] = useState(null) async function submit(e) { e.preventDefault() setBusy('claim'); setError(null) try { onDone(await api.claim(code)) } catch (err) { setError(message(err)) } finally { setBusy(null) } } async function standalone() { setBusy('alone'); setError(null) try { onDone(await api.runStandalone()) } catch (err) { setError(message(err)) } finally { setBusy(null) } } // First launch: a choice, not a code box. Two thirds of the people who // open this have no idea what an installation code is; the other third has // one in their hand. Both must see their own path in the first second. const [path, setPath] = useState(onCancel ? 'code' : null) if (path === null) { return (
This PC will watch your shop’s cameras and recognise returning customers. First, one question: is this shop managed from a head office?
Behavision will run entirely here. Next you’ll add your camera — it can find it on the network for you — and walk past it once so it can prove it works.
{error &&Type the installation code head office gave you. It works once, and this PC becomes that shop.
Don’t have one? Whoever runs head office creates it under the shop: Shops → the shop → Set up a shop PC.