@opexa/portal-components 0.0.394 → 0.0.396

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.
Files changed (47) hide show
  1. package/dist/client/hooks/useIdleLogout.js +0 -1
  2. package/dist/client/hooks/useSignOutMutation.js +3 -1
  3. package/dist/client/hooks/useSignUpMutation.js +3 -2
  4. package/dist/components/PortalProvider/CXDTokenObserver.js +11 -11
  5. package/dist/components/PortalProvider/Providers.d.ts +1 -1
  6. package/dist/components/PortalProvider/Providers.js +2 -1
  7. package/dist/components/SignUp/SignUpDefault/SignUpDefaultForm.js +3 -1
  8. package/dist/components/SignUp/SignUpKYC/SignUpKYCForm.js +3 -1
  9. package/dist/constants/StorageKey.d.ts +0 -1
  10. package/dist/constants/StorageKey.js +0 -1
  11. package/dist/handlers/getSession.js +1 -4
  12. package/dist/handlers/index.d.ts +7 -7
  13. package/dist/handlers/patchSession.js +2 -9
  14. package/dist/ui/AlertDialog/AlertDialog.d.ts +121 -121
  15. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +11 -11
  16. package/dist/ui/Avatar/Avatar.d.ts +9 -9
  17. package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
  18. package/dist/ui/Carousel/Carousel.d.ts +99 -99
  19. package/dist/ui/Carousel/carousel.recipe.d.ts +11 -11
  20. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  21. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  22. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  23. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  24. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  25. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  26. package/dist/ui/Dialog/Dialog.d.ts +121 -121
  27. package/dist/ui/Dialog/dialog.recipe.d.ts +11 -11
  28. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  29. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  30. package/dist/ui/Field/Field.d.ts +21 -21
  31. package/dist/ui/Field/field.recipe.d.ts +3 -3
  32. package/dist/ui/Menu/Menu.d.ts +144 -144
  33. package/dist/ui/Menu/menu.recipe.d.ts +8 -8
  34. package/dist/ui/Popover/Popover.d.ts +121 -121
  35. package/dist/ui/Popover/popover.recipe.d.ts +11 -11
  36. package/dist/ui/Progress/Progress.d.ts +27 -27
  37. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  38. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  39. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  40. package/dist/ui/Select/Select.d.ts +45 -45
  41. package/dist/ui/Select/select.recipe.d.ts +3 -3
  42. package/dist/ui/Table/Table.d.ts +21 -21
  43. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  44. package/dist/ui/Table/table.recipe.d.ts +3 -3
  45. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  46. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  47. package/package.json +1 -1
@@ -57,7 +57,6 @@ export function useIdleLogout(timer = DEFAULT_IDLE_TIMER) {
57
57
  }
58
58
  return () => {
59
59
  window.removeEventListener('beforeunload', handleUnload);
60
- handleUnload();
61
60
  };
62
61
  }, [sessionQuery.data?.status, signOutMutation, timer]);
