@c1m-public/dash-site-kit 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -285,3 +285,11 @@ before it has a domain), never on `saasdash.app`. Set `adminUrl` in
285
285
  `site.defaults.json` and build links with `createSiteConfig().adminUrl(path)`.
286
286
  `DashAdminLink` swaps its label while the admin host's `c1m_signed_in` hint is
287
287
  set; the session itself never leaves the admin host.
288
+
289
+ ### Moving request recovery (0.17.1 candidate)
290
+
291
+ The moving form's first submit validates and opens review; only the next submit
292
+ captures the request. Native action resets are prevented so invalid/unavailable
293
+ responses preserve the entered details and existing idempotency key. Success
294
+ replaces the form with the receipt. Consumers should adopt the registry release
295
+ after the candidate's browser acceptance; never commit a local tarball dependency.
package/dist/sentry.d.ts CHANGED
@@ -5,7 +5,35 @@ export interface ChannelSiteSentryConfiguration {
5
5
  release?: string;
6
6
  site: string;
7
7
  }
8
+ export interface ChannelSiteSentryDataCollection {
9
+ cookies: false;
10
+ databaseQueryData: false;
11
+ genAI: {
12
+ inputs: false;
13
+ outputs: false;
14
+ };
15
+ graphQL: {
16
+ document: false;
17
+ variables: false;
18
+ };
19
+ httpBodies: [];
20
+ httpHeaders: {
21
+ request: {
22
+ allow: string[];
23
+ };
24
+ response: false;
25
+ };
26
+ mcp: {
27
+ inputs: false;
28
+ outputs: false;
29
+ };
30
+ queues: false;
31
+ stackFrameVariables: false;
32
+ urlQueryParams: false;
33
+ userInfo: false;
34
+ }
8
35
  export interface ChannelSiteSentryOptions {
36
+ dataCollection: ChannelSiteSentryDataCollection;
9
37
  dsn: string;
10
38
  enableLogs: false;
11
39
  environment?: string;
package/dist/sentry.js CHANGED
@@ -6,6 +6,26 @@ export class ChannelSiteSentryConfigurationError extends Error {
6
6
  this.code = code;
7
7
  }
8
8
  }
