@neowhale/storefront 0.2.37 → 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.
@@ -1,5 +1,5 @@
1
1
  import { PixelManager } from '../chunk-MZO7BCGU.js';
2
- import { resilientSend, WhaleClient } from '../chunk-2XODSXJT.js';
2
+ import { resilientSend, WhaleClient } from '../chunk-BZCZLS5M.js';
3
3
  import { BehavioralTracker } from '../chunk-AKWSW7DW.js';
4
4
  import { createContext, useContext, useRef, useCallback, useEffect, useState, useMemo } from 'react';
5
5
  import { usePathname } from 'next/navigation';
@@ -2522,6 +2522,7 @@ function LeadCaptureSection({ section, data, theme, onEvent }) {
2522
2522
  const [newsletterOptIn, setNewsletterOptIn] = useState(false);
2523
2523
  const [status, setStatus] = useState("idle");
2524
2524
  const [errorMsg, setErrorMsg] = useState("");
2525
+ const [serverMessage, setServerMessage] = useState(null);
2525
2526
  const gatewayUrl = c.gateway_url || data.gatewayUrl || "https://whale-gateway.fly.dev";
2526
2527
  const storeId = c.store_id || data.store?.id;
2527
2528
  const slug = c.landing_page_slug || data.landing_page?.slug;
@@ -2560,8 +2561,15 @@ function LeadCaptureSection({ section, data, theme, onEvent }) {
2560
2561
  })
2561
2562
  });
2562
2563
  if (!res.ok) {
2563
- const body = await res.json().catch(() => ({}));
2564
- throw new Error(body?.error?.message || "Something went wrong. Please try again.");
2564
+ const body2 = await res.json().catch(() => ({}));
2565
+ throw new Error(body2?.error?.message || "Something went wrong. Please try again.");
2566
+ }
2567
+ const body = await res.json().catch(() => ({}));
2568
+ if (body.is_new === false) {
2569
+ setServerMessage({
2570
+ heading: "welcome back!",
2571
+ message: body.message || "your rewards are already loaded."
2572
+ });
2565
2573
  }
2566
2574
  setStatus("success");
2567
2575
  onEvent?.("lead", { email, first_name: firstName || void 0, source: c.source || "landing_page", landing_page_slug: slug || void 0 });
@@ -2584,7 +2592,7 @@ function LeadCaptureSection({ section, data, theme, onEvent }) {
2584
2592
  fontFamily: "inherit",
2585
2593
  transition: "border-color 0.2s"
2586
2594
  };
2587
- if (status === "success") return /* @__PURE__ */ jsx(SuccessState, { theme, heading: successHeading, message: successMessage, couponCode: c.coupon_code });
2595
+ if (status === "success") return /* @__PURE__ */ jsx(SuccessState, { theme, heading: serverMessage?.heading || successHeading, message: serverMessage?.message || successMessage, couponCode: c.coupon_code });
2588
2596
  return /* @__PURE__ */ jsxs("div", { style: { padding: "3.5rem 1.5rem", maxWidth: 560, margin: "0 auto" }, children: [
2589
2597
  /* @__PURE__ */ jsx("style", { children: `@keyframes lc-spin { to { transform: rotate(360deg) } }` }),
2590
2598
  /* @__PURE__ */ jsxs("div", { style: { background: theme.surface, border: `1px solid ${theme.fg}12`, padding: "clamp(2rem, 6vw, 3rem)" }, children: [