astra-sdk-web 1.1.1 → 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.
@@ -1325,19 +1325,16 @@ function FaceScanModal({ onComplete }) {
1325
1325
  ] }) });
1326
1326
  }
1327
1327
  var FaceScanModal_default = FaceScanModal;
1328
- function MobileRoute({ onClose } = {}) {
1329
- const navigate = reactRouterDom.useNavigate();
1328
+ function MobileRoute({ onClose, onNavigate } = {}) {
1330
1329
  React.useEffect(() => {
1331
- if (!isMobileDevice()) {
1332
- navigate("/qr", { replace: true });
1330
+ if (!isMobileDevice() && onNavigate) {
1331
+ onNavigate("qr");
1333
1332
  return;
1334
1333
  }
1335
- }, [navigate]);
1334
+ }, [onNavigate]);
1336
1335
  const handleClose = () => {
1337
1336
  if (onClose) {
1338
1337
  onClose();
1339
- } else {
1340
- navigate(-1);
1341
1338
  }
1342
1339
  };
1343
1340
  const handleComplete = (capturedImage) => {
@@ -1349,22 +1346,17 @@ function MobileRoute({ onClose } = {}) {
1349
1346
  return /* @__PURE__ */ jsxRuntime.jsx(FaceScanModal_default, { onClose: handleClose, onComplete: handleComplete });
1350
1347
  }
1351
1348
  var MobileRoute_default = MobileRoute;
1352
- function QRCodePage({ onClose } = {}) {
1353
- const [searchParams] = reactRouterDom.useSearchParams();
1354
- const navigate = reactRouterDom.useNavigate();
1349
+ function QRCodePage({ onClose, onNavigate } = {}) {
1355
1350
  const [qrUrl, setQrUrl] = React.useState("");
1356
1351
  const [copied, setCopied] = React.useState(false);
1357
1352
  React.useEffect(() => {
1358
1353
  const currentUrl = window.location.origin;
1359
- const params = {};
1360
- searchParams.forEach((value, key) => {
1361
- params[key] = value;
1362
- });
1354
+ const searchParams = new URLSearchParams(window.location.search);
1363
1355
  const mobileRoute = "/mobileroute";
1364
- const queryString = new URLSearchParams(params).toString();
1356
+ const queryString = searchParams.toString();
1365
1357
  const fullUrl = `${currentUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1366
1358
  setQrUrl(fullUrl);
1367
- }, [searchParams]);
1359
+ }, []);
1368
1360
  const handleCopyUrl = async () => {
1369
1361
  if (qrUrl) {
1370
1362
  try {
@@ -1379,8 +1371,6 @@ function QRCodePage({ onClose } = {}) {
1379
1371
  const handleClose = () => {
1380
1372
  if (onClose) {
1381
1373
  onClose();
1382
- } else {
1383
- navigate(-1);
1384
1374
  }
1385
1375
  };
1386
1376
  const handleRefresh = () => {
@@ -1452,6 +1442,15 @@ var KycFlow = ({
1452
1442
  startAtQr = true,
1453
1443
  onClose
1454
1444
  }) => {
1445
+ const [currentView, setCurrentView] = React.useState(startAtQr ? "qr" : "mobileroute");
1446
+ const handleNavigate = (view) => {
1447
+ setCurrentView(view);
1448
+ };
1449
+ const handleClose = () => {
1450
+ if (onClose) {
1451
+ onClose();
1452
+ }
1453
+ };
1455
1454
  return /* @__PURE__ */ jsxRuntime.jsx(
1456
1455
  KycProvider,
1457
1456
  {
@@ -1459,11 +1458,7 @@ var KycFlow = ({
1459
1458
  sessionId,
1460
1459
  serverKey,
1461
1460
  deviceType,
1462
- children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.BrowserRouter, { children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
1463
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/", element: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: startAtQr ? "/qr" : "/mobileroute", replace: true }) }),
1464
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/qr", element: /* @__PURE__ */ jsxRuntime.jsx(QRCodePage_default, { onClose }) }),
1465
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/mobileroute", element: /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose }) })
1466
- ] }) })
1461
+ children: currentView === "qr" ? /* @__PURE__ */ jsxRuntime.jsx(QRCodePage_default, { onClose: handleClose, onNavigate: handleNavigate }) : /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose: handleClose, onNavigate: handleNavigate })
1467
1462
  }
1468
1463
  );
1469
1464
  };