astra-sdk-web 1.1.2 → 1.1.3

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.
@@ -1530,19 +1530,16 @@ function FaceScanModal({ onComplete }) {
1530
1530
  ] }) });
1531
1531
  }
1532
1532
  var FaceScanModal_default = FaceScanModal;
1533
- function MobileRoute({ onClose } = {}) {
1534
- const navigate = reactRouterDom.useNavigate();
1533
+ function MobileRoute({ onClose, onNavigate } = {}) {
1535
1534
  React.useEffect(() => {
1536
- if (!isMobileDevice()) {
1537
- navigate("/qr", { replace: true });
1535
+ if (!isMobileDevice() && onNavigate) {
1536
+ onNavigate("qr");
1538
1537
  return;
1539
1538
  }
1540
- }, [navigate]);
1539
+ }, [onNavigate]);
1541
1540
  const handleClose = () => {
1542
1541
  if (onClose) {
1543
1542
  onClose();
1544
- } else {
1545
- navigate(-1);
1546
1543
  }
1547
1544
  };
1548
1545
  const handleComplete = (capturedImage) => {
@@ -1554,22 +1551,17 @@ function MobileRoute({ onClose } = {}) {
1554
1551
  return /* @__PURE__ */ jsxRuntime.jsx(FaceScanModal_default, { onClose: handleClose, onComplete: handleComplete });
1555
1552
  }
1556
1553
  var MobileRoute_default = MobileRoute;
1557
- function QRCodePage({ onClose } = {}) {
1558
- const [searchParams] = reactRouterDom.useSearchParams();
1559
- const navigate = reactRouterDom.useNavigate();
1554
+ function QRCodePage({ onClose, onNavigate } = {}) {
1560
1555
  const [qrUrl, setQrUrl] = React.useState("");
1561
1556
  const [copied, setCopied] = React.useState(false);
1562
1557
  React.useEffect(() => {
1563
1558
  const currentUrl = window.location.origin;
1564
- const params = {};
1565
- searchParams.forEach((value, key) => {
1566
- params[key] = value;
1567
- });
1559
+ const searchParams = new URLSearchParams(window.location.search);
1568
1560
  const mobileRoute = "/mobileroute";
1569
- const queryString = new URLSearchParams(params).toString();
1561
+ const queryString = searchParams.toString();
1570
1562
  const fullUrl = `${currentUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1571
1563
  setQrUrl(fullUrl);
1572
- }, [searchParams]);
1564
+ }, []);
1573
1565
  const handleCopyUrl = async () => {
1574
1566
  if (qrUrl) {
1575
1567
  try {
@@ -1584,8 +1576,6 @@ function QRCodePage({ onClose } = {}) {
1584
1576
  const handleClose = () => {
1585
1577
  if (onClose) {
1586
1578
  onClose();
1587
- } else {
1588
- navigate(-1);
1589
1579
  }
1590
1580
  };
1591
1581
  const handleRefresh = () => {
@@ -1657,6 +1647,15 @@ var KycFlow = ({
1657
1647
  startAtQr = true,
1658
1648
  onClose
1659
1649
  }) => {
1650
+ const [currentView, setCurrentView] = React.useState(startAtQr ? "qr" : "mobileroute");
1651
+ const handleNavigate = (view) => {
1652
+ setCurrentView(view);
1653
+ };
1654
+ const handleClose = () => {
1655
+ if (onClose) {
1656
+ onClose();
1657
+ }
1658
+ };
1660
1659
  return /* @__PURE__ */ jsxRuntime.jsx(
1661
1660
  KycProvider,
1662
1661
  {
@@ -1664,11 +1663,7 @@ var KycFlow = ({
1664
1663
  sessionId,
1665
1664
  serverKey,
1666
1665
  deviceType,
1667
- children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.MemoryRouter, { initialEntries: [startAtQr ? "/qr" : "/mobileroute"], children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
1668
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/", element: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: startAtQr ? "/qr" : "/mobileroute", replace: true }) }),
1669
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/qr", element: /* @__PURE__ */ jsxRuntime.jsx(QRCodePage_default, { onClose }) }),
1670
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/mobileroute", element: /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose }) })
1671
- ] }) })
1666
+ children: currentView === "qr" ? /* @__PURE__ */ jsxRuntime.jsx(QRCodePage_default, { onClose: handleClose, onNavigate: handleNavigate }) : /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose: handleClose, onNavigate: handleNavigate })
1672
1667
  }
1673
1668
  );
1674
1669
  };