@neowhale/storefront 0.2.38 → 0.2.39

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.
@@ -784,6 +784,7 @@ var WhaleStorefront = (function (exports) {
784
784
  const [newsletterOptIn, setNewsletterOptIn] = useState(false);
785
785
  const [status, setStatus] = useState("idle");
786
786
  const [errorMsg, setErrorMsg] = useState("");
787
+ const [serverMessage, setServerMessage] = useState(null);
787
788
  const gatewayUrl = c.gateway_url || data.gatewayUrl || "https://whale-gateway.fly.dev";
788
789
  const storeId = c.store_id || data.store?.id;
789
790
  const slug = c.landing_page_slug || data.landing_page?.slug;
@@ -822,8 +823,15 @@ var WhaleStorefront = (function (exports) {
822
823
  })
823
824
  });
824
825
  if (!res.ok) {
825
- const body = await res.json().catch(() => ({}));
826
- throw new Error(body?.error?.message || "Something went wrong. Please try again.");
826
+ const body2 = await res.json().catch(() => ({}));
827
+ throw new Error(body2?.error?.message || "Something went wrong. Please try again.");
828
+ }
829
+ const body = await res.json().catch(() => ({}));
830
+ if (body.is_new === false) {
831
+ setServerMessage({
832
+ heading: "welcome back!",
833
+ message: body.message || "your rewards are already loaded."
834
+ });
827
835
  }
828
836
  setStatus("success");
829
837
  onEvent?.("lead", { email, first_name: firstName || void 0, source: c.source || "landing_page", landing_page_slug: slug || void 0 });
@@ -846,7 +854,7 @@ var WhaleStorefront = (function (exports) {
846
854
  fontFamily: "inherit",
847
855
  transition: "border-color 0.2s"
848
856
  };
849
- if (status === "success") return /* @__PURE__ */ jsx(SuccessState, { theme, heading: successHeading, message: successMessage, couponCode: c.coupon_code });
857
+ if (status === "success") return /* @__PURE__ */ jsx(SuccessState, { theme, heading: serverMessage?.heading || successHeading, message: serverMessage?.message || successMessage, couponCode: c.coupon_code });
850
858
  return /* @__PURE__ */ jsx("div", { style: { padding: "3.5rem 1.5rem", maxWidth: 560, margin: "0 auto" }, children: [
851
859
  /* @__PURE__ */ jsx("style", { children: `@keyframes lc-spin { to { transform: rotate(360deg) } }` }),
852
860
  /* @__PURE__ */ jsx("div", { style: { background: theme.surface, border: `1px solid ${theme.fg}12`, padding: "clamp(2rem, 6vw, 3rem)" }, children: [
@@ -2524,6 +2524,7 @@ function LeadCaptureSection({ section, data, theme, onEvent }) {
2524
2524
  const [newsletterOptIn, setNewsletterOptIn] = react.useState(false);
2525
2525
  const [status, setStatus] = react.useState("idle");
2526
2526
  const [errorMsg, setErrorMsg] = react.useState("");
2527
+ const [serverMessage, setServerMessage] = react.useState(null);
2527
2528
  const gatewayUrl = c.gateway_url || data.gatewayUrl || "https://whale-gateway.fly.dev";
2528
2529
  const storeId = c.store_id || data.store?.id;
2529
2530
  const slug = c.landing_page_slug || data.landing_page?.slug;
@@ -2562,8 +2563,15 @@ function LeadCaptureSection({ section, data, theme, onEvent }) {
2562
2563
  })
2563
2564
  });
2564
2565
  if (!res.ok) {
2565
- const body = await res.json().catch(() => ({}));
2566
- throw new Error(body?.error?.message || "Something went wrong. Please try again.");
2566
+ const body2 = await res.json().catch(() => ({}));
2567
+ throw new Error(body2?.error?.message || "Something went wrong. Please try again.");
2568
+ }
2569
+ const body = await res.json().catch(() => ({}));
2570
+ if (body.is_new === false) {
2571
+ setServerMessage({
2572
+ heading: "welcome back!",
2573
+ message: body.message || "your rewards are already loaded."
2574
+ });
2567
2575
  }
2568
2576
  setStatus("success");
2569
2577
  onEvent?.("lead", { email, first_name: firstName || void 0, source: c.source || "landing_page", landing_page_slug: slug || void 0 });
@@ -2586,7 +2594,7 @@ function LeadCaptureSection({ section, data, theme, onEvent }) {
2586
2594
  fontFamily: "inherit",
2587
2595
  transition: "border-color 0.2s"
2588
2596
  };
2589
- if (status === "success") return /* @__PURE__ */ jsxRuntime.jsx(SuccessState, { theme, heading: successHeading, message: successMessage, couponCode: c.coupon_code });
2597
+ if (status === "success") return /* @__PURE__ */ jsxRuntime.jsx(SuccessState, { theme, heading: serverMessage?.heading || successHeading, message: serverMessage?.message || successMessage, couponCode: c.coupon_code });
2590
2598
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: "3.5rem 1.5rem", maxWidth: 560, margin: "0 auto" }, children: [
2591
2599
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: `@keyframes lc-spin { to { transform: rotate(360deg) } }` }),
2592
2600
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { background: theme.surface, border: `1px solid ${theme.fg}12`, padding: "clamp(2rem, 6vw, 3rem)" }, children: [