@opexa/portal-components 0.0.737 → 0.0.738

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,10 +1,7 @@
1
1
  import { useMutation } from '@tanstack/react-query';
2
- import invariant from 'tiny-invariant';
3
- import { unregisterFCMDevice } from '../../services/trigger.js';
4
2
  import { getQueryClient } from '../../utils/getQueryClient.js';
5
3
  import { getSignOutMutationKey } from '../../utils/mutationKeys.js';
6
4
  import { getSessionQueryKey } from '../../utils/queryKeys.js';
7
- import { getSession } from '../services/getSession.js';
8
5
  import { signOut } from '../services/signOut.js';
9
6
  const IDLE_TIMESTAMP_KEY = 'idle-logout-timestamp';
10
7
  export const useSignOutMutation = (config) => {
@@ -13,18 +10,6 @@ export const useSignOutMutation = (config) => {
13
10
  ...config,
14
11
  mutationKey: getSignOutMutationKey(),
15
12
  mutationFn: async () => {
16
- const session = await getQueryClient().fetchQuery({
17
- queryKey: getSessionQueryKey(),
18
- queryFn: async () => getSession(),
19
- });
20
- invariant(session.status === 'authenticated');
21
- await unregisterFCMDevice({
22
- type: ['IOS', 'ANDROID'],
23
- }, {
24
- headers: {
25
- Authorization: `Bearer ${session.token}`,
26
- },
27
- });
28
13
  await signOut();
29
14
  await queryClient.invalidateQueries({ queryKey: getSessionQueryKey() });
30
15
  queryClient.removeQueries();
@@ -1,10 +1,12 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Capacitor } from '@capacitor/core';
3
4
  import { isString } from 'lodash-es';
4
5
  import Image from 'next/image';
5
6
  import Link from 'next/link';
6
7
  import { useRouter } from 'next/navigation';
7
8
  import { twMerge } from 'tailwind-merge';
9
+ import invariant from 'tiny-invariant';
8
10
  import { useShallow } from 'zustand/shallow';
9
11
  import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
10
12
  import { useBonusesCountQuery } from '../../client/hooks/useBonusesCountQuery.js';
@@ -14,6 +16,7 @@ import { useMayaAuth } from '../../client/hooks/useMayaAuth.js';
14
16
  import { useProfileCompletionQuery } from '../../client/hooks/useProfileCompletionQuery.js';
15
17
  import { useSignOutMutation } from '../../client/hooks/useSignOutMutation.js';
16
18
  import { useUnreadMessagesCountQuery } from '../../client/hooks/useUnreadMessagesCountQuery.js';
19
+ import { getSession } from '../../client/services/getSession.js';
17
20
  import { BIOMETRIC_STORAGE_KEY } from '../../client/utils/biometric.js';
18
21
  import { AlertCircleIcon } from '../../icons/AlertCircleIcon.js';
19
22
  import { Bell01Icon } from '../../icons/Bell01Icon.js';
@@ -24,12 +27,15 @@ import { Gift01Icon } from '../../icons/Gift01Icon.js';
24
27
  import { Logout01Icon } from '../../icons/Logout01Icon.js';
25
28
  import { Settings02Icon } from '../../icons/Settings02Icon.js';
26
29
  import avatarPlaceholder from '../../images/placeholder-avatar.png';
30
+ import { unregisterFCMDevice } from '../../services/trigger.js';
27
31
  import { Badge } from '../../ui/Badge/index.js';
28
32
  import { Drawer } from '../../ui/Drawer/index.js';
29
33
  import { Popover } from '../../ui/Popover/index.js';
30
34
  import { Portal } from '../../ui/Portal/index.js';
31
35
  import { capitalize } from '../../utils/capitalize.js';
36
+ import { getQueryClient } from '../../utils/getQueryClient.js';
32
37
  import { parseDecimal } from '../../utils/parseDecimal.js';
38
+ import { getSessionQueryKey } from '../../utils/queryKeys.js';
33
39
  import { AccountPropsContext, useAccountPropsContext } from './AccountContext.js';
34
40
  import { accountRecipe } from './account.recipe.js';
35
41
  import { Wallet } from './Wallet.js';
@@ -76,7 +82,7 @@ export function Account(props) {
76
82
  strategy: 'fixed',
77
83
  }, ids: {
78
84
  trigger: 'opexa-powerplay:account-trigger',
79
- }, children: _jsx(Portal, { children: _jsx(Popover.Positioner, { children: _jsxs(Popover.Content, { className: 'relative z-popover max-h-[80vh] w-[23.438rem] ui-closed:animate-fade-out ui-open:animate-fade-in overflow-y-auto overscroll-contain rounded-xl border border-border-primary bg-bg-primary p-xl', style: {
85
+ }, children: _jsx(Portal, { children: _jsx(Popover.Positioner, { children: _jsxs(Popover.Content, { className: "relative z-popover max-h-[80vh] w-[23.438rem] ui-closed:animate-fade-out ui-open:animate-fade-in overflow-y-auto overscroll-contain rounded-xl border border-border-primary bg-bg-primary p-xl", style: {
80
86
  WebkitOverflowScrolling: 'touch',
81
87
  }, children: [_jsx(Profile, {}), _jsx(Wallet, { classNames: classNames }), _jsx(Links, { router: router, classNames: classNames })] }) }) }) })] }));
82
88
  }
@@ -104,19 +110,31 @@ function Links({ router, classNames, }) {
104
110
  messages: ctx.messages,
105
111
  })));