63
62
  useEffect(() => {
@@ -3,6 +3,7 @@ import { getQueryClient } from '../../utils/getQueryClient.js';
3
3
  import { getSignOutMutationKey } from '../../utils/mutationKeys.js';
4
4
  import { getSessionQueryKey } from '../../utils/queryKeys.js';
5
5
  import { signOut } from '../services/signOut.js';
6
+ const IDLE_TIMESTAMP_KEY = 'idle-logout-timestamp';
6
7
  export const useSignOutMutation = (config) => {
7
8
  const queryClient = getQueryClient();
8
9
  return useMutation({
@@ -11,7 +12,8 @@ export const useSignOutMutation = (config) => {
11
12
  mutationFn: async () => {
12
13
  await signOut();
13
14
  await queryClient.invalidateQueries({ queryKey: getSessionQueryKey() });
14
- queryClient.clear();
15
+ queryClient.removeQueries();
16
+ localStorage.removeItem(IDLE_TIMESTAMP_KEY);
15
17
  },
16
18
  });
17
19
  };
@@ -3,6 +3,7 @@ import { registerMemberAccountViaMobile, } from '../../services/account.js';
3
3
  import { getSignUpMutationKey } from '../../utils/mutationKeys.js';
4
4
  import { getSession } from '../services/getSession.js';
5
5
  export const useSignUpMutation = (config) => {
6
+ const cellxpertCxd = config?.meta?.cellxpertCxd;
6
7
  return useMutation({
7
8
  ...config,
8
9
  mutationKey: getSignUpMutationKey(),
@@ -13,8 +14,8 @@ export const useSignUpMutation = (config) => {
13
14
  ...(session.btag && {
14
15
  btag: session.btag,
15
16
  }),
16
- ...(session.cellxpertCxd && {
17
- cellxpertCxd: session.cellxpertCxd,
17
+ ...(cellxpertCxd && {
18
+ cellxpertCxd,
18
19
  }),
19
20
  }, {
20
21
  headers: {
@@ -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';
4
5
  import { useLocalStorage, useTimeout } from 'usehooks-ts';
5
6
  import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
6
7
  export function CXDTokenObserver() {
7
- const { data: account } = useAccountQuery();
8
- const accountCxd = {
9
- cxd: account?.cellxpertDetails?.cxd,
10
- };
11
- const [cxd, setCxd, removeCxd] = useLocalStorage('cxd', null);
8
+ const searchParams = useSearchParams();
9
+ const cxdToken = searchParams.get('cxd');
10
+ const accountQuery = useAccountQuery();
11
+ const account = accountQuery.data;
12
+ const [cxd, setCxd, removeCxd] = useLocalStorage('WebPortalCellxpertCxd', null);
12
13
  const now = new Date();
14
+ const shouldTimeoutRun = cxdToken && account;
13
15
  const removeCxdUntilInMs = cxd?.timestamp
14
16
  ? clamp(cxd.timestamp - now.getTime(), 0, Infinity)
15
17
  : 0;
16
18
  useTimeout(() => {
17
- const isSame = cxd?.cxd === accountCxd.cxd;
19
+ const isSame = cxd?.cxd === cxdToken;
18
20
  if (!isSame) {
19
21
  const extendedTimestamp = addHours(new Date(), 6).getTime();
20
22
  setCxd({
21
- cxd: accountCxd.cxd,
23
+ cxd: cxdToken,
22
24
  timestamp: extendedTimestamp,
23
25
  });
24
26
  }
25
- }, account ? 100 : null);
26
- useTimeout(() => {
27
- removeCxd();
28
- }, account ? removeCxdUntilInMs : null);
27
+ }, shouldTimeoutRun ? 100 : null);
28
+ useTimeout(() => removeCxd(), shouldTimeoutRun ? removeCxdUntilInMs : null);
29
29
  return null;
30
30
  }
@@ -1,4 +1,4 @@
1
- import type { PropsWithChildren } from 'react';
1
+ import { type PropsWithChildren } from 'react';
2
2
  export interface ProvidersProps {
3
3
  recaptchaSiteKey?: string;
4
4
  }
@@ -2,9 +2,10 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { QueryClientProvider } from '@tanstack/react-query';
4
4
  import { ReCaptchaProvider } from 'next-recaptcha-v3';
5
+ import { Suspense } from 'react';
5
6
  import { getQueryClient } from '../../utils/getQueryClient.js';
6
7
  import { CXDTokenObserver } from './CXDTokenObserver.js';
7
8
  export function Providers({ recaptchaSiteKey, children, }) {
8
9
  const queryClient = getQueryClient();
9
- return (_jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(CXDTokenObserver, {}), _jsx(ReCaptchaProvider, { reCaptchaKey: recaptchaSiteKey, children: children })] }));
10
+ return (_jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(Suspense, { children: _jsx(CXDTokenObserver, {}) }), _jsx(ReCaptchaProvider, { reCaptchaKey: recaptchaSiteKey, children: children })] }));
10
11
  }
@@ -59,7 +59,9 @@ export function SignUpDefaultForm() {
59
59
  responsibleGaming: ctx.responsibleGaming,
60
60
  })));
61
61
  const search = useSearchParams();
62
- const signUpMutation = useSignUpMutation();
62
+ const signUpMutation = useSignUpMutation({
63
+ meta: { cellxpertCxd: search.get('cxd') },
64
+ });
63
65
  const signInMutation = useSignInMutation();
64
66
  const updateAccountMutation = useUpdateAccountMutation();
65
67
  const sendVerificationCodeMutation = useSendVerificationCodeMutation();
@@ -67,7 +67,9 @@ export function SignUpKYCForm() {
67
67
  })));
68
68
  const dialog = useDialogContext();
69
69
  const search = useSearchParams();
70
- const signUpMutation = useSignUpMutation();
70
+ const signUpMutation = useSignUpMutation({
71
+ meta: { cellxpertCxd: search.get('cxd') },
72
+ });
71
73
  const signInMutation = useSignInMutation();
72
74
  const updateAccountMutation = useUpdateAccountMutation();
73
75
  const sendVerificationCodeMutation = useSendVerificationCodeMutation();
@@ -2,5 +2,4 @@ export declare const ACCESS_TOKEN_COOKIE_NAME: string;
2
2
  export declare const REFRESH_TOKEN_COOKIE_NAME: string;
3
3
  export declare const DOMAIN_COOKIE_NAME: string;
4
4
  export declare const BTAG_COOKIE_NAME: string;
5
- export declare const CELLXPERT_CXD_COOKIE_NAME: string;
6
5
  export declare const FEATURE_FLAG_LOCAL_STORAGE_KEY: string;
