@opexa/portal-components 0.0.377 → 0.0.378

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 (55) hide show
  1. package/dist/components/Banner/Banner.client.d.ts +12 -0
  2. package/dist/components/Banner/Banner.client.js +49 -0
  3. package/dist/components/Disclaimer/useDisclaimer.js +2 -17
  4. package/dist/components/PortalProvider/CXDTokenObserver.d.ts +1 -0
  5. package/dist/components/PortalProvider/CXDTokenObserver.js +30 -0
  6. package/dist/components/PortalProvider/Providers.js +3 -2
  7. package/dist/components/SignIn/utils.d.ts +8 -0
  8. package/dist/components/SignIn/utils.js +26 -0
  9. package/dist/constants/Branches.d.ts +2 -0
  10. package/dist/constants/Branches.js +42 -0
  11. package/dist/services/queries.d.ts +1 -1
  12. package/dist/services/queries.js +4 -0
  13. package/dist/third-parties/FacebookPixel/FacebookPixel.d.ts +4 -0
  14. package/dist/third-parties/FacebookPixel/FacebookPixel.js +4 -0
  15. package/dist/third-parties/FacebookPixel/api.d.ts +0 -0
  16. package/dist/third-parties/FacebookPixel/api.js +1 -0
  17. package/dist/third-parties/FacebookPixel/index.d.ts +1 -0
  18. package/dist/third-parties/FacebookPixel/index.js +1 -0
  19. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.d.ts +4 -0
  20. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.js +4 -0
  21. package/dist/third-parties/GoogleRecaptcha/api.d.ts +0 -0
  22. package/dist/third-parties/GoogleRecaptcha/api.js +1 -0
  23. package/dist/third-parties/GoogleRecaptcha/index.d.ts +1 -0
  24. package/dist/third-parties/GoogleRecaptcha/index.js +1 -0
  25. package/dist/third-parties/index.d.ts +2 -0
  26. package/dist/third-parties/index.js +2 -0
  27. package/dist/types/index.d.ts +4 -0
  28. package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
  29. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
  30. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  31. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  32. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  33. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  34. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  35. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  36. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  37. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  38. package/dist/ui/Dialog/Dialog.d.ts +88 -88
  39. package/dist/ui/Dialog/dialog.recipe.d.ts +8 -8
  40. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  41. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  42. package/dist/ui/Menu/Menu.d.ts +198 -198
  43. package/dist/ui/Menu/menu.recipe.d.ts +11 -11
  44. package/dist/ui/Select/Select.d.ts +45 -45
  45. package/dist/ui/Select/select.recipe.d.ts +3 -3
  46. package/dist/ui/Table/Table.d.ts +21 -21
  47. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  48. package/dist/ui/Table/table.recipe.d.ts +3 -3
  49. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  50. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  51. package/package.json +1 -1
  52. package/dist/components/AccountInfo/GoogleDisconnect.d.ts +0 -7
  53. package/dist/components/AccountInfo/GoogleDisconnect.js +0 -11
  54. package/dist/icons/LinkBrokenIcon.d.ts +0 -2
  55. package/dist/icons/LinkBrokenIcon.js +0 -4
