@opexa/portal-components 0.0.519 → 0.0.521
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/client/hooks/useAccountQuery.js +31 -1
- package/dist/client/services/refreshSession.d.ts +2 -0
- package/dist/client/services/refreshSession.js +17 -0
- package/dist/components/KYC/KYCDefault/IdentityVerification.js +3 -6
- package/dist/components/KYC/KYCDefault/Indicator.js +1 -1
- package/dist/components/KYC/KYCDefault/KYCDefault.d.ts +1 -0
- package/dist/components/KYC/KYCDefault/KYCDefault.js +3 -28
- package/dist/components/KYC/KYCDefault/PersonalInformation.js +1 -4
- package/dist/components/KYC/KYCDefault/useKYCDefault.d.ts +2 -1
- package/dist/components/KYC/KYCDefault/useKYCDefault.js +3 -2
- package/dist/components/KYC/KYCReminder.lazy.js +24 -9
- package/dist/components/KYC/KYCSumsub.d.ts +1 -0
- package/dist/components/KYC/KycOpenOnHomeMount.d.ts +4 -1
- package/dist/components/KYC/KycOpenOnHomeMount.js +15 -15
- package/dist/components/PortalProvider/CXDTokenObserver.js +11 -11
- package/dist/constants/EnvVar.d.ts +1 -1
- package/dist/handlers/deleteAccessTokenSession.d.ts +9 -0
- package/dist/handlers/deleteAccessTokenSession.js +9 -0
- package/dist/handlers/index.js +4 -0
- package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
- package/dist/ui/Badge/Badge.d.ts +12 -12
- package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
- package/dist/ui/Badge/badge.recipe.d.ts +3 -3
- package/dist/ui/Carousel/Carousel.d.ts +99 -99
- package/dist/ui/Carousel/carousel.recipe.d.ts +11 -11
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/ui/Dialog/Dialog.d.ts +33 -33
- package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Field/Field.d.ts +21 -21
- package/dist/ui/Field/field.recipe.d.ts +3 -3
- package/dist/ui/Menu/Menu.d.ts +307 -307
- package/dist/ui/Menu/menu.recipe.d.ts +17 -17
- package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
- package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
- package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
- package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
- package/dist/ui/PinInput/PinInput.d.ts +12 -12
- package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
- package/dist/ui/Popover/Popover.d.ts +55 -55
- package/dist/ui/Popover/popover.recipe.d.ts +5 -5
- package/dist/ui/Progress/Progress.d.ts +27 -27
- package/dist/ui/Progress/progress.recipe.d.ts +3 -3
- package/dist/ui/QrCode/QrCode.d.ts +25 -25
- package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
- package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
- package/dist/ui/Select/Select.d.ts +45 -45
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.anatomy.d.ts +1 -1
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/package.json +1 -1
- package/dist/components/AccountInfo/GoogleDisconnect.d.ts +0 -7
- package/dist/components/AccountInfo/GoogleDisconnect.js +0 -11
- package/dist/components/DigitainLauncher/Loading.d.ts +0 -1
- package/dist/components/DigitainLauncher/Loading.js +0 -5
- package/dist/components/KYC/BasicInformation.d.ts +0 -1
- package/dist/components/KYC/BasicInformation.js +0 -101
- package/dist/components/KYC/IdentityVerification.d.ts +0 -1
- package/dist/components/KYC/IdentityVerification.js +0 -120
- package/dist/components/KYC/Indicator.d.ts +0 -1
- package/dist/components/KYC/Indicator.js +0 -8
- package/dist/components/KYC/KYC.lazy.d.ts +0 -6
- package/dist/components/KYC/KYC.lazy.js +0 -45
- package/dist/components/KYC/KYCContext.d.ts +0 -6
- package/dist/components/KYC/KYCContext.js +0 -2
- package/dist/components/KYC/PersonalInformation.d.ts +0 -1
- package/dist/components/KYC/PersonalInformation.js +0 -122
- package/dist/components/KYC/useKYC.d.ts +0 -25
- package/dist/components/KYC/useKYC.js +0 -38
- package/dist/components/SessionWatcher/SessionWatcher.d.ts +0 -1
- package/dist/components/SessionWatcher/SessionWatcher.js +0 -20
- package/dist/components/SessionWatcher/index.d.ts +0 -1
- package/dist/components/SessionWatcher/index.js +0 -1
- package/dist/icons/LinkBrokenIcon.d.ts +0 -2
- package/dist/icons/LinkBrokenIcon.js +0 -4
- package/dist/images/responsible-gaming-yellow.png +0 -0
|
@@ -5,8 +5,16 @@ import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
|
5
5
|
import { getAccountQueryKey, getSessionQueryKey } from '../../utils/queryKeys.js';
|
|
6
6
|
import { getSession } from '../services/getSession.js';
|
|
7
7
|
import { useSessionQuery } from './useSessionQuery.js';
|
|
8
|
+
import { useFeatureFlag } from './useFeatureFlag.js';
|
|
9
|
+
import { useGlobalStore } from './useGlobalStore.js';
|
|
10
|
+
import { refreshSession } from '../services/refreshSession.js';
|
|
11
|
+
import { useShallow } from 'zustand/shallow';
|
|
8
12
|
export const useAccountQuery = (config) => {
|
|
9
13
|
const sessionQuery = useSessionQuery();
|
|
14
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
15
|
+
kycReminder: ctx.kycReminder,
|
|
16
|
+
})));
|
|
17
|
+
const featureFlag = useFeatureFlag();
|
|
10
18
|
const query = useQuery({
|
|
11
19
|
...config,
|
|
12
20
|
enabled: config?.enabled === false
|
|
@@ -19,12 +27,34 @@ export const useAccountQuery = (config) => {
|
|
|
19
27
|
queryFn: async () => getSession(),
|
|
20
28
|
});
|
|
21
29
|
invariant(session.status === 'authenticated');
|
|
22
|
-
|
|
30
|
+
const res = await getMemberAccount({
|
|
23
31
|
signal,
|
|
24
32
|
headers: {
|
|
25
33
|
Authorization: `Bearer ${session.token}`,
|
|
26
34
|
},
|
|
27
35
|
});
|
|
36
|
+
if (res?.status === "ACTIVE" &&
|
|
37
|
+
res?.verificationStatus === "VERIFIED" &&
|
|
38
|
+
session.status === 'authenticated' &&
|
|
39
|
+
typeof window !== "undefined" &&
|
|
40
|
+
featureFlag.enabled) {
|
|
41
|
+
console.log("it works!");
|
|
42
|
+
globalStore.kycReminder.setOpen(false);
|
|
43
|
+
await refreshSession();
|
|
44
|
+
await getSession();
|
|
45
|
+
}
|
|
46
|
+
return res;
|
|
47
|
+
},
|
|
48
|
+
refetchOnMount: true,
|
|
49
|
+
refetchOnReconnect: true,
|
|
50
|
+
refetchOnWindowFocus: true,
|
|
51
|
+
refetchInterval: (query) => {
|
|
52
|
+
const data = query.state.data;
|
|
53
|
+
if (data?.status === "ACTIVE" &&
|
|
54
|
+
data?.verificationStatus === "VERIFIED") {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return 1500;
|
|
28
58
|
},
|
|
29
59
|
});
|
|
30
60
|
return query;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { httpRequest, } from '../../services/httpRequest.js';
|
|
2
|
+
export async function refreshSession(options) {
|
|
3
|
+
try {
|
|
4
|
+
const res = await httpRequest.json('/api/refresh-sessions', {
|
|
5
|
+
...options,
|
|
6
|
+
method: 'DELETE',
|
|
7
|
+
headers: {
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
Accept: 'application/json',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
return res.ok;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -6,7 +6,6 @@ import { Controller, useForm } from 'react-hook-form';
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { useShallow } from 'zustand/shallow';
|
|
8
8
|
import { useCreateMemberVerificationMutation } from '../../../client/hooks/useCreateMemberVerificationMutation.js';
|
|
9
|
-
import { useFeatureFlag } from '../../../client/hooks/useFeatureFlag.js';
|
|
10
9
|
import { useGlobalStore } from '../../../client/hooks/useGlobalStore.js';
|
|
11
10
|
import { useMemberVerificationQuery } from '../../../client/hooks/useMemberVerificationQuery.js';
|
|
12
11
|
import { useUpdateMemberVerificationMutation } from '../../../client/hooks/useUpdateMemberVerificationMutation.js';
|
|
@@ -25,7 +24,6 @@ const formSchema = z.object({
|
|
|
25
24
|
});
|
|
26
25
|
export function IdentityVerification() {
|
|
27
26
|
const kyc = useKYCDefaultContext();
|
|
28
|
-
const featureFlag = useFeatureFlag();
|
|
29
27
|
const { mutate: createMemberVerification, isPending: createPending } = useCreateMemberVerificationMutation({
|
|
30
28
|
onSuccess: () => {
|
|
31
29
|
toaster.success({
|
|
@@ -86,7 +84,7 @@ export function IdentityVerification() {
|
|
|
86
84
|
placeOfBirth: '',
|
|
87
85
|
sourceOfIncome: '',
|
|
88
86
|
});
|
|
89
|
-
kyc.setStep(
|
|
87
|
+
kyc.setStep(2);
|
|
90
88
|
}
|
|
91
89
|
else {
|
|
92
90
|
updateMemberVerification({
|
|
@@ -96,7 +94,7 @@ export function IdentityVerification() {
|
|
|
96
94
|
idFrontImage: values.idFrontImage,
|
|
97
95
|
},
|
|
98
96
|
});
|
|
99
|
-
kyc.setStep(
|
|
97
|
+
kyc.setStep(2);
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
100
|
useEffect(() => {
|
|
@@ -117,8 +115,7 @@ export function IdentityVerification() {
|
|
|
117
115
|
type: 'validate',
|
|
118
116
|
message: error.message,
|
|
119
117
|
});
|
|
120
|
-
} }), _jsx(Field.ErrorText, { children: o.fieldState.error?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-6", disabled: createPending || updatePending, children: "Continue" }),
|
|
118
|
+
} }), _jsx(Field.ErrorText, { children: o.fieldState.error?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-6", disabled: createPending || updatePending, children: "Continue" }), kyc.isSkippable && (_jsx(Button, { variant: "outline", colorScheme: "gray", className: "mt-lg", onClick: () => {
|
|
121
119
|
globalStore.kyc.setOpen(false);
|
|
122
|
-
globalStore.kycReminder.setOpen(true);
|
|
123
120
|
}, children: "Skip for now" }))] })] }));
|
|
124
121
|
}
|
|
@@ -4,5 +4,5 @@ import { Progress } from '../../../ui/Progress/index.js';
|
|
|
4
4
|
import { useKYCDefaultContext } from './KYCDefaultContext.js';
|
|
5
5
|
export function Indicator() {
|
|
6
6
|
const kyc = useKYCDefaultContext();
|
|
7
|
-
return (_jsxs("div", { className: "flex items-center justify-center gap-1.5 py-3", children: [_jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step >= 1 ? 100 : 0, onValueChange: noop, children: _jsx(Progress.Track, { className: "bg-bg-primary-hover", children: _jsx(Progress.Range, {}) }) }), _jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step
|
|
7
|
+
return (_jsxs("div", { className: "flex items-center justify-center gap-1.5 py-3", children: [_jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step >= 1 ? 100 : 0, onValueChange: noop, children: _jsx(Progress.Track, { className: "bg-bg-primary-hover", children: _jsx(Progress.Range, {}) }) }), _jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step === 2 ? 100 : 0, onValueChange: noop, children: _jsx(Progress.Track, { className: "bg-bg-primary-hover", children: _jsx(Progress.Range, {}) }) })] }));
|
|
8
8
|
}
|
|
@@ -3,5 +3,6 @@ import { type KYCReminderProps } from '../KYCReminder';
|
|
|
3
3
|
export interface KYCDefaultProps extends KYCReminderProps {
|
|
4
4
|
provider?: 'opexa';
|
|
5
5
|
logo: ImageProps['src'];
|
|
6
|
+
isSkippable?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare function KYCDefault(props: KYCDefaultProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import Image from 'next/image';
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
3
|
import { useShallow } from 'zustand/shallow';
|
|
5
|
-
import { useAccountQuery } from '../../../client/hooks/useAccountQuery.js';
|
|
6
4
|
import { useFeatureFlag } from '../../../client/hooks/useFeatureFlag.js';
|
|
7
5
|
import { useGlobalStore } from '../../../client/hooks/useGlobalStore.js';
|
|
8
|
-
import { useMemberVerificationQuery } from '../../../client/hooks/useMemberVerificationQuery.js';
|
|
9
6
|
import { useSessionQuery } from '../../../client/hooks/useSessionQuery.js';
|
|
10
7
|
import { Dialog } from '../../../ui/Dialog/index.js';
|
|
11
8
|
import { Portal } from '../../../ui/Portal/index.js';
|
|
12
9
|
import { KYCReminder } from '../KYCReminder.js';
|
|
13
|
-
import { BasicInformation } from './BasicInformation.js';
|
|
14
10
|
import { IdentityVerification } from './IdentityVerification.js';
|
|
15
11
|
import { Indicator } from './Indicator.js';
|
|
16
12
|
import { KYCDefaultContext } from './KYCDefaultContext.js';
|
|
@@ -19,35 +15,14 @@ import { useKYCDefault } from './useKYCDefault.js';
|
|
|
19
15
|
export function KYCDefault(props) {
|
|
20
16
|
const globalStore = useGlobalStore(useShallow((ctx) => ({ kyc: ctx.kyc, kycReminder: ctx.kycReminder })));
|
|
21
17
|
const featureFlag = useFeatureFlag();
|
|
22
|
-
const kyc = useKYCDefault();
|
|
18
|
+
const kyc = useKYCDefault(props?.isSkippable ?? false);
|
|
23
19
|
const { data: session, isLoading: sessionLoading } = useSessionQuery();
|
|
24
|
-
const { data: account, isLoading: accountLoading } = useAccountQuery();
|
|
25
|
-
const { data: verification } = useMemberVerificationQuery();
|
|
26
|
-
const isBasicInfoCompleted = account?.realName !== null && account?.birthDay !== null;
|
|
27
|
-
const isUploadCompleted = verification?.idFrontImage && verification?.selfieImage;
|
|
28
|
-
const isRejected = verification?.status === 'REJECTED';
|
|
29
|
-
const steps = !isBasicInfoCompleted
|
|
30
|
-
? 1
|
|
31
|
-
: !isUploadCompleted
|
|
32
|
-
? 2
|
|
33
|
-
: isRejected
|
|
34
|
-
? 2
|
|
35
|
-
: 3;
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (steps) {
|
|
38
|
-
kyc.setStep(steps);
|
|
39
|
-
}
|
|
40
|
-
}, [steps, kyc]);
|
|
41
20
|
const isDialogOpen = featureFlag.enabled
|
|
42
|
-
? !globalStore.kycReminder.open &&
|
|
43
|
-
globalStore.kyc.open &&
|
|
44
|
-
!sessionLoading &&
|
|
45
|
-
!accountLoading
|
|
21
|
+
? !globalStore.kycReminder.open && globalStore.kyc.open && !sessionLoading
|
|
46
22
|
: globalStore.kyc.open &&
|
|
47
23
|
!sessionLoading &&
|
|
48
|
-
!accountLoading &&
|
|
49
24
|
session?.status !== 'unauthenticated';
|
|
50
25
|
return (_jsxs(_Fragment, { children: [_jsx(KYCDefaultContext, { value: kyc, children: _jsx(Dialog.Root, { open: isDialogOpen, onOpenChange: (details) => {
|
|
51
26
|
globalStore.kyc.setOpen(details.open);
|
|
52
|
-
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: kyc.reset, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: "mx-auto mt-[10rem] min-h-full w-full overflow-y-auto bg-bg-primary-alt lg:min-h-auto lg:w-fit", children: _jsxs("div", { className: "flex h-dvh w-full flex-col overflow-y-auto p-3xl sm:h-fit sm:overflow-auto lg:w-[400px]", children: [_jsx(Image, { src: props.logo, alt: "", width: 200, height: 100, className: "mx-auto mb-5 block h-7.5 w-auto", draggable: false }), _jsx(Indicator, {}), kyc.step === 1 && _jsx(
|
|
27
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: kyc.reset, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: "mx-auto mt-[10rem] min-h-full w-full overflow-y-auto bg-bg-primary-alt lg:min-h-auto lg:w-fit", children: _jsxs("div", { className: "flex h-dvh w-full flex-col overflow-y-auto p-3xl sm:h-fit sm:overflow-auto lg:w-[400px]", children: [_jsx(Image, { src: props.logo, alt: "", width: 200, height: 100, className: "mx-auto mb-5 block h-7.5 w-auto", draggable: false }), _jsx(Indicator, {}), kyc.step === 1 && _jsx(IdentityVerification, {}), kyc.step === 2 && _jsx(PersonalInformation, {})] }) }) })] }) }) }), _jsx(KYCReminder, { ...props })] }));
|
|
53
28
|
}
|
|
@@ -5,7 +5,6 @@ import { z } from 'zod';
|
|
|
5
5
|
import { useShallow } from 'zustand/shallow';
|
|
6
6
|
import { useApproveMemberVerification } from '../../../client/hooks/useApproveMemberVerification.js';
|
|
7
7
|
import { useCreateMemberVerificationMutation } from '../../../client/hooks/useCreateMemberVerificationMutation.js';
|
|
8
|
-
import { useFeatureFlag } from '../../../client/hooks/useFeatureFlag.js';
|
|
9
8
|
import { useGlobalStore } from '../../../client/hooks/useGlobalStore.js';
|
|
10
9
|
import { useMemberVerificationQuery } from '../../../client/hooks/useMemberVerificationQuery.js';
|
|
11
10
|
import { useUpdateMemberVerificationMutation } from '../../../client/hooks/useUpdateMemberVerificationMutation.js';
|
|
@@ -28,7 +27,6 @@ const definition = z.object({
|
|
|
28
27
|
});
|
|
29
28
|
export function PersonalInformation() {
|
|
30
29
|
const kyc = useKYCDefaultContext();
|
|
31
|
-
const featureFlag = useFeatureFlag();
|
|
32
30
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
33
31
|
kyc: ctx.kyc,
|
|
34
32
|
kycReminder: ctx.kycReminder,
|
|
@@ -124,9 +122,8 @@ export function PersonalInformation() {
|
|
|
124
122
|
});
|
|
125
123
|
}
|
|
126
124
|
}, disabled: !permanentAddress, children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsx(Checkbox.Label, { children: "Use permanent address as current address" }), _jsx(Checkbox.HiddenInput, {})] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.sourceOfIncome, children: [_jsx(Field.Label, { children: "Source of income" }), _jsx(Field.Input, { placeholder: "Enter your source of income", ...form.register('sourceOfIncome') }), _jsx(Field.ErrorText, { children: form.formState.errors.sourceOfIncome?.message })] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.natureOfWork, children: [_jsx(Field.Label, { children: "Work Description" }), _jsx(Field.Input, { placeholder: "Enter your work description", ...form.register('natureOfWork') }), _jsx(Field.ErrorText, { children: form.formState.errors.natureOfWork?.message })] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.placeOfBirth, children: [_jsx(Field.Label, { children: "Place of birth" }), _jsx(Field.Input, { placeholder: "Enter your place of birth", ...form.register('placeOfBirth') }), _jsx(Field.ErrorText, { children: form.formState.errors.placeOfBirth?.message })] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.nationality, children: [_jsx(Field.Label, { children: "Nationality" }), _jsx(Field.Input, { placeholder: "Enter your nationality", ...form.register('nationality') }), _jsx(Field.ErrorText, { children: form.formState.errors.nationality?.message })] }), _jsx(Button, { type: "submit", className: "mt-4xl", disabled: updateMemberVerificationMutation.isPending ||
|
|
127
|
-
createMemberVerificationMutation.isPending, children: "Continue" }),
|
|
125
|
+
createMemberVerificationMutation.isPending, children: "Continue" }), kyc.isSkippable && (_jsx(Button, { variant: "outline", colorScheme: "gray", className: "mt-lg", onClick: () => {
|
|
128
126
|
globalStore.kyc.setOpen(false);
|
|
129
|
-
globalStore.kycReminder.setOpen(true);
|
|
130
127
|
}, disabled: updateMemberVerificationMutation.isPending ||
|
|
131
128
|
createMemberVerificationMutation.isPending, children: "Skip for now" }))] })] }));
|
|
132
129
|
}
|
|
@@ -20,6 +20,7 @@ export interface UseKYCDefaultReturn {
|
|
|
20
20
|
selfieImageId: string | null;
|
|
21
21
|
setSelfieImageId: (id: string | null) => void;
|
|
22
22
|
reset: () => void;
|
|
23
|
+
isSkippable: boolean;
|
|
23
24
|
}
|
|
24
|
-
export declare function useKYCDefault(): UseKYCDefaultReturn;
|
|
25
|
+
export declare function useKYCDefault(isSkippable: boolean): UseKYCDefaultReturn;
|
|
25
26
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useRef, useState } from 'react';
|
|
2
|
-
export function useKYCDefault() {
|
|
3
|
-
const [step, setStep] = useState(
|
|
2
|
+
export function useKYCDefault(isSkippable) {
|
|
3
|
+
const [step, setStep] = useState(1);
|
|
4
4
|
const [done, setDone] = useState(false);
|
|
5
5
|
const [idFrontImageId, setFrontImageId] = useState(null);
|
|
6
6
|
const [selfieImageId, setSelfieImageId] = useState(null);
|
|
@@ -34,5 +34,6 @@ export function useKYCDefault() {
|
|
|
34
34
|
subscribe,
|
|
35
35
|
triggerEvent,
|
|
36
36
|
reset,
|
|
37
|
+
isSkippable,
|
|
37
38
|
};
|
|
38
39
|
}
|
|
@@ -4,7 +4,6 @@ import Image from 'next/image';
|
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { useShallow } from 'zustand/shallow';
|
|
6
6
|
import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
|
|
7
|
-
import { useFeatureFlag } from '../../client/hooks/useFeatureFlag.js';
|
|
8
7
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
9
8
|
import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
|
|
10
9
|
import { FileCheck02Icon } from '../../icons/FileCheck02Icon.js';
|
|
@@ -14,11 +13,24 @@ import responsibleGamingLogo from '../../images/responsible-gaming-gold.png';
|
|
|
14
13
|
import { Button } from '../../ui/Button/index.js';
|
|
15
14
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
16
15
|
import { Portal } from '../../ui/Portal/index.js';
|
|
16
|
+
import { useSignOutMutation } from '../../client/hooks/useSignOutMutation.js';
|
|
17
|
+
import { useRouter } from 'next/navigation';
|
|
18
|
+
import { useFeatureFlag } from '../../client/hooks/useFeatureFlag.js';
|
|
17
19
|
export function KYCReminder(props) {
|
|
20
|
+
const router = useRouter();
|
|
18
21
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
19
22
|
kyc: ctx.kyc,
|
|
20
23
|
kycReminder: ctx.kycReminder,
|
|
24
|
+
account: ctx.account,
|
|
25
|
+
account__mobile: ctx.account__mobile,
|
|
21
26
|
})));
|
|
27
|
+
const signOutMutation = useSignOutMutation({
|
|
28
|
+
onSuccess() {
|
|
29
|
+
localStorage.clear();
|
|
30
|
+
sessionStorage.clear();
|
|
31
|
+
router.replace('/');
|
|
32
|
+
},
|
|
33
|
+
});
|
|
22
34
|
const featureFlag = useFeatureFlag();
|
|
23
35
|
const { data: session, isLoading: sessionLoading } = useSessionQuery();
|
|
24
36
|
const { data: account, isLoading: accountLoading } = useAccountQuery();
|
|
@@ -37,22 +49,25 @@ export function KYCReminder(props) {
|
|
|
37
49
|
globalStore.kycReminder.open &&
|
|
38
50
|
!globalStore.kyc.open &&
|
|
39
51
|
(!isPending || isVerificationLocked) &&
|
|
40
|
-
session?.status === 'authenticated'
|
|
41
|
-
featureFlag.enabled, onOpenChange: (details) => {
|
|
52
|
+
session?.status === 'authenticated', onOpenChange: (details) => {
|
|
42
53
|
globalStore.kycReminder.setOpen(details.open);
|
|
43
|
-
}, closeOnEscape: false, closeOnInteractOutside: false, lazyMount: true, unmountOnExit: true, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+3)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+4)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "mx-auto h-fit max-w-[calc(100dvw-1rem)] overflow-y-auto rounded-lg bg-bg-primary lg:max-w-[400px]", children: [isVerificationLocked && !isPending && (_jsxs("div", { className: "p-3xl text-center", children: [_jsx("div", { className: "mx-auto mb-4 w-fit rounded-full p-2", children: _jsx(Image, { src: props.logo, alt: `${props.siteName} logo`, width: 200, height: 100, className: "mx-auto h-auto w-[120px]", draggable: false }) }), _jsx("h2", { className: `mt-4 font-semibold text-lg ${props.titleBgColor}`, children: "Temporarily Locked" }), _jsx("p", { className: `mt-xs text-sm text-text-tertiary-600 ${props.descriptionBgColor}`, children: "Your account has been locked due to incomplete verification. Please complete your verification to restore full access." }), _jsxs("div", { className: "mt-6 flex w-full items-center justify-center gap-3xl", children: [_jsx(Image, { src: props.pagcorLogo ?? pagcorLogo, alt: "PAGCOR logo", height: 43, width: 88, className: "h-[43px] w-auto shrink-0", draggable: false, unoptimized: true }), _jsx(Image, { src: props.responsibleGamingLogo ?? responsibleGamingLogo, alt: "Responsible Gaming logo", height: 50, width: 186, className: "h-[50px] w-auto shrink-0", draggable: false, unoptimized: true })] }), _jsx(Dialog.Context, { children: (api) => (_jsx("div", { className: "mt-6 space-y-lg", children: _jsx(Button, { onClick: () => {
|
|
54
|
+
}, closeOnEscape: false, closeOnInteractOutside: false, lazyMount: true, unmountOnExit: true, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+3)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+4)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "mx-auto h-fit max-w-[calc(100dvw-1rem)] overflow-y-auto rounded-lg bg-bg-primary lg:max-w-[400px]", children: [isVerificationLocked && !isPending && featureFlag.enabled && (_jsxs("div", { className: "p-3xl text-center", children: [_jsx("div", { className: "mx-auto mb-4 w-fit rounded-full p-2", children: _jsx(Image, { src: props.logo, alt: `${props.siteName} logo`, width: 200, height: 100, className: "mx-auto h-auto w-[120px]", draggable: false }) }), _jsx("h2", { className: `mt-4 font-semibold text-lg ${props.titleBgColor}`, children: "Temporarily Locked" }), _jsx("p", { className: `mt-xs text-sm text-text-tertiary-600 ${props.descriptionBgColor}`, children: "Your account has been locked due to incomplete verification. Please complete your verification to restore full access." }), _jsxs("div", { className: "mt-6 flex w-full items-center justify-center gap-3xl", children: [_jsx(Image, { src: props.pagcorLogo ?? pagcorLogo, alt: "PAGCOR logo", height: 43, width: 88, className: "h-[43px] w-auto shrink-0", draggable: false, unoptimized: true }), _jsx(Image, { src: props.responsibleGamingLogo ?? responsibleGamingLogo, alt: "Responsible Gaming logo", height: 50, width: 186, className: "h-[50px] w-auto shrink-0", draggable: false, unoptimized: true })] }), _jsx(Dialog.Context, { children: (api) => (_jsx("div", { className: "mt-6 space-y-lg", children: _jsx(Button, { onClick: () => {
|
|
44
55
|
api.setOpen(false);
|
|
45
56
|
globalStore.kyc.setOpen(true);
|
|
46
57
|
}, children: "Complete KYC" }) })) })] })), isNotVerified &&
|
|
47
58
|
daysFromCreationToNow <= 3 &&
|
|
48
59
|
daysFromCreationToNow >= 1 &&
|
|
49
|
-
!isVerificationLocked &&
|
|
60
|
+
!isVerificationLocked &&
|
|
61
|
+
featureFlag.enabled && (_jsxs(_Fragment, { children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "p-3xl text-center", children: [_jsx("div", { className: "mx-auto mb-4 w-fit rounded-full bg-bg-primary p-2", children: _jsx(Image, { src: props.logo, alt: `${props.siteName} logo`, width: 200, height: 100, className: "mx-auto h-auto w-[120px]", draggable: false }) }), _jsx("h2", { className: `mt-4 font-semibold text-lg ${props.titleBgColor}`, children: "JUST A FRIENDLY REMINDER" }), _jsxs("p", { className: `mt-xs text-sm text-text-tertiary-600 ${props.descriptionBgColor}`, children: ["Please complete your KYC information within", ' ', _jsx("span", { className: "font-semibold text-[#FF0000]", children: "3 days" }), ' ', "to avoid temporary lock on your account."] }), _jsxs("div", { className: "mt-6 flex w-full items-center justify-center gap-3xl", children: [_jsx(Image, { src: props.pagcorLogo ?? pagcorLogo, alt: "PAGCOR logo", height: 43, width: 88, className: "h-[43px] w-auto shrink-0", draggable: false, unoptimized: true }), _jsx(Image, { src: props.responsibleGamingLogo ?? responsibleGamingLogo, alt: "Responsible Gaming logo", height: 50, width: 186, className: "h-[50px] w-auto shrink-0", draggable: false, unoptimized: true })] }), _jsx(Dialog.Context, { children: (api) => (_jsx("div", { className: "mt-6 space-y-lg", children: _jsx(Button, { onClick: () => {
|
|
50
62
|
api.setOpen(false);
|
|
51
63
|
globalStore.kyc.setOpen(true);
|
|
52
|
-
}, children: "Complete KYC" }) })) })] })] })), isNotVerified &&
|
|
53
|
-
!(daysFromCreationToNow <= 3 && daysFromCreationToNow >= 1) &&
|
|
54
|
-
!isVerificationLocked && (_jsxs(_Fragment, { children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "p-3xl text-center", children: [_jsx("div", { className: "mx-auto w-fit rounded-full bg-bg-primary p-2", children: _jsx(FileCheck02Icon, { className: "text-[#FEDF89]" }) }), _jsx("h2", { className: `mt-4 font-semibold text-lg ${props.titleBgColor}`, children: "Personal Verification" }), _jsxs("p", { className: `mt-xs text-sm text-text-tertiary-600 ${props.descriptionBgColor}`, children: ["All new users are required to complete identity verification to access the full range of ", props.siteName, ' ', "services, including withdrawals."] }), _jsx(Dialog.Context, { children: (api) => (_jsxs("div", { className: "mt-3xl space-y-lg", children: [_jsx(Button, { onClick: () => {
|
|
64
|
+
}, children: "Complete KYC" }) })) })] })] })), (isNotVerified || isPending) && !featureFlag.enabled && (_jsxs(_Fragment, { children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "p-3xl text-center", children: [_jsx("div", { className: "mx-auto w-fit rounded-full bg-bg-primary p-2", children: _jsx(FileCheck02Icon, { className: "text-[#FEDF89]" }) }), _jsx("h2", { className: `mt-4 font-semibold text-lg ${props.titleBgColor}`, children: "Personal Verification" }), _jsxs("p", { className: `mt-xs text-sm text-text-tertiary-600 ${props.descriptionBgColor}`, children: ["All new users are required to complete identity verification to access the full range of ", props.siteName, ' ', "services, including withdrawals."] }), _jsx(Dialog.Context, { children: (api) => (_jsxs("div", { className: "mt-3xl space-y-lg", children: [_jsx(Button, { onClick: () => {
|
|
55
65
|
api.setOpen(false);
|
|
56
66
|
globalStore.kyc.setOpen(true);
|
|
57
|
-
}, children: "Verify Now" }), _jsx(Button, { type: "button", variant: "outline", fullWidth: true, onClick: () => api.setOpen(false), children: "Do it later" })] })) })] })] })), isPending && (_jsxs("div", { className: "p-3xl text-center", children: [_jsx("div", { className: "mx-auto mb-4 w-fit rounded-full bg-bg-primary p-2", children: _jsx(Image, { src: props.logo, alt: `${props.siteName} logo`, width: 200, height: 100, className: "mx-auto h-auto w-[120px]", draggable: false }) }), _jsx("
|
|
67
|
+
}, children: "Verify Now" }), _jsx(Button, { type: "button", variant: "outline", fullWidth: true, onClick: () => api.setOpen(false), children: "Do it later" })] })) })] })] })), isPending && featureFlag.enabled && (_jsxs("div", { className: "p-3xl text-center", children: [_jsx("div", { className: "mx-auto mb-4 w-fit rounded-full bg-bg-primary p-2", children: _jsx(Image, { src: props.logo, alt: `${props.siteName} logo`, width: 200, height: 100, className: "mx-auto h-auto w-[120px]", draggable: false }) }), _jsx("h2", { className: `mt-4 font-semibold text-lg ${props.titleBgColor}`, children: "VERIFICATION IN PROGRESS" }), _jsx("p", { className: `mt-xs text-sm text-text-tertiary-600 ${props.descriptionBgColor}`, children: "Your account is verification-locked. Please wait for approval to regain full access to this platform." }), _jsxs("div", { className: "mt-6 flex w-full items-center justify-center gap-3xl", children: [_jsx(Image, { src: props.pagcorLogo ?? pagcorLogo, alt: "PAGCOR logo", height: 43, width: 88, className: "h-[43px] w-auto shrink-0", draggable: false, unoptimized: true }), _jsx(Image, { src: props.responsibleGamingLogo ?? responsibleGamingLogo, alt: "Responsible Gaming logo", height: 50, width: 186, className: "h-[50px] w-auto shrink-0", draggable: false, unoptimized: true })] }), _jsx(Dialog.Context, { children: (api) => (_jsx("div", { className: "mt-6 space-y-lg", children: _jsx(Button, { onClick: () => {
|
|
68
|
+
signOutMutation.mutate();
|
|
69
|
+
globalStore.account.setOpen(false);
|
|
70
|
+
globalStore.account__mobile.setOpen(false);
|
|
71
|
+
router.push('/');
|
|
72
|
+
}, children: "Log Out" }) })) })] }))] }) })] }) }));
|
|
58
73
|
}
|
|
@@ -3,5 +3,6 @@ import { type KYCReminderProps } from './KYCReminder';
|
|
|
3
3
|
export interface KYCSumsubProps extends KYCReminderProps {
|
|
4
4
|
provider: 'sumsub';
|
|
5
5
|
logo: ImageProps['src'];
|
|
6
|
+
isSkippable: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare function KYCSumsub(props: KYCSumsubProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,14 +4,13 @@ import { useEffect } from 'react';
|
|
|
4
4
|
import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
|
|
5
5
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
6
6
|
import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
|
|
7
|
-
export function KycOpenOnHomeMount() {
|
|
7
|
+
export function KycOpenOnHomeMount(props) {
|
|
8
8
|
const setkycReminderOpen = useGlobalStore((s) => s.kycReminder.setOpen);
|
|
9
9
|
const setkycOpen = useGlobalStore((s) => s.kyc.setOpen);
|
|
10
10
|
const pathname = usePathname();
|
|
11
11
|
const { data: verification, isLoading: verificationLoading } = useMemberVerificationQuery();
|
|
12
12
|
const { data: account, isLoading: accountLoading } = useAccountQuery();
|
|
13
13
|
const isVerificationLocked = account?.status === 'VERIFICATION_LOCKED';
|
|
14
|
-
const isPending = account?.verificationStatus === 'PENDING';
|
|
15
14
|
const hasntSubmittedCompliantDocs = account?.verified ||
|
|
16
15
|
verification?.sumsubVerified ||
|
|
17
16
|
verification?.status === 'APPROVED' ||
|
|
@@ -28,20 +27,21 @@ export function KycOpenOnHomeMount() {
|
|
|
28
27
|
verification?.status === 'PENDING' ||
|
|
29
28
|
verification?.status === 'VERIFIED'
|
|
30
29
|
? false
|
|
31
|
-
:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
: !verification?.nationality ||
|
|
31
|
+
!verification?.natureOfWork ||
|
|
32
|
+
!verification?.sourceOfIncome ||
|
|
33
|
+
!verification?.permanentAddress ||
|
|
34
|
+
!verification?.placeOfBirth ||
|
|
35
|
+
!verification?.address;
|
|
37
36
|
useEffect(() => {
|
|
38
37
|
if (pathname === '/' && !verificationLoading && !accountLoading) {
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
if (hasntSubmittedCompliantDocs || hasntCompletedKYC) {
|
|
39
|
+
if (props.isSkippable) {
|
|
40
|
+
setkycReminderOpen(true);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
setkycOpen(true);
|
|
44
|
+
}
|
|
45
45
|
}
|
|
46
46
|
else if ((!hasntSubmittedCompliantDocs && hasntCompletedKYC) ||
|
|
47
47
|
isVerificationLocked) {
|
|
@@ -52,12 +52,12 @@ export function KycOpenOnHomeMount() {
|
|
|
52
52
|
pathname,
|
|
53
53
|
setkycReminderOpen,
|
|
54
54
|
setkycOpen,
|
|
55
|
+
props.isSkippable,
|
|
55
56
|
hasntSubmittedCompliantDocs,
|
|
56
57
|
verificationLoading,
|
|
57
58
|
accountLoading,
|
|
58
59
|
hasntCompletedKYC,
|
|
59
60
|
isVerificationLocked,
|
|
60
|
-
isPending,
|
|
61
61
|
]);
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { addHours } from 'date-fns';
|
|
3
3
|
import { clamp } from 'lodash-es';
|
|
4
|
-
import { useSearchParams } from 'next/navigation';
|
|
5
4
|
import { useLocalStorage, useTimeout } from 'usehooks-ts';
|
|
6
5
|
import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
|
|
7
6
|
export function CXDTokenObserver() {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const [cxd, setCxd, removeCxd] = useLocalStorage('
|
|
7
|
+
const { data: account } = useAccountQuery();
|
|
8
|
+
const accountCxd = {
|
|
9
|
+
cxd: account?.cellxpertDetails?.cxd,
|
|
10
|
+
};
|
|
11
|
+
const [cxd, setCxd, removeCxd] = useLocalStorage('cxd', null);
|
|
13
12
|
const now = new Date();
|
|
14
|
-
const shouldTimeoutRun = cxdToken && account;
|
|
15
13
|
const removeCxdUntilInMs = cxd?.timestamp
|
|
16
14
|
? clamp(cxd.timestamp - now.getTime(), 0, Infinity)
|
|
17
15
|
: 0;
|
|
18
16
|
useTimeout(() => {
|
|
19
|
-
const isSame = cxd?.cxd ===
|
|
17
|
+
const isSame = cxd?.cxd === accountCxd.cxd;
|
|
20
18
|
if (!isSame) {
|
|
21
19
|
const extendedTimestamp = addHours(new Date(), 6).getTime();
|
|
22
20
|
setCxd({
|
|
23
|
-
cxd:
|
|
21
|
+
cxd: accountCxd.cxd,
|
|
24
22
|
timestamp: extendedTimestamp,
|
|
25
23
|
});
|
|
26
24
|
}
|
|
27
|
-
},
|
|
28
|
-
useTimeout(() =>
|
|
25
|
+
}, account ? 100 : null);
|
|
26
|
+
useTimeout(() => {
|
|
27
|
+
removeCxd();
|
|
28
|
+
}, account ? removeCxdUntilInMs : null);
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const SITE_ID: string;
|
|
2
2
|
export declare const PLATFORM_ID: string;
|
|
3
3
|
export declare const PLATFORM_CODE: string;
|
|
4
|
-
export declare const ENVIRONMENT: "
|
|
4
|
+
export declare const ENVIRONMENT: "production" | "development";
|
|
5
5
|
export declare const INTERNALS__REPORT_WEB_VITALS: boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { ACCESS_TOKEN_COOKIE_NAME, } from '../constants/index.js';
|
|
3
|
+
export async function deleteAccessTokenSession(request) {
|
|
4
|
+
const response = NextResponse.json({
|
|
5
|
+
ok: true,
|
|
6
|
+
});
|
|
7
|
+
response.cookies.delete(ACCESS_TOKEN_COOKIE_NAME);
|
|
8
|
+
return response;
|
|
9
|
+
}
|
package/dist/handlers/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
2
|
import { deleteSession } from './deleteSession.js';
|
|
3
|
+
import { deleteAccessTokenSession } from './deleteAccessTokenSession.js';
|
|
3
4
|
import { getHealthCheck } from './getHealthCheck.js';
|
|
4
5
|
import { getSession } from './getSession.js';
|
|
5
6
|
import { patchSession } from './patchSession.js';
|
|
@@ -22,6 +23,9 @@ export const DELETE = async (req, { params }) => {
|
|
|
22
23
|
if (path === 'sessions') {
|
|
23
24
|
return await deleteSession(req);
|
|
24
25
|
}
|
|
26
|
+
if (path === 'refresh-sessions') {
|
|
27
|
+
return await deleteAccessTokenSession(req);
|
|
28
|
+
}
|
|
25
29
|
return NextResponse.json({ ok: false, message: 'Not found' }, { status: 404 });
|
|
26
30
|
};
|
|
27
31
|
export const POST = async (req, { params }) => {
|