// Lalaluxe booking — booking/screens/who.jsx
// Page: "who" — nails, toes, or both. Nails and toes are two cards, each turned on or off on its
// own; with both on the booking is "both", so there is no third card to explain. A card is its
// name, its tagline and its check, and nothing is drawn on it; a photo the studio adds for that
// visit type (content.whoTiles.*.img) is shown above the name.
// One screen per file. Load before app.jsx (see docs/architecture.md, "The no-build multi-file Babel contract").
function WhoStep({ cfg, s, set }) {
	const nails = s.who === "nails" || s.who === "both";
	const toes = s.who === "toes" || s.who === "both";
	const pick = (n, t) => set({ who: n && t ? "both" : n ? "nails" : t ? "toes" : null });
	// a card missing from the config is drawn empty rather than taking the page down (the server gives it back)
	const nailsTile = cfg.content.whoTiles?.nails || {}, toesTile = cfg.content.whoTiles?.toes || {};
	return (
		<div className="screen">
			<ScreenHead cfg={cfg} screen="who">
				What Are You Booking <em>Today?</em>
			</ScreenHead>

			<div className="body">
				<div className="who-grid">
					<button className={"who-tile " + (nails ? "sel" : "")} aria-pressed={nails} onClick={() => pick(!nails, toes)}>
						{nailsTile.img && <span className="who-art"><img className="nail-photo" src={mediaUrl(nailsTile.img)} alt="" /></span>}
						<span className="who-copy">
							<span className="who-name">{nailsTile.name}</span>
							<span className="who-check" aria-hidden="true">{nails && <Ico name="check" />}</span>
						</span>
						{nailsTile.sub && <span className="who-sub">{nailsTile.sub}</span>}
					</button>
					<button className={"who-tile " + (toes ? "sel" : "")} aria-pressed={toes} onClick={() => pick(nails, !toes)}>
						{toesTile.img && <span className="who-art"><img className="toe-photo" src={mediaUrl(toesTile.img)} alt="" /></span>}
						<span className="who-copy">
							<span className="who-name">{toesTile.name}</span>
							<span className="who-check" aria-hidden="true">{toes && <Ico name="check" />}</span>
						</span>
						{toesTile.sub && <span className="who-sub">{toesTile.sub}</span>}
					</button>
				</div>
			</div>
		</div>
	);
}