@@ -0,0 +1,12 @@
1
+ import type { ImageProps } from 'next/image';
2
+ export interface BannerEntry {
3
+ src: ImageProps['src'];
4
+ redirectUrl?: string;
5
+ }
6
+ export interface BannerProps {
7
+ banners: BannerEntry[];
8
+ imageWidth?: number | [mobile: number, desktop: number];
9
+ imageHeight?: number | [mobile: number, desktop: number];
10
+ className?: string;
11
+ }
12
+ export declare function Banner__client(props: BannerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import emblaCarouselAutoplay from 'embla-carousel-autoplay';
4
+ import useEmblaCarousel, {} from 'embla-carousel-react';
5
+ import isMobile from 'is-mobile';
6
+ import Image from 'next/image';
7
+ import Link from 'next/link';
8
+ import { Fragment, useEffect, useState } from 'react';
9
+ import { twMerge } from 'tailwind-merge';
10
+ import { dataAttr } from '../../utils/dataAttr.js';
11
+ export function Banner__client(props) {
12
+ const [emblaRef, emblaApi] = useEmblaCarousel({
13
+ loop: true,
14
+ align: 'start',
15
+ }, [
16
+ emblaCarouselAutoplay({
17
+ playOnInit: true,
18
+ delay: 5000,
19
+ }),
20
+ ]);
21
+ const [currentIndex, setCurrentIndex] = useState(0);
22
+ useEffect(() => {
23
+ function handler(detail) {
24
+ setCurrentIndex(detail?.selectedScrollSnap() ?? 0);
25
+ }
26
+ emblaApi?.on('scroll', handler);
27
+ emblaApi?.on('init', handler);
28
+ return () => {
29
+ emblaApi?.on('init', handler);
30
+ emblaApi?.off('scroll', handler);
31
+ };
32
+ }, [emblaApi]);
33
+ const imageWidth = !props.imageWidth
34
+ ? [400, 1200]
35
+ : Array.isArray(props.imageWidth)
36
+ ? props.imageWidth
37
+ : [props.imageWidth, props.imageWidth];
38
+ const imageHeight = !props.imageHeight
39
+ ? [225, 300]
40
+ : Array.isArray(props.imageHeight)
41
+ ? props.imageHeight
42
+ : [props.imageHeight, props.imageHeight];
43
+ return (_jsxs("div", { className: twMerge('relative', props.className), children: [_jsx("div", { ref: emblaRef, className: "overflow-hidden", children: _jsx("div", { className: "flex gap-2", children: props.banners.map((banner, index) => {
44
+ const img = (_jsx(Image, { src: banner.src, alt: "", width: isMobile() ? imageWidth[0] : imageWidth[1], height: isMobile() ? imageHeight[0] : imageHeight[1], className: "block h-auto w-full", priority: index === 0 }));
45
+ return (_jsx(Fragment, { children: !banner.redirectUrl ? (_jsx("div", { className: "w-full shrink-0", children: img })) : (_jsx(Link, { href: banner.redirectUrl, className: "block w-full shrink-0", "aria-label": `Open ${banner.redirectUrl}`, children: img })) }, index));
46
+ }) }) }), _jsx("div", { className: "absolute bottom-lg left-1/2 flex w-fit -translate-x-1/2 gap-2", children: props.banners.map((_, index) => (_jsx("button", { type: "button", className: "ui-active:bg-brand-500 bg-gray-300 size-3 shrink-0 rounded-full border border-white transition-all duration-300 ui-active:w-9", onClick: () => {
47
+ emblaApi?.scrollTo(index);
48
+ }, "aria-label": `Go to slide ${index + 1}`, "data-active": dataAttr(index === currentIndex) }, index))) })] }));
49
+ }
@@ -1,6 +1,4 @@
1
- import { addMinutes } from 'date-fns';
2
- import { clamp } from 'lodash-es';
3
- import { useLocalStorage, useTimeout } from 'usehooks-ts';
1
+ import { useTimeout } from 'usehooks-ts';
4
2
  import { useShallow } from 'zustand/shallow';
5
3
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
6
4
  import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
@@ -8,21 +6,9 @@ export function useDisclaimer() {
8
6
  'use no memo';
9
7
  const sessionQuery = useSessionQuery();
10
8
  const disclaimerStore = useGlobalStore(useShallow((state) => state.disclaimer));
11
- const [refreshPausedUntil, setRefreshPausedUntil] = useLocalStorage('WebPortalDisclaimerRefreshPausedUntil', null, {
12
- serializer(v) {
13
- return v?.toISOString() ?? '';
14
- },
15
- deserializer(v) {
16
- return v ? new Date(v) : null;
17
- },
18
- });
19
- const now = new Date();
20
- const refetchPausedUntilInMs = refreshPausedUntil
21
- ? clamp(refreshPausedUntil.getTime() - now.getTime(), 0, Infinity)
22
- : /* set to zero to trigger timeout function */ 0;
23
9
  useTimeout(() => {
24
10
  disclaimerStore.setOpen(true);
25
- }, disclaimerStore.open ? null : refetchPausedUntilInMs);
11
+ }, 0);
26
12
  return {
27
13
  open: sessionQuery.isLoading
28
14
  ? false
@@ -31,7 +17,6 @@ export function useDisclaimer() {
31
17
  : disclaimerStore.open,
32
18
  close: () => {
33
19
  disclaimerStore.setOpen(false);
34
- setRefreshPausedUntil(addMinutes(new Date(), 30));
35
20
  },
36
21
  };
37
22
  }