106
112
  const signOutMutation = useSignOutMutation({
107
- onSuccess() {
113
+ onSuccess: async () => {
108
114
  // Clear everything except the 'biometric' entry
109
- {
110
- const keep = new Set([BIOMETRIC_STORAGE_KEY]);
111
- for (let i = 0; i < localStorage.length;) {
112
- const key = localStorage.key(i);
113
- if (key && !keep.has(key)) {
114
- localStorage.removeItem(key);
115
- }
116
- else {
117
- i++;
118
- }
115
+ const keep = new Set([BIOMETRIC_STORAGE_KEY]);
116
+ for (let i = 0; i < localStorage.length;) {
117
+ const key = localStorage.key(i);
118
+ if (key && !keep.has(key)) {
119
+ localStorage.removeItem(key);
119
120
  }
121
+ else {
122
+ i++;
123
+ }
124
+ }
125
+ if (Capacitor.isNativePlatform()) {
126
+ const session = await getQueryClient().fetchQuery({
127
+ queryKey: getSessionQueryKey(),
128
+ queryFn: async () => getSession(),
129
+ });
130
+ invariant(session.status === 'authenticated');
131
+ await unregisterFCMDevice({
132
+ type: ['IOS', 'ANDROID'],
133
+ }, {
134
+ headers: {
135
+ Authorization: `Bearer ${session.token}`,
136
+ },
137
+ });
120
138
  }
121
139
  sessionStorage.clear();
122
140
  router.replace('/');
@@ -1,20 +1,26 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Capacitor } from '@capacitor/core';
3
4
  import Image from 'next/image';
4
5
  import { useState } from 'react';
5
6
  import { twMerge } from 'tailwind-merge';
7
+ import invariant from 'tiny-invariant';
6
8
  import { useShallow } from 'zustand/shallow';
7
9
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
8
10
  import { useSignOutMutation } from '../../client/hooks/useSignOutMutation.js';
11
+ import { getSession } from '../../client/services/getSession.js';
9
12
  import { BIOMETRIC_STORAGE_KEY } from '../../client/utils/biometric.js';
10
13
  import { AlertCircleIcon } from '../../icons/AlertCircleIcon.js';
11
14
  import { CheckIcon } from '../../icons/CheckIcon.js';
12
15
  import pagcorLogo from '../../images/pagcor2.png';
13
16
  import responsibleGamingLogo from '../../images/responsible-gaming.png';
17
+ import { unregisterFCMDevice } from '../../services/trigger.js';
14
18
  import { Button } from '../../ui/Button/index.js';
15
19
  import { Checkbox } from '../../ui/Checkbox/index.js';
16
20
  import { Dialog } from '../../ui/Dialog/index.js';
17
21
  import { Portal } from '../../ui/Portal/index.js';
22
+ import { getQueryClient } from '../../utils/getQueryClient.js';
23
+ import { getSessionQueryKey } from '../../utils/queryKeys.js';
18
24
  import { useDisclaimer } from './useDisclaimer.js';
19
25
  export function DisclaimerV2(props) {
20
26
  const disclaimer = useDisclaimer({
@@ -27,7 +33,7 @@ export function DisclaimerV2(props) {
27
33
  const checked = globalStore.termsOfUse.accepted && globalStore.responsibleGaming.accepted;
28
34
  const [showWarning, setShowWarning] = useState(false);
29
35
  const signOutMutation = useSignOutMutation({
30
- onSuccess() {
36
+ async onSuccess() {
31
37
  // Clear everything except the 'biometric' entry
32
38
  const keep = new Set([BIOMETRIC_STORAGE_KEY]);
33
39
  for (let i = 0; i < localStorage.length;) {
@@ -39,6 +45,20 @@ export function DisclaimerV2(props) {
39
45
  i++;
40
46
  }
41
47
  }
48
+ if (Capacitor.isNativePlatform()) {
49
+ const session = await getQueryClient().fetchQuery({
50
+ queryKey: getSessionQueryKey(),
51
+ queryFn: async () => getSession(),
52
+ });
53
+ invariant(session.status === 'authenticated');
54
+ await unregisterFCMDevice({
55
+ type: ['IOS', 'ANDROID'],
56
+ }, {
57
+ headers: {
58
+ Authorization: `Bearer ${session.token}`,
59
+ },
60
+ });
61
+ }
42
62
  sessionStorage.clear();
43
63
  },
44
64
  });
@@ -3,7 +3,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { ark } from '@ark-ui/react/factory';
4
4
  import { Capacitor } from '@capacitor/core';
5
5
  import { BiometricAuthError } from 'capacitor-native-biometric';
6
- import { useState } from 'react';
7
6
  import { useShallow } from 'zustand/shallow';
8
7
  import { useCreateGameSessionMutation } from '../../client/hooks/useCreateGameSessionMutation.js';
9
8
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
@@ -27,7 +26,6 @@ export function GameLaunchTrigger(props) {
27
26
  gameLaunch: ctx.gameLaunch,
28
27
  kycVerificationStatus: ctx.kycVerificationStatus,
29
28
  })));
30
- const [hasCancelledBiometric, setHasCancelledBiometric] = useState(false);
31
29
  const verificationStatus = verificationQuery.data?.status ?? 'UNVERIFIED';
32
30
  const currentHour = new Date().getHours();
33
31
  const between3amAnd3pm = currentHour >= 15 || currentHour < 3;
@@ -49,7 +47,7 @@ export function GameLaunchTrigger(props) {
49
47
  : 'open', ...props, disabled: disabled, onClick: async (e) => {
50
48
  props.onClick?.(e);
51
49
  if (sessionQuery.data?.status === 'unauthenticated') {
52
- if (hasSavedBiometry() && !hasCancelledBiometric) {
50
+ if (hasSavedBiometry()) {
53
51
  const ok = await performBiometricVerification({
54
52
  reason: 'Login to your account',
55
53
  title: 'Login',
@@ -64,7 +62,6 @@ export function GameLaunchTrigger(props) {
64
62
  info.errorCode === BiometricAuthError.SYSTEM_CANCEL ||
65
63
  info.errorCode === undefined ||
66
64
  info.errorCode === null) {
67
- setHasCancelledBiometric(true);
68
65
  console.log('Biometric verification cancelled');
69
66
  }
70
67
  else {
@@ -1,9 +1,11 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Capacitor } from '@capacitor/core';
3
4
  import { zodResolver } from '@hookform/resolvers/zod';
4
5
  import { useRouter } from 'next/navigation';
5
6
  import { useEffect } from 'react';
6
7
  import { Controller, useForm } from 'react-hook-form';
8
+ import invariant from 'tiny-invariant';
7
9
  import { z } from 'zod';
8
10
  import { useShallow } from 'zustand/shallow';
9
11
  import { useCreateMemberVerificationMutation } from '../../../client/hooks/useCreateMemberVerificationMutation.js';
@@ -11,12 +13,14 @@ import { useGlobalStore } from '../../../client/hooks/useGlobalStore.js';
11
13
  import { useMemberVerificationQuery } from '../../../client/hooks/useMemberVerificationQuery.js';
12
14
  import { useSignOutMutation } from '../../../client/hooks/useSignOutMutation.js';
13
15
  import { useUpdateMemberVerificationMutation } from '../../../client/hooks/useUpdateMemberVerificationMutation.js';
16
+ import { getSession } from '../../../client/services/getSession.js';
14
17
  import { toaster } from '../../../client/utils/toaster.js';
18
+ import { unregisterFCMDevice } from '../../../services/trigger.js';
15
19
  import { Button } from '../../../ui/Button/index.js';
16
20
  import { Dialog } from '../../../ui/Dialog/index.js';
17
21
  import { Field } from '../../../ui/Field/index.js';
18
22
  import { getQueryClient } from '../../../utils/getQueryClient.js';
19
- import { getMemberVerificationQueryKey } from '../../../utils/queryKeys.js';
23
+ import { getMemberVerificationQueryKey, getSessionQueryKey, } from '../../../utils/queryKeys.js';
20
24
  import { IdFrontImageField } from '../../shared/IdFrontImageField/index.js';
21
25
  import { SelfieImageField } from '../../shared/SelfieImageField/index.js';
22
26
  import { useKYCDefaultContext } from './KYCDefaultContext.js';
@@ -28,10 +32,24 @@ export function IdentityVerification() {
28
32
  const kyc = useKYCDefaultContext();
29
33
  const router = useRouter();
30
34
  const signOutMutation = useSignOutMutation({
31
- onSuccess() {
35
+ async onSuccess() {
32
36
  localStorage.clear();
33
37
  sessionStorage.clear();
34
38
  router.replace('/');
39
+ if (Capacitor.isNativePlatform()) {
40
+ const session = await getQueryClient().fetchQuery({
41
+ queryKey: getSessionQueryKey(),
42
+ queryFn: async () => getSession(),
43
+ });
44
+ invariant(session.status === 'authenticated');
45
+ await unregisterFCMDevice({
46
+ type: ['IOS', 'ANDROID'],
47
+ }, {
48
+ headers: {
49
+ Authorization: `Bearer ${session.token}`,
50
+ },
51
+ });
52
+ }
35
53
  },
36
54
  });
37
55
  const { mutate: createMemberVerification, isPending: createPending } = useCreateMemberVerificationMutation({
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Capacitor } from '@capacitor/core';
2
3
  import { zodResolver } from '@hookform/resolvers/zod';
3
4
  import { useRouter } from 'next/navigation';
4
5
  import { useForm } from 'react-hook-form';
6
+ import invariant from 'tiny-invariant';
5
7
  import { z } from 'zod';
6
8
  import { useShallow } from 'zustand/shallow';
7
9
  import { useApproveMemberVerification } from '../../../client/hooks/useApproveMemberVerification.js';
@@ -10,15 +12,17 @@ import { useGlobalStore } from '../../../client/hooks/useGlobalStore.js';
10
12
  import { useMemberVerificationQuery } from '../../../client/hooks/useMemberVerificationQuery.js';
11
13
  import { useSignOutMutation } from '../../../client/hooks/useSignOutMutation.js';
12
14
  import { useUpdateMemberVerificationMutation } from '../../../client/hooks/useUpdateMemberVerificationMutation.js';
15
+ import { getSession } from '../../../client/services/getSession.js';
13
16
  import { BIOMETRIC_STORAGE_KEY } from '../../../client/utils/biometric.js';
14
17
  import { toaster } from '../../../client/utils/toaster.js';
15
18
  import { CheckIcon } from '../../../icons/CheckIcon.js';
19
+ import { unregisterFCMDevice } from '../../../services/trigger.js';
16
20
  import { Button } from '../../../ui/Button/index.js';
17
21
  import { Checkbox } from '../../../ui/Checkbox/index.js';
18
22
  import { Dialog } from '../../../ui/Dialog/index.js';
19
23
  import { Field } from '../../../ui/Field/index.js';
20
24
  import { getQueryClient } from '../../../utils/getQueryClient.js';
21
- import { getMemberVerificationQueryKey } from '../../../utils/queryKeys.js';
25
+ import { getMemberVerificationQueryKey, getSessionQueryKey, } from '../../../utils/queryKeys.js';
22
26
  import { useKYCDefaultContext } from './KYCDefaultContext.js';
23
27
  const definition = z.object({
24
28
  address: z.string().trim().min(1, 'Current address is required'),
@@ -38,7 +42,7 @@ export function PersonalInformation() {
38
42
  const memberVerificationId = memberVerificationQuery.data?.id;
39
43
  const router = useRouter();
40
44
  const signOutMutation = useSignOutMutation({
41
- onSuccess() {
45
+ async onSuccess() {
42
46
  const keep = new Set([BIOMETRIC_STORAGE_KEY]);
43
47
  for (let i = 0; i < localStorage.length;) {
44
48
  const key = localStorage.key(i);
@@ -49,6 +53,20 @@ export function PersonalInformation() {
49
53
  i++;
50
54
  }
51
55
  }
56
+ if (Capacitor.isNativePlatform()) {
57
+ const session = await getQueryClient().fetchQuery({
58
+ queryKey: getSessionQueryKey(),
59
+ queryFn: async () => getSession(),
60
+ });
61
+ invariant(session.status === 'authenticated');
62
+ await unregisterFCMDevice({
63
+ type: ['IOS', 'ANDROID'],
64
+ }, {
65
+ headers: {
66
+ Authorization: `Bearer ${session.token}`,
67
+ },
68
+ });
69
+ }
52
70
  sessionStorage.clear();
53
71
  router.replace('/');
54
72
  },
@@ -1,21 +1,27 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Capacitor } from '@capacitor/core';
2
3
  import { differenceInCalendarDays } from 'date-fns';
3
4
  import Image from 'next/image';
4
5
  import { useRouter } from 'next/navigation';
5
6
  import { useMemo } from 'react';
7
+ import invariant from 'tiny-invariant';
6
8
  import { useShallow } from 'zustand/shallow';
7
9
  import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
8
10
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
9
11
  import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
10
12
  import { useSignOutMutation } from '../../client/hooks/useSignOutMutation.js';
13
+ import { getSession } from '../../client/services/getSession.js';
11
14
  import { BIOMETRIC_STORAGE_KEY } from '../../client/utils/biometric.js';
12
15
  import { FileCheck02Icon } from '../../icons/FileCheck02Icon.js';
13
16
  import { XIcon } from '../../icons/XIcon.js';
14
17
  import pagcorLogo from '../../images/pagcor.png';
15
18
  import responsibleGamingLogo from '../../images/responsible-gaming-gold.png';
19
+ import { unregisterFCMDevice } from '../../services/trigger.js';
16
20
  import { Button } from '../../ui/Button/index.js';
17
21
  import { Dialog } from '../../ui/Dialog/index.js';
18
22
  import { Portal } from '../../ui/Portal/index.js';
23
+ import { getQueryClient } from '../../utils/getQueryClient.js';
24
+ import { getSessionQueryKey } from '../../utils/queryKeys.js';
19
25
  export function KYCReminder(props) {
20
26
  const router = useRouter();
21
27
  const globalStore = useGlobalStore(useShallow((ctx) => ({
@@ -26,7 +32,7 @@ export function KYCReminder(props) {
26
32
  responsibleGamingReminder: ctx.responsibleGamingReminder,
27
33
  })));
28
34
  const signOutMutation = useSignOutMutation({
29
- onSuccess() {
35
+ async onSuccess() {
30
36
  // Clear everything except the 'biometric' entry
31
37
  const keep = new Set([BIOMETRIC_STORAGE_KEY]);
32
38
  for (let i = 0; i < localStorage.length;) {
@@ -38,6 +44,20 @@ export function KYCReminder(props) {
38
44
  i++;
39
45
  }
40
46
  }
47
+ if (Capacitor.isNativePlatform()) {
48
+ const session = await getQueryClient().fetchQuery({
49
+ queryKey: getSessionQueryKey(),
50
+ queryFn: async () => getSession(),
51
+ });
52
+ invariant(session.status === 'authenticated');
53
+ await unregisterFCMDevice({
54
+ type: ['IOS', 'ANDROID'],
55
+ }, {
56
+ headers: {
57
+ Authorization: `Bearer ${session.token}`,
58
+ },
59
+ });
60
+ }
41
61
  sessionStorage.clear();
42
62
  router.replace('/');
43
63
  },
@@ -1,4 +1,4 @@
1
- import { type ComponentPropsWithRef } from 'react';
1
+ import type { ComponentPropsWithRef } from 'react';
2
2
  interface SignInTriggerProps extends ComponentPropsWithRef<'button'> {
3
3
  asChild?: boolean;
4
4
  }
@@ -2,7 +2,6 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { ark } from '@ark-ui/react/factory';
4
4
  import { Capacitor } from '@capacitor/core';
5
- import { useState } from 'react';
6
5
  import { useShallow } from 'zustand/shallow';
7
6
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
8
7
  import { getSession } from '../../client/services/getSession.js';
@@ -15,13 +14,12 @@ import { getQueryClient } from '../../utils/getQueryClient.js';
15
14
  import { getSessionQueryKey } from '../../utils/queryKeys.js';
16
15
  import { LOCALSTORAGE_PUSH_NOTIFICATION_TOKEN_KEY } from '../PortalProvider/PushNotifications.js';
17
16
  export function SignInTrigger(props) {
18
- const [hasCancelledBiometric, setHasCancelledBiometric] = useState(false);
19
17
  const globalStore = useGlobalStore(useShallow((ctx) => ({
20
18
  signIn: ctx.signIn,
21
19
  registerBiometrics: ctx.registerBiometrics,
22
20
  })));
23
21
  return (_jsx(ark.button, { type: "button", "aria-label": "Sign in", "data-state": globalStore.signIn.open ? 'open' : 'closed', ...props, onClick: async (e) => {
24
- if (hasSavedBiometry() && !hasCancelledBiometric) {
22
+ if (hasSavedBiometry()) {
25
23
  const ok = await performBiometricVerification({
26
24
  reason: 'Login to your account',
27
25
  title: 'Login',
@@ -36,7 +34,6 @@ export function SignInTrigger(props) {
36
34
  info.errorCode === BiometricAuthError.SYSTEM_CANCEL ||
37
35
  info.errorCode === undefined ||
38
36
  info.errorCode === null) {
39
- setHasCancelledBiometric(true);
40
37
  console.log('Biometric verification cancelled');
41
38
  }
42
39
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.737",
3
+ "version": "0.0.738",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",