// Lalaluxe booking — booking/screens/subdone.jsx
// Page: "subdone", what she sees once a visit on her plan is booked (nothing to pay: it was prepaid).
// One screen per file. Load before app.jsx.
function SubDoneStep({ cfg, s, reset }) {
	const r = s.subResult || {};
	const day = s.date
		? parseYmd(s.date).toLocaleDateString(undefined, { weekday: "long" })
		: null;
	return (
		<div className="screen">
			<ScreenHead
				cfg={cfg} screen="subdone" after={<span className="done-mark" aria-hidden="true"><DoneMark /></span>}
				sub={day
					? `See you ${day}. Nothing more to pay today.`
					: "Your plan visit is confirmed. Nothing to pay today."}
			>
				You’re <em>Booked.</em>
			</ScreenHead>

			<div className="body">
				<div className="receipt">
					<div className="rcpt-head">
						<span className="rcpt-title">Plan Visit</span>
						{r.remaining != null && <PunchCard total={s.subLookup?.visitsAllowed || 3} left={Math.max(0, r.remaining)} />}
					</div>
					<dl className="rcpt-list">
						<div className="rcpt-row">
							<dt className="l">When</dt>
							<dd className="r">
								{[s.date && prettyDateShort(s.date), s.time && fmtTime(s.time)].filter(Boolean).join(" · ") || "No Time Picked Yet"}
							</dd>
						</div>
						<div className="rcpt-row">
							<dt className="l">Confirmation</dt>
							<dd className="r mono">{r.confirmation || "Not Issued"}</dd>
						</div>
						<div className="rcpt-row">
							<dt className="l">Visits Remaining</dt>
							<dd className="r">{r.remaining == null ? "Not Known" : r.remaining}</dd>
						</div>
					</dl>
					<div className="rcpt-note">
						{r.remaining > 0
							? `Book your remaining ${r.remaining === 1 ? "visit" : "visits"} with ${s.subEmail || "your email"}.`
							: "Your last plan visit is booked."}
					</div>
				</div>

				{s.customerToken && <a className="cta" href={`/square-return?confirmation=${encodeURIComponent(s.confirmation)}#token=${encodeURIComponent(s.customerToken)}`}>View Confirmation <Ico name="arrow" /></a>}
				<p className="custom-hint">Save this private link for the studio address and visit changes. Online changes close 24 hours before your visit.</p>
				<button className="cal-retry" onClick={reset}>
					Done
				</button>
			</div>
		</div>
	);
}