@@ -0,0 +1 @@
1
+ export declare function CXDTokenObserver(): null;
@@ -0,0 +1,30 @@
1
+ 'use client';
2
+ import { addHours } from 'date-fns';
3
+ import { clamp } from 'lodash-es';
4
+ import { useLocalStorage, useTimeout } from 'usehooks-ts';
5
+ import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
6
+ 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);
12
+ const now = new Date();
13
+ const removeCxdUntilInMs = cxd?.timestamp
14
+ ? clamp(cxd.timestamp - now.getTime(), 0, Infinity)
15
+ : 0;
16
+ useTimeout(() => {
17
+ const isSame = cxd?.cxd === accountCxd.cxd;
18
+ if (!isSame) {
19
+ const extendedTimestamp = addHours(new Date(), 6).getTime();
20
+ setCxd({
21
+ cxd: accountCxd.cxd,
22
+ timestamp: extendedTimestamp,
23
+ });
24
+ }
25
+ }, account ? 100 : null);
26
+ useTimeout(() => {
27
+ removeCxd();
28
+ }, account ? removeCxdUntilInMs : null);
29
+ return null;
30
+ }
@@ -1,9 +1,10 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
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
5
  import { getQueryClient } from '../../utils/getQueryClient.js';
6
+ import { CXDTokenObserver } from './CXDTokenObserver.js';
6
7
  export function Providers({ recaptchaSiteKey, children, }) {
7
8
  const queryClient = getQueryClient();
8
- return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ReCaptchaProvider, { reCaptchaKey: recaptchaSiteKey, children: children }) }));
9
+ return (_jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(CXDTokenObserver, {}), _jsx(ReCaptchaProvider, { reCaptchaKey: recaptchaSiteKey, children: children })] }));
9
10
  }