@@ -2,5 +2,4 @@ export const ACCESS_TOKEN_COOKIE_NAME = 'WebPortalAuthAccessToken';
2
2
  export const REFRESH_TOKEN_COOKIE_NAME = 'WebPortalAuthRefreshToken';
3
3
  export const DOMAIN_COOKIE_NAME = 'WebPortalDomain';
4
4
  export const BTAG_COOKIE_NAME = 'WebPortalBtag';
5
- export const CELLXPERT_CXD_COOKIE_NAME = 'WebPortalCellxpertCxd';
6
5
  export const FEATURE_FLAG_LOCAL_STORAGE_KEY = 'WebPortalFeatureFlag';
@@ -1,13 +1,12 @@
1
1
  import { addMinutes } from 'date-fns';
2
2
  import { NextResponse } from 'next/server';
3
- import { ACCESS_TOKEN_COOKIE_NAME, BTAG_COOKIE_NAME, CELLXPERT_CXD_COOKIE_NAME, DOMAIN_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
3
+ import { ACCESS_TOKEN_COOKIE_NAME, BTAG_COOKIE_NAME, DOMAIN_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
4
4
  import { refreshSession } from '../services/auth.js';
5
5
  export async function getSession(request) {
6
6
  const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;
7
7
  const refreshToken = request.cookies.get(REFRESH_TOKEN_COOKIE_NAME)?.value;
8
8
  const domain = request.cookies.get(DOMAIN_COOKIE_NAME)?.value;
9
9
  const btag = request.cookies.get(BTAG_COOKIE_NAME)?.value;
10
- const cellxpertCxd = request.cookies.get(CELLXPERT_CXD_COOKIE_NAME)?.value;
11
10
  if (!refreshToken) {
12
11
  const response = NextResponse.json({
13
12
  ok: true,
@@ -15,7 +14,6 @@ export async function getSession(request) {
15
14
  status: 'unauthenticated',
16
15
  domain,
17
16
  btag,
18
- cellxpertCxd,
19
17
  },
20
18
  });
21
19
  response.cookies.delete(ACCESS_TOKEN_COOKIE_NAME);
@@ -58,7 +56,6 @@ export async function getSession(request) {
58
56
  status: 'unauthenticated',
59
57
  domain,
60
58
  btag,
61
- cellxpertCxd,
62
59
  },
63
60
  });
64
61
  response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
@@ -6,26 +6,26 @@ interface Context {
6
6
  params: Promise<Params>;
7
7
  }
8
8
  export declare const GET: (req: NextRequest, { params }: Context) => Promise<NextResponse<{
9
- ok: true;
10
- data?: never;
11
- } | {
12
9
  ok: false;
13
10
  message: string;
14
11
  __error?: unknown;
12
+ } | {
13
+ ok: true;
14
+ data: import("../types").Session;
15
15
  }> | NextResponse<{
16
+ ok: true;
17
+ data?: never;
18
+ } | {
16
19
  ok: false;
17
20
  message: string;
18
21
  __error?: unknown;
19
- } | {
20
- ok: true;
21
- data: Record<string, unknown>;
22
22
  }> | NextResponse<{
23
23
  ok: false;
24
24
  message: string;
25
25
  __error?: unknown;
26
26
  } | {
27
27
  ok: true;
28
- data: import("../types").Session;
28
+ data: Record<string, unknown>;
29
29
  }>>;
30
30
  export declare const DELETE: (req: NextRequest, { params }: Context) => Promise<NextResponse<{
31
31
  ok: true;
@@ -1,7 +1,7 @@
1
- import { addDays, addHours } from 'date-fns';
1
+ import { addDays } from 'date-fns';
2
2
  import { NextResponse } from 'next/server';
3
3
  import { z } from 'zod';
4
- import { BTAG_COOKIE_NAME, CELLXPERT_CXD_COOKIE_NAME, DOMAIN_COOKIE_NAME, } from '../constants/index.js';
4
+ import { BTAG_COOKIE_NAME, DOMAIN_COOKIE_NAME } from '../constants/index.js';
5
5
  const UpdateSessionDefinition = z.object({
6
6
  domain: z.string().optional().nullable(),
7
7
  btag: z.string().optional().nullable(),
@@ -24,13 +24,6 @@ export async function patchSession(request) {
24
24
  sameSite: 'strict',
25
25
  });
26
26
  }
27
- if (parsed.data.cellxpertCxd) {
28
- response.cookies.set(CELLXPERT_CXD_COOKIE_NAME, parsed.data.cellxpertCxd, {
29
- expires: addHours(new Date(), 6),
30
- httpOnly: true,
31
- sameSite: 'strict',
32
- });
33
- }
34
27
  if (parsed.data.btag) {
35
28
  response.cookies.set(BTAG_COOKIE_NAME, parsed.data.btag, {
36
29
  expires: addDays(new Date(), 30),