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.
- package/dist/astra-sdk.cjs.js +18 -23
- package/dist/astra-sdk.cjs.js.map +1 -1
- package/dist/astra-sdk.es.js +19 -24
- package/dist/astra-sdk.es.js.map +1 -1
- package/dist/components.cjs.js +18 -23
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +19 -24
- package/dist/components.es.js.map +1 -1
- package/package.json +1 -1
- package/src/components/KycFlow.tsx +20 -9
- package/src/pages/MobileRoute.tsx +5 -9
- package/src/pages/QRCodePage.tsx +7 -14
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { KycProvider } from '../contexts/KycContext';
|
|
3
3
|
import MobileRoute from '../pages/MobileRoute';
|
|
4
4
|
import QRCodePage from '../pages/QRCodePage';
|
|
5
|
-
import { MemoryRouter, Routes, Route, Navigate } from 'react-router-dom';
|
|
6
5
|
|
|
7
6
|
export interface KycFlowProps {
|
|
8
7
|
apiBaseUrl: string;
|
|
@@ -13,6 +12,8 @@ export interface KycFlowProps {
|
|
|
13
12
|
onClose?: () => void;
|
|
14
13
|
}
|
|
15
14
|
|
|
15
|
+
type KycFlowView = 'qr' | 'mobileroute';
|
|
16
|
+
|
|
16
17
|
export const KycFlow: React.FC<KycFlowProps> = ({
|
|
17
18
|
apiBaseUrl,
|
|
18
19
|
sessionId,
|
|
@@ -21,6 +22,18 @@ export const KycFlow: React.FC<KycFlowProps> = ({
|
|
|
21
22
|
startAtQr = true,
|
|
22
23
|
onClose,
|
|
23
24
|
}) => {
|
|
25
|
+
const [currentView, setCurrentView] = useState<KycFlowView>(startAtQr ? 'qr' : 'mobileroute');
|
|
26
|
+
|
|
27
|
+
const handleNavigate = (view: KycFlowView) => {
|
|
28
|
+
setCurrentView(view);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const handleClose = () => {
|
|
32
|
+
if (onClose) {
|
|
33
|
+
onClose();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
24
37
|
return (
|
|
25
38
|
<KycProvider
|
|
26
39
|
apiBaseUrl={apiBaseUrl}
|
|
@@ -28,13 +41,11 @@ export const KycFlow: React.FC<KycFlowProps> = ({
|
|
|
28
41
|
serverKey={serverKey}
|
|
29
42
|
deviceType={deviceType}
|
|
30
43
|
>
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</Routes>
|
|
37
|
-
</MemoryRouter>
|
|
44
|
+
{currentView === 'qr' ? (
|
|
45
|
+
<QRCodePage onClose={handleClose} onNavigate={handleNavigate} />
|
|
46
|
+
) : (
|
|
47
|
+
<MobileRoute onClose={handleClose} onNavigate={handleNavigate} />
|
|
48
|
+
)}
|
|
38
49
|
</KycProvider>
|
|
39
50
|
);
|
|
40
51
|
};
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import { useNavigate } from 'react-router-dom';
|
|
3
2
|
import { isMobileDevice } from '../utils/deviceDetection';
|
|
4
3
|
import FaceScanModal from './FaceScanModal';
|
|
5
4
|
import '../index.css';
|
|
6
5
|
|
|
7
6
|
interface MobileRouteProps {
|
|
8
7
|
onClose?: () => void;
|
|
8
|
+
onNavigate?: (view: 'qr' | 'mobileroute') => void;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function MobileRoute({ onClose }: MobileRouteProps = {}) {
|
|
12
|
-
const navigate = useNavigate();
|
|
13
|
-
|
|
11
|
+
function MobileRoute({ onClose, onNavigate }: MobileRouteProps = {}) {
|
|
14
12
|
useEffect(() => {
|
|
15
|
-
if (!isMobileDevice()) {
|
|
16
|
-
|
|
13
|
+
if (!isMobileDevice() && onNavigate) {
|
|
14
|
+
onNavigate('qr');
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
19
|
-
}, [
|
|
17
|
+
}, [onNavigate]);
|
|
20
18
|
|
|
21
19
|
const handleClose = () => {
|
|
22
20
|
if (onClose) {
|
|
23
21
|
onClose();
|
|
24
|
-
} else {
|
|
25
|
-
navigate(-1);
|
|
26
22
|
}
|
|
27
23
|
};
|
|
28
24
|
|
package/src/pages/QRCodePage.tsx
CHANGED
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
import { QRCodeSVG } from 'qrcode.react';
|
|
3
|
-
import { useSearchParams, useNavigate } from 'react-router-dom';
|
|
4
3
|
import '../index.css';
|
|
5
4
|
|
|
6
5
|
interface QRCodePageProps {
|
|
7
6
|
onClose?: () => void;
|
|
7
|
+
onNavigate?: (view: 'qr' | 'mobileroute') => void;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function QRCodePage({ onClose }: QRCodePageProps = {}) {
|
|
11
|
-
const [searchParams] = useSearchParams();
|
|
12
|
-
const navigate = useNavigate();
|
|
10
|
+
function QRCodePage({ onClose, onNavigate }: QRCodePageProps = {}) {
|
|
13
11
|
const [qrUrl, setQrUrl] = useState<string>('');
|
|
14
12
|
const [copied, setCopied] = useState<boolean>(false);
|
|
15
13
|
|
|
16
14
|
useEffect(() => {
|
|
17
15
|
const currentUrl = window.location.origin;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
searchParams
|
|
21
|
-
params[key] = value;
|
|
22
|
-
});
|
|
23
|
-
|
|
16
|
+
|
|
17
|
+
// Get search params from current URL
|
|
18
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
24
19
|
const mobileRoute = '/mobileroute';
|
|
25
|
-
const queryString =
|
|
20
|
+
const queryString = searchParams.toString();
|
|
26
21
|
const fullUrl = `${currentUrl}${mobileRoute}${queryString ? `?${queryString}` : ''}`;
|
|
27
22
|
|
|
28
23
|
setQrUrl(fullUrl);
|
|
29
|
-
}, [
|
|
24
|
+
}, []);
|
|
30
25
|
|
|
31
26
|
const handleCopyUrl = async () => {
|
|
32
27
|
if (qrUrl) {
|
|
@@ -43,8 +38,6 @@ function QRCodePage({ onClose }: QRCodePageProps = {}) {
|
|
|
43
38
|
const handleClose = () => {
|
|
44
39
|
if (onClose) {
|
|
45
40
|
onClose();
|
|
46
|
-
} else {
|
|
47
|
-
navigate(-1);
|
|
48
41
|
}
|
|
49
42
|
};
|
|
50
43
|
|