@@ -0,0 +1,8 @@
1
+ type Options = {
2
+ accountName?: string;
3
+ siteName?: string;
4
+ signInOptions?: 'MOBILE_NUMBER' | 'NAME_AND_PASSWORD';
5
+ };
6
+ export type ErrorCode = 'MEMBER_ACCOUNT_BLACKLISTED' | 'MEMBER_ACCOUNT_SUSPENDED' | 'INVALID_RECAPTCHA_RESPONSE' | 'MEMBER_NOT_FOUND' | 'RATE_LIMIT_REACH' | 'NOT_READY_TO_SEND_VERIFICATION_ERROR' | 'Forbidden';
7
+ export declare function getFriendlyErrorMessage(code: ErrorCode, options?: Options): string;
8
+ export {};
@@ -0,0 +1,26 @@
1
+ export function getFriendlyErrorMessage(code, options) {
2
+ const accountName = options?.accountName ?? '';
3
+ const siteName = options?.siteName ?? '';
4
+ const signInOptions = options?.signInOptions ?? 'NAME_AND_PASSWORD';
5
+ switch (code) {
6
+ case 'MEMBER_ACCOUNT_BLACKLISTED':
7
+ return `Your account ${accountName} has been blacklisted due to a serious violation of our policies. For more information or to appeal, please contact the ${siteName} Chat Support team.`;
8
+ case 'MEMBER_ACCOUNT_SUSPENDED':
9
+ return `Your account ${accountName} has been temporarily suspended. Please reach out to the ${siteName} Chat Support team to learn more and get help with resolving the issue.`;
10
+ case 'INVALID_RECAPTCHA_RESPONSE':
11
+ return 'Invalid reCAPTCHA response';
12
+ case 'MEMBER_NOT_FOUND':
13
+ return 'Account not found. Please check your username and try again.';
14
+ case 'RATE_LIMIT_REACH':
15
+ return 'Rate limit exceeded';
16
+ case 'NOT_READY_TO_SEND_VERIFICATION_ERROR':
17
+ return 'Your account is not ready to send verification requests. Please try again later.';
18
+ case 'Forbidden':
19
+ if (signInOptions === 'MOBILE_NUMBER') {
20
+ return 'Invalid verification code. Please check the code and try again.';
21
+ }
22
+ return 'Invalid username or password, please try again.';
23
+ default:
24
+ return 'Something went wrong. Please try again later.';
25
+ }
26
+ }
@@ -0,0 +1,2 @@
1
+ import type { Branch } from '../types';
2
+ export declare const BRANCHES: Branch[];
@@ -0,0 +1,42 @@
1
+ export const BRANCHES = [
2
+ {
3
+ code: 'BRCAL',
4
+ name: 'Bingo Republic 2nd floor Primark Center Deparo St., Caloocan City',
5
+ },
6
+ {
7
+ code: 'BRNAG',
8
+ name: 'Bingo Republic 3rd floor Robinsons Mall, Naga City, Camarines Sur',
9
+ },
10
+ {
11
+ code: 'BRANT',
12
+ name: 'Bingo Republic 2nd floor Robinsons Mall, San Vicente,Antique',
13
+ },
14
+ {
15
+ code: 'BRCLA',
16
+ name: 'Clark',
17
+ },
18
+ {
19
+ code: 'BRLAG',
20
+ name: 'Laguna',
21
+ },
22
+ {
23
+ code: 'BREAS',
24
+ name: 'Eastwood City, Quezon City',
25
+ },
26
+ {
27
+ code: 'BRMAR',
28
+ name: 'Bingo ng Bayan 4th floor Marikina Public Market, Marikina City',
29
+ },
30
+ {
31
+ code: 'BRILO',
32
+ name: 'Iloilo',
33
+ },
34
+ {
35
+ code: 'BRFIM',
36
+ name: 'Fisher Mall,Quezon City',
37
+ },
38
+ {
39
+ code: 'BRCAC',
40
+ name: 'Villa Caceres Hotel, Naga City,Camsur',
41
+ },
42
+ ];
@@ -67,7 +67,7 @@ export declare const MEMBER = "\n query Member {\n member {\n dateTimeL
67
67
  /**
68
68
  * _aka_ `Query.self`
69
69
  */
70
- export declare const MEMBER_ACCOUNT = "\n query MemberAccount {\n memberAccount: self {\n ... on MemberAccount {\n id\n name\n status\n realName\n emailAddress\n mobileNumber\n birthDay\n verified\n verificationStatus\n nickName\n validId\n mobileNumberVerified\n mobileNumberVerificationRequired\n transactionPassword\n secretAnswerSubmitted\n dateTimeCreated\n dateTimeLastUpdated\n googleId\n facebookId\n }\n }\n }\n";
70
+ export declare const MEMBER_ACCOUNT = "\n query MemberAccount {\n memberAccount: self {\n ... on MemberAccount {\n id\n name\n status\n realName\n emailAddress\n mobileNumber\n birthDay\n verified\n verificationStatus\n nickName\n validId\n mobileNumberVerified\n mobileNumberVerificationRequired\n transactionPassword\n secretAnswerSubmitted\n dateTimeCreated\n dateTimeLastUpdated\n googleId\n facebookId\n cellxpertDetails {\n cxd\n dateTimeLastUpdated \n }\n }\n }\n }\n";
71
71
  export declare const MEMBER_VERIFICATION = "\n \n fragment FileFragment on File {\n id\n url\n status\n }\n\n\n query MemberVerification {\n memberAccount: self {\n ... on MemberAccount {\n verification {\n id\n status\n address\n permanentAddress\n sourceOfIncome\n natureOfWork\n nationality\n placeOfBirth\n idFrontImage {\n ...FileFragment\n }\n selfieImage {\n ...FileFragment\n }\n }\n }\n }\n }\n";
