@metron-labs/quote-react 0.1.19 → 0.1.20

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.
@@ -11,6 +11,7 @@ import { clientHeaders, getBoqClientId, readJson } from "../../lib/api/boqClient
11
11
  // ponytail: flat UK VAT rate, matching fmtCurrency's GBP-only assumption elsewhere in this app.
12
12
  const VAT_RATE = 0.2;
13
13
  const PAGE_SIZE = 10;
14
+ const INVALID_EMAIL_MESSAGE = "Enter a valid email address so we can send your quote.";
14
15
  const orderSummary = (item, pricing) => {
15
16
  const requested = `${pricing.requestedAmount} ${unitDisplayText(pricing.requestedUnit, pricing.requestedAmount)}`;
16
17
  const order = `${pricing.requiredSellUnits} ${unitDisplayText(pricing.sellUnit, pricing.requiredSellUnits ?? 0)}`;
@@ -145,7 +146,7 @@ export default function BasketStage({ cart, onUpdateQty, onUpdateSellUnits, onRe
145
146
  async function submitQuoteRequest() {
146
147
  const email = reference.trim();
147
148
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
148
- setQuoteContactError("Enter a valid email address so we can send your better price.");
149
+ setQuoteContactError(INVALID_EMAIL_MESSAGE);
149
150
  return;
150
151
  }
151
152
  setQuoteContactError("");
@@ -175,7 +176,10 @@ export default function BasketStage({ cart, onUpdateQty, onUpdateSellUnits, onRe
175
176
  });
176
177
  if (!res.ok) {
177
178
  const payload = await readJson(res);
178
- setQuoteContactError(res.status === 429 ? "You've sent a few requests already. Please try again in a few minutes." : (payload?.message ?? "Your request couldn't be sent. Please try again."));
179
+ // The API's own message is written for developers (e.g. "items.0: Unrecognized key(s)"),
180
+ // so the customer gets a plain one and the console keeps the detail.
181
+ console.error("Quote request failed", res.status, payload?.message);
182
+ setQuoteContactError(res.status === 429 ? "You've sent a few requests already. Please try again in a few minutes." : "Your request couldn't be sent. Please try again, or contact us if it keeps happening.");
179
183
  return;
180
184
  }
181
185
  setQuoteRequestSent(true);
@@ -232,7 +236,7 @@ export default function BasketStage({ cart, onUpdateQty, onUpdateSellUnits, onRe
232
236
  setReference(e.target.value);
233
237
  if (qzaBasketLayout)
234
238
  setQuoteContactError("");
235
- }, placeholder: qzaBasketLayout ? "you@example.com" : "PO number or job reference" }), qzaBasketLayout && quoteContactError && (_jsx("p", { className: "basket-quote-request-error", role: "alert", children: quoteContactError })), qzaBasketLayout ? (_jsx("button", { type: "button", className: "cta-btn", onClick: () => void submitQuoteRequest(), disabled: quoteRequestSending, "aria-busy": quoteRequestSending, children: _jsx("span", { children: quoteRequestSending ? "Sending…" : "Request our best quote" }) })) : (_jsx("button", { className: "cta-btn", onClick: () => void exportBasketExcel(items), "aria-label": internal ? "Download selection" : "Download basket", children: _jsx("span", { children: internal ? "Download Quote" : "Buy Now" }) })), _jsxs("p", { className: "basket-sidebar-disclaimer", children: [_jsx("span", { "aria-hidden": "true", children: "\u26A0\uFE0F" }), qzaBasketLayout
239
+ }, placeholder: qzaBasketLayout ? "you@example.com" : "PO number or job reference", "aria-invalid": qzaBasketLayout && quoteContactError === INVALID_EMAIL_MESSAGE, "aria-describedby": qzaBasketLayout && quoteContactError ? `${uid}-basket-reference-error` : undefined }), qzaBasketLayout && quoteContactError && (_jsx("p", { id: `${uid}-basket-reference-error`, className: "basket-quote-request-error", role: "alert", children: quoteContactError })), qzaBasketLayout ? (_jsx("button", { type: "button", className: "cta-btn", onClick: () => void submitQuoteRequest(), disabled: quoteRequestSending, "aria-busy": quoteRequestSending, children: _jsx("span", { children: quoteRequestSending ? "Sending…" : "Request our best quote" }) })) : (_jsx("button", { className: "cta-btn", onClick: () => void exportBasketExcel(items), "aria-label": internal ? "Download selection" : "Download basket", children: _jsx("span", { children: internal ? "Download Quote" : "Buy Now" }) })), _jsxs("p", { className: "basket-sidebar-disclaimer", children: [_jsx("span", { "aria-hidden": "true", children: "\u26A0\uFE0F" }), qzaBasketLayout
236
240
  ? "This is a quote request, not an order. We'll confirm our best price, availability and delivery before you approve."
237
241
  : "Prices and availability are estimates and should be confirmed before procurement."] })] })] }), _jsx("div", { className: "btn-row results-actions", children: _jsxs("button", { className: "cta-btn cta-btn-secondary", style: { flex: "0 1 30%", gap: 10, justifyContent: "center" }, onClick: onBack, "aria-label": "Back to results", children: [_jsx(BackArrow, {}), _jsx("span", { children: "Back to results" })] }) })] })) })] }) }));
238
242
  }