@opexa/portal-components 0.0.496 → 0.0.498
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.
|
@@ -4,4 +4,4 @@ export interface KYCSumsubProps extends KYCReminderProps {
|
|
|
4
4
|
provider: 'sumsub';
|
|
5
5
|
logo: ImageProps['src'];
|
|
6
6
|
}
|
|
7
|
-
export declare function KYCSumsub(props: KYCSumsubProps):
|
|
7
|
+
export declare function KYCSumsub(props: KYCSumsubProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,21 +2,27 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import Sumsub from '@sumsub/websdk-react';
|
|
4
4
|
import { isObject } from 'lodash-es';
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
6
|
import { useShallow } from 'zustand/shallow';
|
|
7
|
+
import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
|
|
7
8
|
import { useGenerateSumsubVerificationTokenMutation } from '../../client/hooks/useGenerateSumsubVerificationTokenMutation.js';
|
|
8
9
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
10
|
+
import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
|
|
9
11
|
import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
|
|
10
|
-
import { Spinner02Icon } from '../../icons/Spinner02Icon.js';
|
|
11
12
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
12
13
|
import { Portal } from '../../ui/Portal/index.js';
|
|
13
14
|
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
14
15
|
import { getAccountQueryKey, getMemberVerificationQueryKey, getProfileCompletionQueryKey, } from '../../utils/queryKeys.js';
|
|
15
16
|
import { KYCReminder } from './KYCReminder.js';
|
|
16
|
-
export
|
|
17
|
+
export function KYCSumsub(props) {
|
|
17
18
|
const [open, setOpen] = useGlobalStore(useShallow((ctx) => [ctx.kyc.open, ctx.kyc.setOpen]));
|
|
19
|
+
const dummyRef = useRef(null);
|
|
18
20
|
const { data: session } = useSessionQuery();
|
|
19
|
-
const {
|
|
21
|
+
const { data: account } = useAccountQuery();
|
|
22
|
+
const { data: MemberVerification } = useMemberVerificationQuery();
|
|
23
|
+
const isVerified = account?.verificationStatus === 'VERIFIED' ||
|
|
24
|
+
(MemberVerification?.sumsubVerified ?? false);
|
|
25
|
+
const { mutate, mutateAsync, reset, isIdle } = useGenerateSumsubVerificationTokenMutation();
|
|
20
26
|
const [token, setToken] = useState('');
|
|
21
27
|
useEffect(() => {
|
|
22
28
|
if (session?.status === 'authenticated' &&
|
|
@@ -37,123 +43,119 @@ export async function KYCSumsub(props) {
|
|
|
37
43
|
mutate,
|
|
38
44
|
session?.status,
|
|
39
45
|
]);
|
|
40
|
-
return (_jsxs(_Fragment, { children: [_jsx(Dialog.Root, { open: open && session?.status === 'authenticated', onOpenChange: (details) => {
|
|
46
|
+
return (_jsxs(_Fragment, { children: [_jsx(Dialog.Root, { open: open && session?.status === 'authenticated' && !isVerified, onOpenChange: (details) => {
|
|
41
47
|
setOpen(details.open);
|
|
42
|
-
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, initialFocusEl:
|
|
48
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, initialFocusEl: () => dummyRef.current, closeOnInteractOutside: false, restoreFocus: false, onExitComplete: () => {
|
|
43
49
|
reset();
|
|
44
50
|
setToken('');
|
|
45
|
-
}, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { className: "flex items-center justify-center lg:block", children:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
51
|
+
}, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { className: "flex items-center justify-center lg:block", children: _jsxs(Dialog.Content, { className: "mx-auto flex h-full w-[calc(100%-2rem)] flex-col items-center justify-center overflow-y-auto rounded-md bg-transparent p-0 lg:mt-3 lg:block lg:h-auto lg:w-[600px]", children: [_jsx("div", { ref: dummyRef, tabIndex: -1 }), token && (_jsx("div", { className: "max-h-[calc(96dvh-2rem)] w-full overflow-y-auto lg:h-auto lg:max-h-[unset]", children: _jsx(Sumsub, { accessToken: token, expirationHandler: async () => {
|
|
52
|
+
const token = await mutateAsync();
|
|
53
|
+
return token;
|
|
54
|
+
}, config: {
|
|
55
|
+
lang: 'en',
|
|
56
|
+
theme: 'dark',
|
|
57
|
+
}, options: {
|
|
58
|
+
debug: process.env.NODE_ENV === 'development',
|
|
59
|
+
addViewportTag: false,
|
|
60
|
+
adaptIframeHeight: true,
|
|
61
|
+
enableScrollIntoView: true,
|
|
62
|
+
}, onMessage: (type, payload) => {
|
|
63
|
+
/*
|
|
64
|
+
|
|
65
|
+
------------------------
|
|
66
|
+
REJECTED
|
|
67
|
+
------------------------
|
|
68
|
+
|
|
69
|
+
{
|
|
70
|
+
"type": "idCheck.onApplicantStatusChanged",
|
|
71
|
+
"payload": {
|
|
72
|
+
"reviewId": "toJnn",
|
|
73
|
+
"attemptId": "ooaKO",
|
|
74
|
+
"attemptCnt": 1,
|
|
75
|
+
"elapsedSincePendingMs": 1072,
|
|
76
|
+
"elapsedSinceQueuedMs": 1072,
|
|
77
|
+
"reprocessing": true,
|
|
78
|
+
"levelName": "id-and-liveness",
|
|
79
|
+
"levelAutoCheckMode": null,
|
|
80
|
+
"createDate": "2025-07-18 02:08:16+0000",
|
|
81
|
+
"reviewDate": "2025-07-18 02:08:17+0000",
|
|
82
|
+
"reviewResult": {
|
|
83
|
+
"moderationComment": "We couldn’t verify your...",
|
|
84
|
+
"reviewAnswer": "RED",
|
|
85
|
+
"reviewRejectType": "FINAL"
|
|
86
|
+
},
|
|
87
|
+
"reviewStatus": "completed",
|
|
88
|
+
"priority": 0
|
|
89
|
+
}
|
|
83
90
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
91
|
+
|
|
92
|
+
------------------------
|
|
93
|
+
APPROVED
|
|
94
|
+
------------------------
|
|
95
|
+
|
|
96
|
+
{
|
|
97
|
+
"type": "idCheck.onApplicantStatusChanged",
|
|
98
|
+
"payload": {
|
|
99
|
+
"reviewId": "RCAdU",
|
|
100
|
+
"attemptId": "iaOXv",
|
|
101
|
+
"attemptCnt": 1,
|
|
102
|
+
"elapsedSincePendingMs": 1956,
|
|
103
|
+
"elapsedSinceQueuedMs": 1956,
|
|
104
|
+
"reprocessing": true,
|
|
105
|
+
"levelName": "id-and-selfie",
|
|
106
|
+
"levelAutoCheckMode": null,
|
|
107
|
+
"createDate": "2025-07-18 02:17:52+0000",
|
|
108
|
+
"reviewDate": "2025-07-18 02:17:54+0000",
|
|
109
|
+
"reviewResult": {
|
|
110
|
+
"reviewAnswer": "GREEN"
|
|
111
|
+
},
|
|
112
|
+
"reviewStatus": "completed",
|
|
113
|
+
"priority": 0
|
|
114
|
+
}
|
|
108
115
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}, onError: (error) => {
|
|
157
|
-
console.warn(error);
|
|
158
|
-
}, className: "block max-h-full w-full overflow-y-auto rounded-md", force: true }) })) }) })] }) }), _jsx(KYCReminder, { ...props })] }));
|
|
116
|
+
|
|
117
|
+
*/
|
|
118
|
+
const queryClient = getQueryClient();
|
|
119
|
+
if (type === 'idCheck.onApplicantStatusChanged' &&
|
|
120
|
+
isObject(payload) &&
|
|
121
|
+
'reviewStatus' in payload &&
|
|
122
|
+
payload.reviewStatus === 'completed' &&
|
|
123
|
+
'reviewResult' in payload &&
|
|
124
|
+
isObject(payload.reviewResult) &&
|
|
125
|
+
'reviewAnswer' in payload.reviewResult &&
|
|
126
|
+
payload.reviewResult.reviewAnswer === 'GREEN') {
|
|
127
|
+
queryClient.setQueryData(getMemberVerificationQueryKey(), (prev) => ({
|
|
128
|
+
id: '',
|
|
129
|
+
address: '',
|
|
130
|
+
nationality: '',
|
|
131
|
+
natureOfWork: '',
|
|
132
|
+
placeOfBirth: '',
|
|
133
|
+
sourceOfIncome: '',
|
|
134
|
+
permanentAddress: '',
|
|
135
|
+
selfieImage: { id: '', url: '', status: 'READY' },
|
|
136
|
+
idFrontImage: { id: '', url: '', status: 'READY' },
|
|
137
|
+
...(prev ?? {}),
|
|
138
|
+
status: 'APPROVED',
|
|
139
|
+
sumsubVerified: true,
|
|
140
|
+
}));
|
|
141
|
+
queryClient.setQueryData(getAccountQueryKey(), (prev) => {
|
|
142
|
+
if (!prev)
|
|
143
|
+
return prev;
|
|
144
|
+
return {
|
|
145
|
+
...prev,
|
|
146
|
+
verified: true,
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
queryClient.setQueryData(getProfileCompletionQueryKey(), (prev) => {
|
|
150
|
+
if (!prev)
|
|
151
|
+
return prev;
|
|
152
|
+
return {
|
|
153
|
+
...prev,
|
|
154
|
+
accountVerification: true,
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}, onError: (error) => {
|
|
159
|
+
console.warn(error);
|
|
160
|
+
}, className: "block max-h-full w-full overflow-y-auto rounded-md", force: true }) }))] }) })] }) }), _jsx(KYCReminder, { ...props })] }));
|
|
159
161
|
}
|