72
72
  export declare const REGISTER_MEMBER_ACCOUNT = "\n mutation RegisterMemberAccount(\n $input: RegisterMemberAccountInput!\n $referralCode: String\n $verificationCode: String\n $reCAPTCHAResponse: String\n ) {\n registerMemberAccount(\n input: $input\n referralCode: $referralCode\n verificationCode: $verificationCode\n reCAPTCHAResponse: $reCAPTCHAResponse\n ) {\n ... on AccountNameNotAvailableError {\n name: __typename\n message\n }\n ... on InvalidPlatformError {\n name: __typename\n message\n }\n ... on InvalidPlatformError {\n name: __typename\n message\n }\n ... on InvalidReCAPTCHAResponseError {\n name: __typename\n message\n }\n ... on InvalidSMSVerificationCodeError {\n name: __typename\n message\n }\n ... on MinimumAgeRequirementError {\n name: __typename\n message\n }\n ... on MobileNumberNotAvailableError {\n name: __typename\n message\n }\n ... on ReCAPTCHAVerificationFailedError {\n name: __typename\n message\n }\n }\n }\n";
73
73
  export declare const REGISTER_MEMBER_ACCOUNT_BY_NAME = "\n mutation RegisterMemberAccountByName(\n $input: RegisterMemberAccountByNameInput!\n $reCAPTCHAResponse: String!\n ) {\n registerMemberAccountByName(\n input: $input\n reCAPTCHAResponse: $reCAPTCHAResponse\n ) {\n ... on AccountNameNotAvailableError {\n name: __typename\n message\n }\n ... on InvalidPlatformError {\n name: __typename\n message\n }\n ... on InvalidReCAPTCHAResponseError {\n name: __typename\n message\n }\n }\n }\n";
@@ -1532,6 +1532,10 @@ export const MEMBER_ACCOUNT = /* GraphQL */ `
1532
1532
  dateTimeLastUpdated
1533
1533
  googleId
1534
1534
  facebookId
1535
+ cellxpertDetails {
1536
+ cxd
1537
+ dateTimeLastUpdated
1538
+ }
1535
1539
  }
1536
1540
  }
1537
1541
  }
@@ -0,0 +1,4 @@
1
+ export interface FacebookPixelProps {
2
+ fbId: string;
3
+ }
4
+ export declare function FacebookPixel(props: FacebookPixelProps): null;
@@ -0,0 +1,4 @@
1
+ export function FacebookPixel(props) {
2
+ console.log(props);
3
+ return null;
4
+ }
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ export * from './FacebookPixel';
@@ -0,0 +1 @@
1
+ export * from './FacebookPixel.js';
@@ -0,0 +1,4 @@
1
+ export interface GoogleRecaptchaProps {
2
+ siteKey: string;
3
+ }
4
+ export declare function GoogleRecaptcha(props: GoogleRecaptchaProps): null;
@@ -0,0 +1,4 @@
1
+ export function GoogleRecaptcha(props) {
2
+ console.log(props);
3
+ return null;
4
+ }
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ export * from './GoogleRecaptcha';
@@ -0,0 +1 @@
1
+ export * from './GoogleRecaptcha.js';
@@ -0,0 +1,2 @@
1
+ export * from './FacebookPixel';
2
+ export * from './GoogleRecaptcha';
@@ -0,0 +1,2 @@
1
+ export * from './FacebookPixel/index.js';
2
+ export * from './GoogleRecaptcha/index.js';
@@ -461,6 +461,10 @@ export interface MemberAccount {
461
461
  dateTimeLastUpdated: string;
462
462
  googleId?: string | null;
463
463
  facebookId?: string | null;
464
+ cellxpertDetails?: {
465
+ cxd: string;
466
+ dateTimeLastUpdated: string;
467
+ };
464
468
  }
465
469
  export interface MemberVerification {
466
470
  id: string;