9
+ /**
10
+ * Sentry 11 ignores `sendDefaultPii`, and any category left out here defaults
11
+ * to collected, so list them all. Sites take visitors' contact details and put
12
+ * access tokens in URLs; none of that belongs in an error report.
13
+ */
14
+ function channelSiteDataCollection() {
15
+ return {
16
+ cookies: false,
17
+ databaseQueryData: false,
18
+ genAI: { inputs: false, outputs: false },
19
+ graphQL: { document: false, variables: false },
20
+ httpBodies: [],
21
+ httpHeaders: { request: { allow: ["user-agent"] }, response: false },
22
+ mcp: { inputs: false, outputs: false },
23
+ queues: false,
24
+ stackFrameVariables: false,
25
+ urlQueryParams: false,
26
+ userInfo: false,
27
+ };
28
+ }
9
29
  function validateDsn(value) {
10
30
  let dsn;
11
31
  try {
@@ -35,6 +55,7 @@ export function resolveChannelSiteSentryOptions(configuration) {
35
55
  const environment = configuration.environment?.trim();
36
56
  const release = configuration.release?.trim();
37
57
  return {
58
+ dataCollection: channelSiteDataCollection(),
38
59
  dsn: validateDsn(dsn),
39
60
  enableLogs: false,
40
61
  ...(environment ? { environment } : {}),
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useActionState, useEffect, useState } from "react";
3
+ import { useActionState, useEffect, useRef, useState } from "react";
4
4
  import { DashHoneypotField } from "./honeypot-field.js";
5
5
  export function DashMovingQuoteForm({ action, initialPickup = "", }) {
6
6
  const [state, formAction, pending] = useActionState(action, { status: "idle" });
@@ -9,31 +9,53 @@ export function DashMovingQuoteForm({ action, initialPickup = "", }) {
9
9
  const [reviewing, setReviewing] = useState(false);
10
10
  const [addresses, setAddresses] = useState({ from: [], to: [] });
11
11
  const [searchState, setSearchState] = useState({ from: "", to: "" });
12
- const [selected, setSelected] = useState({ from: null, to: null });
12
+ const selected = useRef({ from: null, to: null });
13
+ const addressVersions = useRef({ from: 0, to: 0 });
14
+ const routeVersion = useRef(0);
13
15
  const [distance, setDistance] = useState(null);
14
16
  const [distanceUnavailable, setDistanceUnavailable] = useState(false);
15
17
  if (state.status === "created") {
16
18
  return _jsxs("div", { className: "rounded-3xl border border-border bg-white p-8", role: "status", children: [_jsx("h2", { className: "text-2xl font-semibold text-ink", children: "Request received" }), _jsxs("p", { className: "mt-3 text-muted", children: ["Your reference is ", _jsx("strong", { children: state.reference }), ". Keep it for your records."] }), _jsx("p", { className: "mt-3 text-muted", children: "We will email you as the request progresses. You can also retrieve it with an email link." }), _jsx("a", { className: "mt-6 inline-flex rounded-full bg-accent px-6 py-3 font-semibold text-accent-foreground", href: "/my-quotes", children: "View my requests" })] });
17
19
  }
20
+ function clearRoute() {
21
+ routeVersion.current++;
22
+ setDistance(null);
23
+ setDistanceUnavailable(false);
24
+ }
25
+ function editAddress(side) {
26
+ addressVersions.current[side]++;
27
+ selected.current[side] = null;
28
+ setAddresses(current => ({ ...current, [side]: [] }));
29
+ setSearchState(current => ({ ...current, [side]: "" }));
30
+ clearRoute();
31
+ }
18
32
  async function lookup(side, form) {
19
33
  const field = form.elements.namedItem(`${side}_postcode`);
20
34
  const query = field?.value.trim() ?? "";
21
35
  if (!query)
22
36
  return;
37
+ const version = ++addressVersions.current[side];
38
+ setAddresses(current => ({ ...current, [side]: [] }));
23
39
  setSearchState((current) => ({ ...current, [side]: "Searching addresses…" }));
24
40
  try {
25
41
  const response = await fetch(`/api/moving-addresses/lookup?q=${encodeURIComponent(query)}`, { cache: "no-store" });
26
42
  if (!response.ok)
27
43
  throw new Error("lookup failed");
28
44
  const data = await response.json();
45
+ if (version !== addressVersions.current[side])
46
+ return;
29
47
  setAddresses((current) => ({ ...current, [side]: data.results }));
30
48
  setSearchState((current) => ({ ...current, [side]: data.results.length ? "Choose your address below." : "No addresses found. Enter it manually." }));
31
49
  }
32
50
  catch {
51
+ if (version !== addressVersions.current[side])
52
+ return;
33
53
  setSearchState((current) => ({ ...current, [side]: "Address search is unavailable. Enter the address manually." }));
34
54
  }
35
55
  }
36
56
  async function selectAddress(side, result, form) {
57
+ const version = ++addressVersions.current[side];
58
+ clearRoute();
37
59
  let resolved = result;
38
60
  if (result._udprn && !result.normalized) {
39
61
  try {
@@ -43,21 +65,26 @@ export function DashMovingQuoteForm({ action, initialPickup = "", }) {
43
65
  resolved = await response.json();
44
66
  }
45
67
  catch {
68
+ if (version !== addressVersions.current[side])
69
+ return;
46
70
  setSearchState((current) => ({ ...current, [side]: "Could not confirm that address. Enter it manually." }));
47
71
  return;
48
72
  }
49
73
  }
74
+ if (version !== addressVersions.current[side])
75
+ return;
50
76
  const addressField = form.elements.namedItem(`${side}_address`);
51
77
  const postcodeField = form.elements.namedItem(`${side}_postcode`);
52
78
  if (addressField)
53
79
  addressField.value = resolved.display;
54
80
  if (postcodeField && resolved.normalized?.postal_code)
55
81
  postcodeField.value = resolved.normalized.postal_code;
56
- setSelected((current) => ({ ...current, [side]: resolved }));
82
+ selected.current[side] = resolved;
57
83
  setAddresses((current) => ({ ...current, [side]: [] }));
58
84
  setSearchState((current) => ({ ...current, [side]: "Address selected." }));
59
- setDistance(null);
60
- const counterpart = selected[side === "from" ? "to" : "from"];
85
+ clearRoute();
86
+ const route = routeVersion.current;
87
+ const counterpart = selected.current[side === "from" ? "to" : "from"];
61
88
  const a = side === "from" ? resolved : counterpart;
62
89
  const b = side === "to" ? resolved : counterpart;
63
90
  if (a?.normalized && b?.normalized && Number.isFinite(a.normalized.latitude) && Number.isFinite(b.normalized.latitude)) {
@@ -66,15 +93,24 @@ export function DashMovingQuoteForm({ action, initialPickup = "", }) {
66
93
  const response = await fetch(`/api/moving-addresses/distance?${params}`, { cache: "no-store" });
67
94
  if (!response.ok)
68
95
  throw new Error("distance failed");
69
- setDistance(await response.json());
96
+ const result = await response.json();
97
+ if (route !== routeVersion.current)
98
+ return;
99
+ setDistance(result);
70
100
  setDistanceUnavailable(false);
71
101
  }
72
102
  catch {
73
- setDistanceUnavailable(true);
103
+ if (route === routeVersion.current)
104
+ setDistanceUnavailable(true);
74
105
  }
75
106
  }
76
107
  }
77
- return _jsxs("form", { action: formAction, className: "space-y-8 rounded-3xl border border-border bg-white p-6 shadow-xl shadow-slate-900/5 sm:p-9", children: [_jsx(DashHoneypotField, {}), _jsx("input", { type: "hidden", name: "attempt_id", value: attemptId }), _jsx("input", { type: "hidden", name: "distance_miles", value: distance?.distanceMiles ?? "" }), _jsx("input", { type: "hidden", name: "duration_minutes", value: distance?.durationMinutes ?? "" }), ["from", "to"].map((side) => _jsxs("fieldset", { className: "space-y-3", children: [_jsx("legend", { className: "text-lg font-semibold text-ink", children: side === "from" ? "Collection" : "Delivery" }), _jsx("label", { className: "block text-sm font-medium text-ink", htmlFor: `${side}_postcode`, children: "Postcode" }), _jsxs("div", { className: "flex gap-2", children: [_jsx("input", { className: "min-h-12 min-w-0 flex-1 rounded-xl border border-border px-4", defaultValue: side === "from" ? initialPickup : "", id: `${side}_postcode`, name: `${side}_postcode`, autoComplete: "postal-code", required: true, maxLength: 16 }), _jsx("button", { className: "rounded-xl border border-border px-4 font-medium text-ink", type: "button", onClick: (event) => lookup(side, event.currentTarget.form), children: "Find address" })] }), searchState[side] && _jsx("p", { className: "text-sm text-muted", role: "status", children: searchState[side] }), addresses[side].length > 0 && _jsx("ul", { className: "max-h-48 overflow-auto rounded-xl border border-border", "aria-label": `${side} address suggestions`, children: addresses[side].map((result) => _jsx("li", { children: _jsx("button", { className: "w-full px-4 py-2 text-left text-sm hover:bg-subtle", type: "button", onClick: (event) => selectAddress(side, result, event.currentTarget.form), children: result.display }) }, `${result._udprn ?? result.display}`)) }), _jsx("label", { className: "block text-sm font-medium text-ink", htmlFor: `${side}_address`, children: "Address" }), _jsx("input", { className: "min-h-12 w-full rounded-xl border border-border px-4", id: `${side}_address`, name: `${side}_address`, required: true, maxLength: 500, placeholder: "Select an address or enter it manually" })] }, side)), distance && _jsxs("p", { className: "text-sm text-muted", children: ["Approximate driving distance: ", distance.distanceMiles, " miles."] }), distanceUnavailable && _jsx("p", { className: "text-sm text-muted", children: "Distance is unavailable. You can still submit your request." }), _jsxs("fieldset", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx("legend", { className: "mb-3 text-lg font-semibold text-ink", children: "Move details" }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Preferred date", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "date", name: "move_date" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Property size", _jsxs("select", { className: "min-h-12 rounded-xl border border-border px-4", name: "property_size", defaultValue: "2-bed", children: [_jsx("option", { value: "studio", children: "Studio" }), _jsx("option", { value: "1-bed", children: "1 bedroom" }), _jsx("option", { value: "2-bed", children: "2 bedrooms" }), _jsx("option", { value: "3-bed", children: "3 bedrooms" }), _jsx("option", { value: "4+-bed", children: "4 or more bedrooms" }), _jsx("option", { value: "other", children: "Other" })] })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Collection floor", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "number", name: "floor_from", min: "0", max: "99", defaultValue: "0" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Delivery floor", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "number", name: "floor_to", min: "0", max: "99", defaultValue: "0" })] }), [["flexible_date", "My date is flexible"], ["has_lift_from", "Collection has a lift"], ["has_lift_to", "Delivery has a lift"], ["packing_required", "I need packing"], ["storage_required", "I need storage"], ["dismantling_required", "I need dismantling"]].map(([key, label]) => _jsxs("label", { className: "flex items-center gap-2 text-sm text-ink", children: [_jsx("input", { type: "checkbox", name: key }), label] }, key)), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Special items, separated by commas", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "special_items", maxLength: 1000 })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Other details", _jsx("textarea", { className: "min-h-28 rounded-xl border border-border p-4", name: "additional_notes", maxLength: 4000 })] })] }), _jsxs("fieldset", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx("legend", { className: "mb-3 text-lg font-semibold text-ink", children: "Your contact details" }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Name", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "name", required: true, maxLength: 255, autoComplete: "name" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Email", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "email", type: "email", required: true, maxLength: 320, autoComplete: "email" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Phone (optional)", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "phone", type: "tel", maxLength: 64, autoComplete: "tel" })] })] }), state.status === "invalid" && _jsx("p", { className: "rounded-xl bg-amber-50 p-4 text-sm text-amber-950", role: "alert", children: "Check your details and try again." }), state.status === "error" && _jsx("p", { className: "rounded-xl bg-amber-50 p-4 text-sm text-amber-950", role: "alert", children: "We could not submit your request. Please try again." }), reviewing && _jsx("p", { className: "rounded-xl bg-subtle p-4 text-sm text-ink", role: "status", children: "Review your addresses, move details, and contact email above. Submit when everything looks right." }), reviewing ? _jsx("button", { className: "min-h-12 rounded-full bg-accent px-7 font-semibold text-accent-foreground disabled:opacity-50", type: "submit", disabled: pending, children: pending ? "Submitting…" : "Submit request" })
78
- : _jsx("button", { className: "min-h-12 rounded-full bg-accent px-7 font-semibold text-accent-foreground", type: "button", disabled: !attemptId, onClick: (event) => { if (event.currentTarget.form?.reportValidity())
79
- setReviewing(true); }, children: "Review request" })] });
108
+ return _jsxs("form", { action: formAction, onSubmit: (event) => {
109
+ if (!reviewing) {
110
+ event.preventDefault();
111
+ setReviewing(true);
112
+ }
113
+ },
114
+ // Failed actions retain the draft; successful actions replace this form.
115
+ onReset: (event) => event.preventDefault(), className: "space-y-8 rounded-3xl border border-border bg-white p-6 shadow-xl shadow-slate-900/5 sm:p-9", children: [_jsx(DashHoneypotField, {}), _jsx("input", { type: "hidden", name: "attempt_id", value: attemptId }), _jsx("input", { type: "hidden", name: "distance_miles", value: distance?.distanceMiles ?? "" }), _jsx("input", { type: "hidden", name: "duration_minutes", value: distance?.durationMinutes ?? "" }), ["from", "to"].map((side) => _jsxs("fieldset", { className: "space-y-3", onChange: () => editAddress(side), children: [_jsx("legend", { className: "text-lg font-semibold text-ink", children: side === "from" ? "Collection" : "Delivery" }), _jsx("label", { className: "block text-sm font-medium text-ink", htmlFor: `${side}_postcode`, children: "Postcode" }), _jsxs("div", { className: "flex gap-2", children: [_jsx("input", { className: "min-h-12 min-w-0 flex-1 rounded-xl border border-border px-4", defaultValue: side === "from" ? initialPickup : "", id: `${side}_postcode`, name: `${side}_postcode`, autoComplete: "postal-code", required: true, maxLength: 16 }), _jsx("button", { className: "rounded-xl border border-border px-4 font-medium text-ink", type: "button", onClick: (event) => lookup(side, event.currentTarget.form), children: "Find address" })] }), searchState[side] && _jsx("p", { className: "text-sm text-muted", role: "status", children: searchState[side] }), addresses[side].length > 0 && _jsx("ul", { className: "max-h-48 overflow-auto rounded-xl border border-border", "aria-label": `${side} address suggestions`, children: addresses[side].map((result) => _jsx("li", { children: _jsx("button", { className: "w-full px-4 py-2 text-left text-sm hover:bg-subtle", type: "button", onClick: (event) => selectAddress(side, result, event.currentTarget.form), children: result.display }) }, `${result._udprn ?? result.display}`)) }), _jsx("label", { className: "block text-sm font-medium text-ink", htmlFor: `${side}_address`, children: "Address" }), _jsx("input", { className: "min-h-12 w-full rounded-xl border border-border px-4", id: `${side}_address`, name: `${side}_address`, required: true, maxLength: 500, placeholder: "Select an address or enter it manually" })] }, side)), distance && _jsxs("p", { className: "text-sm text-muted", children: ["Approximate driving distance: ", distance.distanceMiles, " miles."] }), distanceUnavailable && _jsx("p", { className: "text-sm text-muted", children: "Distance is unavailable. You can still submit your request." }), _jsxs("fieldset", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx("legend", { className: "mb-3 text-lg font-semibold text-ink", children: "Move details" }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Preferred date", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "date", name: "move_date" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Property size", _jsxs("select", { className: "min-h-12 rounded-xl border border-border px-4", name: "property_size", defaultValue: "2-bed", children: [_jsx("option", { value: "studio", children: "Studio" }), _jsx("option", { value: "1-bed", children: "1 bedroom" }), _jsx("option", { value: "2-bed", children: "2 bedrooms" }), _jsx("option", { value: "3-bed", children: "3 bedrooms" }), _jsx("option", { value: "4+-bed", children: "4 or more bedrooms" }), _jsx("option", { value: "other", children: "Other" })] })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Collection floor", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "number", name: "floor_from", min: "0", max: "99", defaultValue: "0" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Delivery floor", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "number", name: "floor_to", min: "0", max: "99", defaultValue: "0" })] }), [["flexible_date", "My date is flexible"], ["has_lift_from", "Collection has a lift"], ["has_lift_to", "Delivery has a lift"], ["packing_required", "I need packing"], ["storage_required", "I need storage"], ["dismantling_required", "I need dismantling"]].map(([key, label]) => _jsxs("label", { className: "flex items-center gap-2 text-sm text-ink", children: [_jsx("input", { type: "checkbox", name: key }), label] }, key)), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Special items, separated by commas", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "special_items", maxLength: 1000 })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Other details", _jsx("textarea", { className: "min-h-28 rounded-xl border border-border p-4", name: "additional_notes", maxLength: 4000 })] })] }), _jsxs("fieldset", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx("legend", { className: "mb-3 text-lg font-semibold text-ink", children: "Your contact details" }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Name", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "name", required: true, maxLength: 255, autoComplete: "name" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Email", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "email", type: "email", required: true, maxLength: 320, autoComplete: "email" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Phone (optional)", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "phone", type: "tel", maxLength: 64, autoComplete: "tel" })] })] }), state.status === "invalid" && _jsx("p", { className: "rounded-xl bg-amber-50 p-4 text-sm text-amber-950", role: "alert", children: "Check your details and try again." }), state.status === "error" && _jsx("p", { className: "rounded-xl bg-amber-50 p-4 text-sm text-amber-950", role: "alert", children: "We could not submit your request. Please try again." }), reviewing && _jsx("p", { className: "rounded-xl bg-subtle p-4 text-sm text-ink", role: "status", children: "Review your addresses, move details, and contact email above. Submit when everything looks right." }), _jsx("button", { className: "min-h-12 rounded-full bg-accent px-7 font-semibold text-accent-foreground disabled:opacity-50", type: "submit", disabled: pending || !attemptId, children: pending ? "Submitting…" : reviewing ? "Submit request" : "Review request" })] });
80
116
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c1m-public/dash-site-kit",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Shared transport, domain and UI layer for MML dash-scoped public sites",
@@ -57,8 +57,8 @@
57
57
  "react-dom": "19.2.8",
58
58
  "typescript": "5.9.3",
59
59
  "vitest": "^4.1.4",
60
- "@c1m-public/channel-client": "0.36.0",
61
- "@c1m-public/platform-auth": "0.23.0"
60
+ "@c1m-public/platform-auth": "0.26.0",
61
+ "@c1m-public/channel-client": "0.38.0"
62
62
  },
63
63
  "peerDependenciesMeta": {
64
64
  "next": {