@opexa/portal-components 0.0.493 → 0.0.494

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.
@@ -1,13 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { differenceInCalendarDays } from 'date-fns';
3
- import { isEmpty, isNil } from 'lodash-es';
4
3
  import Image from 'next/image';
5
4
  import { useMemo } from 'react';
6
5
  import { useShallow } from 'zustand/shallow';
7
6
  import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
8
7
  import { useFeatureFlag } from '../../client/hooks/useFeatureFlag.js';
9
8
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
10
- import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
11
9
  import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
12
10
  import { FileCheck02Icon } from '../../icons/FileCheck02Icon.js';
13
11
  import { XIcon } from '../../icons/XIcon.js';
@@ -24,7 +22,6 @@ export function KYCReminder(props) {
24
22
  const { enabled } = useFeatureFlag();
25
23
  const { data: session, isLoading: sessionLoading } = useSessionQuery();
26
24
  const { data: account, isLoading: accountLoading } = useAccountQuery();
27
- const { data: verification, isLoading: verificationLoading } = useMemberVerificationQuery();
28
25
  const isVerificationLocked = account?.status === 'VERIFICATION_LOCKED';
29
26
  const daysFromCreationToNow = useMemo(() => {
30
27
  if (!account?.dateTimeCreated)
@@ -33,24 +30,12 @@ export function KYCReminder(props) {
33
30
  const now = new Date();
34
31
  return differenceInCalendarDays(now, creationDate);
35
32
  }, [account?.dateTimeCreated]);
36
- const hasMissingData = account?.verified || verification?.sumsubVerified
37
- ? false
38
- : isNil(account?.realName) ||
39
- isEmpty(account?.realName) ||
40
- isNil(account?.birthDay) ||
41
- isEmpty(account?.birthDay) ||
42
- isNil(verification?.selfieImage) ||
43
- isEmpty(verification?.selfieImage) ||
44
- isNil(verification?.idFrontImage) ||
45
- isEmpty(verification?.idFrontImage) ||
46
- !isVerificationLocked;
47
33
  return (_jsx(Dialog.Root, { open: !sessionLoading &&
48
34
  !accountLoading &&
49
- !verificationLoading &&
50
35
  globalStore.kycReminder.open &&
51
- (enabled ? true : !isVerificationLocked && !globalStore.kyc.open) &&
52
- session?.status === 'authenticated' &&
53
- hasMissingData, onOpenChange: (details) => {
36
+ !globalStore.kyc.open &&
37
+ (enabled ? true : !isVerificationLocked) &&
38
+ session?.status === 'authenticated', onOpenChange: (details) => {
54
39
  globalStore.kycReminder.setOpen(details.open);
55
40
  }, 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: _jsx(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 && 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", 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: 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: () => {
56
41
  api.setOpen(false);
@@ -5,7 +5,6 @@ import { useEffect, useState } from 'react';
5
5
  import { useShallow } from 'zustand/shallow';
6
6
  import { useGenerateSumsubVerificationTokenMutation } from '../../client/hooks/useGenerateSumsubVerificationTokenMutation.js';
7
7
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
8
- import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
9
8
  import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
10
9
  import { Spinner02Icon } from '../../icons/Spinner02Icon.js';
11
10
  import { Dialog } from '../../ui/Dialog/index.js';
@@ -15,12 +14,7 @@ import { getAccountQueryKey, getMemberVerificationQueryKey, getProfileCompletion
15
14
  import { KYCReminder } from './KYCReminder.js';
16
15
  export async function KYCSumsub(props) {
17
16
  const [open, setOpen] = useGlobalStore(useShallow((ctx) => [ctx.kyc.open, ctx.kyc.setOpen]));
18
- const memberVerification = useMemberVerificationQuery();
19
- const { data: session, isLoading: sessionLoading } = useSessionQuery();
20
- const isVerified = memberVerification.data?.status === 'VERIFIED' ||
21
- memberVerification.data?.sumsubVerified === true ||
22
- memberVerification.data?.status === 'APPROVED' ||
23
- memberVerification.data?.status === 'PENDING';
17
+ const { data: session } = useSessionQuery();
24
18
  const { mutate, mutateAsync, reset, isPending, isIdle } = useGenerateSumsubVerificationTokenMutation();
25
19
  const [token, setToken] = useState('');
26
20
  useEffect(() => {
@@ -38,10 +32,7 @@ export async function KYCSumsub(props) {
38
32
  isIdle,
39
33
  mutate,
40
34
  ]);
41
- return (_jsxs(_Fragment, { children: [_jsx(Dialog.Root, { open: open &&
42
- !isVerified &&
43
- !sessionLoading &&
44
- session?.status === 'authenticated', onOpenChange: (details) => {
35
+ return (_jsxs(_Fragment, { children: [_jsx(Dialog.Root, { open: open && session?.status === 'authenticated', onOpenChange: (details) => {
45
36
  setOpen(details.open);
46
37
  }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
47
38
  reset();
@@ -1,16 +1,56 @@
1
- "use client";
2
- import { useEffect } from "react";
3
- import { usePathname } from "next/navigation";
4
- import { useGlobalStore } from "../../client/hooks/useGlobalStore.js";
1
+ 'use client';
2
+ import { isEmpty, isNil } from 'lodash-es';
3
+ import { usePathname } from 'next/navigation';
4
+ import { useEffect } from 'react';
5
+ import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
6
+ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
7
+ import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
5
8
  export function KycOpenOnHomeMount() {
6
9
  const setkycReminderOpen = useGlobalStore((s) => s.kycReminder.setOpen);
7
10
  const setkycOpen = useGlobalStore((s) => s.kyc.setOpen);
8
11
  const pathname = usePathname();
12
+ const { data: verification } = useMemberVerificationQuery();
13
+ const { data: account } = useAccountQuery();
14
+ const isVerificationLocked = account?.status === 'VERIFICATION_LOCKED';
15
+ const hasntSubmittedCompliantDocs = account?.verified || verification?.sumsubVerified
16
+ ? false
17
+ : isNil(account?.realName) ||
18
+ isEmpty(account?.realName) ||
19
+ isNil(account?.birthDay) ||
20
+ isEmpty(account?.birthDay) ||
21
+ isNil(verification?.selfieImage) ||
22
+ isEmpty(verification?.selfieImage) ||
23
+ isNil(verification?.idFrontImage) ||
24
+ isEmpty(verification?.idFrontImage) ||
25
+ isNil(verification?.address) ||
26
+ isEmpty(verification?.address) ||
27
+ isNil(verification?.permanentAddress) ||
28
+ isEmpty(verification?.permanentAddress) ||
29
+ !isVerificationLocked;
30
+ const hasntCompletedKYC = account?.verified || verification?.sumsubVerified
31
+ ? false
32
+ : isNil(verification?.nationality) ||
33
+ isEmpty(verification?.nationality) ||
34
+ isNil(verification?.natureOfWork) ||
35
+ isEmpty(verification?.natureOfWork) ||
36
+ isNil(verification?.sourceOfIncome) ||
37
+ isEmpty(verification?.sourceOfIncome) ||
38
+ !isVerificationLocked;
9
39
  useEffect(() => {
10
- if (pathname === "/") {
11
- setkycReminderOpen(true);
12
- setkycOpen(true);
40
+ if (pathname === '/') {
41
+ if (hasntSubmittedCompliantDocs) {
42
+ setkycOpen(true);
43
+ }
44
+ if (!hasntSubmittedCompliantDocs && hasntCompletedKYC) {
45
+ setkycReminderOpen(true);
46
+ }
13
47
  }
14
- }, [pathname, setkycReminderOpen, setkycOpen]);
48
+ }, [
49
+ pathname,
50
+ setkycReminderOpen,
51
+ setkycOpen,
52
+ hasntSubmittedCompliantDocs,
53
+ hasntCompletedKYC,
54
+ ]);
15
55
  return null;
16
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.493",
3
+ "version": "0.0.494",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",