feat(exit): manual-exit dialog + wording — styled modal replaces window.prompt; copy says 'manual exit' / 'dalje manuale'
Build & push images / images (push) Successful in 3m13s
Build & push images / images (push) Successful in 3m13s
- BoothScreen: the no-ticket open uses the app's Modal (explainer, optional reason, red confirm; Enter confirms, Escape/Cancel abort) instead of a browser prompt. - en/sq: forgive/forgiven/forgone wording dropped from every user-facing string (buttons, dialog, results, live-feed reasons, shift figures); Albanian edited by the user, English aligned. Printed Z line is 'Dalje manuale (N)'. The signed English fallback sentences follow. Identifiers (exit.forgiven, forgoneMinor, barrier:create) unchanged. - wiki: forgiven-exit §Wording, shift, log.
This commit is contained in:
@@ -7,6 +7,7 @@ import { qk } from "./lib/query.js";
|
||||
import { useLiveStore } from "./lib/live-store.js";
|
||||
import { useShift } from "./lib/use-shift.js";
|
||||
import { useScanner } from "./lib/use-scanner.js";
|
||||
import { Modal } from "./ui/Modal.js";
|
||||
import { Panel } from "./ui/Panel.js";
|
||||
import { StatusDot } from "./ui/StatusDot.js";
|
||||
import { BoothPayModal } from "./BoothPayModal.js";
|
||||
@@ -217,25 +218,26 @@ function LaneIndicators() {
|
||||
}
|
||||
|
||||
// FORGIVEN exit for a car with NO ticket (barrier:create; wiki/decisions/forgiven-exit.md):
|
||||
// signed anomaly + exit snapshot + pulse, no money, nothing printed. Reason optional
|
||||
// (Cancel in the prompt aborts; an empty answer proceeds).
|
||||
// signed anomaly + exit snapshot + pulse, no money, nothing printed. A small styled
|
||||
// dialog (same chrome as every other form) asks for an OPTIONAL reason, then confirms.
|
||||
const canForgive = can(user, "barrier:create") && shiftOpen && isMine;
|
||||
const [forgiveOpen, setForgiveOpen] = useState(false);
|
||||
const [forgiveNote, setForgiveNote] = useState("");
|
||||
const forgive = useMutation({
|
||||
mutationFn: (note: string) => forgiveExit(null, note),
|
||||
onSuccess: (r) => {
|
||||
setForgiveOpen(false);
|
||||
setForgiveNote("");
|
||||
setMsg({ ok: r.opened, text: r.opened ? t("booth.forgiveExitOk") : t("booth.forgiveExitNotOpened", { reason: r.reason ?? "" }) });
|
||||
void qc.invalidateQueries({ queryKey: qk.events });
|
||||
setTimeout(() => setMsg(null), 5000);
|
||||
},
|
||||
onError: (e) => {
|
||||
setForgiveOpen(false);
|
||||
setMsg({ ok: false, text: (e as Error).message });
|
||||
setTimeout(() => setMsg(null), 5000);
|
||||
},
|
||||
});
|
||||
function onForgiveNoTicket() {
|
||||
const note = window.prompt(t("booth.forgiveExitPrompt"));
|
||||
if (note !== null) forgive.mutate(note.trim());
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -252,7 +254,7 @@ function LaneIndicators() {
|
||||
{canForgive && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onForgiveNoTicket}
|
||||
onClick={() => setForgiveOpen(true)}
|
||||
disabled={forgive.isPending}
|
||||
className="btn btn-ghost btn-sm text-term-red"
|
||||
title={t("booth.forgiveExitTitle")}
|
||||
@@ -260,6 +262,39 @@ function LaneIndicators() {
|
||||
{t("booth.forgiveExit")}
|
||||
</button>
|
||||
)}
|
||||
{/* Forgiven-exit dialog (no ticket): what it does, an optional reason, a deliberate red
|
||||
confirm. Enter in the field confirms; Escape / ✕ / Cancel abort. */}
|
||||
<Modal open={forgiveOpen} onClose={() => setForgiveOpen(false)} title={t("booth.forgiveDialogTitle")} width="max-w-md">
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
if (!forgive.isPending) forgive.mutate(forgiveNote.trim());
|
||||
}}
|
||||
className="flex flex-col gap-3"
|
||||
>
|
||||
<div className="rounded-term border border-term-red/50 bg-term-red/5 px-3 py-2 text-[0.75rem] text-term-text">
|
||||
{t("booth.forgiveDialogBody")}
|
||||
</div>
|
||||
<label className="flex flex-col gap-1 text-[0.6875rem] uppercase tracking-wider text-term-muted">
|
||||
{t("booth.forgiveDialogReason")}
|
||||
<input
|
||||
className="input w-full normal-case tracking-normal"
|
||||
value={forgiveNote}
|
||||
onChange={(e) => setForgiveNote(e.target.value)}
|
||||
placeholder={t("booth.forgiveDialogReasonPlaceholder")}
|
||||
autoFocus
|
||||
/>
|
||||
</label>
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<button type="button" onClick={() => setForgiveOpen(false)} className="btn btn-ghost btn-sm">
|
||||
{t("common.cancel")}
|
||||
</button>
|
||||
<button type="submit" disabled={forgive.isPending} className="btn btn-danger">
|
||||
{forgive.isPending ? t("booth.forgiveDialogWorking") : t("booth.forgiveDialogConfirm")}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</Modal>
|
||||
{msg && (
|
||||
<span className={`text-[0.6875rem] ${msg.ok ? "text-term-green" : "text-term-red"}`}>{msg.text}</span>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user