@opexa/portal-components 0.0.1035 → 0.0.1037

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,119 +1,48 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import isMobile from 'is-mobile';
4
4
  import { useRouter } from 'next/navigation';
5
- import { useEffect, useRef, useState } from 'react';
5
+ import { useEffect, useState } from 'react';
6
6
  import { twJoin } from 'tailwind-merge';
7
7
  import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
8
8
  import { toaster } from '../../client/utils/toaster.js';
9
9
  import { Fallback } from './Fallback.js';
10
10
  export function DigitainContainer(props) {
11
11
  const session = useSessionQuery();
12
- const [isLoading, setLoading] = useState(true);
13
- const [hasBooted, setHasBooted] = useState(false);
12
+ const [isLoading, setLoading] = useState(false);
14
13
  const router = useRouter();
15
- const hasBootedRef = useRef(false);
16
- const containerRef = useRef(null);
17
14
  useEffect(() => {
18
15
  if (session.data?.status === 'authenticated') {
19
16
  router.refresh();
20
17
  }
21
18
  }, [session.data?.status, router]);
22
19
  useEffect(() => {
23
- if (hasBootedRef.current || typeof window === 'undefined') {
24
- return;
25
- }
20
+ setLoading(true);
26
21
  let attempts = 0;
27
- const maxAttempts = 5;
28
- const intervalId = setInterval(() => {
29
- if (window.Bootstrapper) {
22
+ const maxAttempts = 5; // e.g. wait up to ~10 seconds
23
+ function checkAndBoot() {
24
+ if (typeof window !== 'undefined' && window.Bootstrapper) {
30
25
  console.log('Bootstrapper found, booting with params:', props.params);
31
- hasBootedRef.current = true;
32
26
  window.Bootstrapper.boot(props.params, {
33
27
  name: isMobile() ? 'Mobile' : 'AsianView',
34
28
  }).then(() => {
35
29
  console.log('Sportsbook booted!');
36
- setHasBooted(true);
37
- }).catch((error) => {
38
- console.error('Sportsbook boot failed:', error);
39
- setLoading(false);
40
- toaster.error({
41
- title: 'Error',
42
- description: 'Failed to initialize sportsbook.',
43
- });
44
30
  });
31
+ setTimeout(() => setLoading(false), 1000); // Give some time for the UI to update
45
32
  clearInterval(intervalId);
46
33
  }
47
34
  else if (++attempts >= maxAttempts) {
48
- console.warn('Bootstrapper did not load in time.');
49
35
  setLoading(false);
50
36
  toaster.error({
51
37
  title: 'Error',
52
38
  description: 'Sportsbook failed to load. Please try again later.',
53
39
  });
40
+ console.warn('Bootstrapper did not load in time.');
54
41
  clearInterval(intervalId);
55
42
  }
56
- }, 500);
43
+ }
44
+ const intervalId = setInterval(checkAndBoot, 500);
57
45
  return () => clearInterval(intervalId);
58
46
  }, [props.params]);
59
- useEffect(() => {
60
- if (!hasBooted || !containerRef.current) {
61
- return;
62
- }
63
- const container = containerRef.current;
64
- const handleIframeReady = (iframe) => {
65
- const onLoad = () => {
66
- console.log('Digitain iframe loaded successfully!');
67
- setTimeout(() => setLoading(false), 300);
68
- };
69
- const onError = () => {
70
- console.error('Digitain iframe failed to load');
71
- setLoading(false);
72
- toaster.error({
73
- title: 'Error',
74
- description: 'Failed to load sportsbook. Please try again.',
75
- });
76
- };
77
- if (iframe.contentDocument?.readyState === 'complete') {
78
- console.log('Iframe already loaded!');
79
- setTimeout(() => setLoading(false), 300);
80
- }
81
- else {
82
- iframe.addEventListener('load', onLoad, { once: true });
83
- iframe.addEventListener('error', onError, { once: true });
84
- }
85
- };
86
- const existingIframe = container.querySelector('iframe');
87
- if (existingIframe) {
88
- handleIframeReady(existingIframe);
89
- return;
90
- }
91
- let iframeDetected = false;
92
- const observer = new MutationObserver((mutations) => {
93
- for (const mutation of mutations) {
94
- for (const node of mutation.addedNodes) {
95
- if (node.nodeName === 'IFRAME') {
96
- console.log('Digitain iframe detected');
97
- iframeDetected = true;
98
- handleIframeReady(node);
99
- observer.disconnect();
100
- return;
101
- }
102
- }
103
- }
104
- });
105
- observer.observe(container, { childList: true, subtree: true });
106
- const fallbackTimeout = setTimeout(() => {
107
- if (!iframeDetected) {
108
- console.warn('No iframe detected after 10 seconds. Hiding loader.');
109
- setLoading(false);
110
- observer.disconnect();
111
- }
112
- }, 10000);
113
- return () => {
114
- observer.disconnect();
115
- clearTimeout(fallbackTimeout);
116
- };
117
- }, [hasBooted]);
118
- return (_jsxs("div", { className: "relative h-full min-h-screen w-full", children: [_jsx("div", { className: twJoin('absolute inset-0 transition-opacity duration-300', isLoading ? 'z-10 opacity-100' : 'pointer-events-none opacity-0'), children: _jsx(Fallback, { type: "loading", fallbackBackgroundImage: props.fallbackBackgroundImage }) }), _jsx("div", { ref: containerRef, id: "digitain-container", className: twJoin('absolute inset-0 transition-opacity duration-300', isLoading ? 'opacity-0' : 'opacity-100') })] }));
47
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: twJoin(!isLoading && 'hidden'), children: _jsx(Fallback, { type: "loading", fallbackBackgroundImage: props.fallbackBackgroundImage }) }), _jsx("div", { id: "digitain-container", className: twJoin(isLoading && 'hidden') })] }));
119
48
  }
@@ -68,7 +68,7 @@ export function JackpotsListItemDesktop({ animate = true, customJackpotChestImag
68
68
  maxDecimalPlaces: 2,
69
69
  })] }), _jsx(Tooltip.Arrow, { children: _jsx(Tooltip.ArrowTip, {}) })] }) })] }), _jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-start pl-1.5", "aria-hidden": "true", children: arrowImages }), _jsxs(Tooltip.Root, { openDelay: 0, closeDelay: 100, lazyMount: true, unmountOnExit: true, positioning: { strategy: 'fixed', placement: 'top' }, children: [_jsx(Tooltip.Trigger, { asChild: true, children: _jsx("div", { className: "absolute inset-0 h-full bg-black opacity-30", style: {
70
70
  width: `${getPercentage(jackpot.minimumJackpotPoolDrawingLimit, jackpot.pool)}%`,
71
- } }) }), _jsx(Tooltip.Positioner, { children: _jsxs(Tooltip.Content, { children: [_jsxs("div", { className: "text-xs", children: ["Minimum Payout Limit:", ' ', formatNumber(jackpot.minimumJackpotPoolDrawingLimit, {
71
+ } }) }), _jsx(Tooltip.Positioner, { children: _jsxs(Tooltip.Content, { children: [_jsxs("div", { className: "text-xs", children: ["Minimum Jackpot Pool Drawing Limit:", ' ', formatNumber(jackpot.minimumJackpotPoolDrawingLimit, {
72
72
  currency: localeInfo.currency.code,
73
73
  minDecimalPlaces: 2,
74
74
  maxDecimalPlaces: 2,
@@ -96,7 +96,7 @@ export function JackpotsListItemDesktop({ animate = true, customJackpotChestImag
96
96
  if (jackpot.status === 'DISABLED' && jackpot.drawing !== true) {
97
97
  return null;
98
98
  }
99
- return (_jsxs("div", { ref: rootRef, className: twMerge('rounded-2xl border border-border-primary bg-bg-tertiary', className?.itemRoot), children: [_jsxs("div", { style: props.style, className: twMerge('relative flex shrink-0 rounded-2xl p-3 text-center lg:gap-4 lg:p-5'), children: [_jsxs("div", { className: "relative z-1 flex flex-1 flex-col", children: [_jsx("div", { className: "flex h-full flex-col justify-between", children: _jsx("div", { className: "flex w-full justify-between", children: _jsxs("div", { className: "flex w-full flex-col", children: [_jsxs("div", { className: "relative flex w-full justify-between", children: [_jsxs("div", { children: [isPayingOut ? (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-success-200 bg-utility-success-50 px-2 py-0.5 font-medium text-utility-success-700 text-xs", children: [_jsx("span", { className: "full size-1.5 animate-pulse rounded bg-utility-success-500" }), "Paying Out"] })) : (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-blue-200 bg-utility-blue-50 px-2 py-0.5 font-medium text-utility-blue-700 text-xs", children: [_jsx(ArrowNarrowUpRightIcon, { className: "size-3.5 text-utility-blue-500" }), "Accumulating"] })), _jsx("div", { className: "mt-1 text-left font-medium text-lg text-text-primary-900 lg:mt-5 lg:text-2xl", children: jackpot.name }), _jsx("div", { className: twMerge('mt-1.5 w-fit rounded-md bg-bg-primary px-2 py-1 font-bold text-2xl text-brand-400 lg:mt-2 lg:text-4xl', className?.jackpotAmountRoot), children: formatNumber(jackpotAmount, {
99
+ return (_jsxs("div", { ref: rootRef, className: twMerge('rounded-2xl border border-border-primary bg-bg-tertiary', className?.itemRoot), children: [_jsxs("div", { style: props.style, className: twMerge('relative flex shrink-0 rounded-2xl p-3 text-center lg:gap-4 lg:p-5'), children: [_jsxs("div", { className: "relative z-20 flex flex-1 flex-col", children: [_jsx("div", { className: "flex h-full flex-col justify-between", children: _jsx("div", { className: "flex w-full justify-between", children: _jsxs("div", { className: "flex w-full flex-col", children: [_jsxs("div", { className: "relative flex w-full justify-between", children: [_jsxs("div", { children: [isPayingOut ? (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-success-200 bg-utility-success-50 px-2 py-0.5 font-medium text-utility-success-700 text-xs", children: [_jsx("span", { className: "full size-1.5 animate-pulse rounded bg-utility-success-500" }), "Paying Out"] })) : (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-blue-200 bg-utility-blue-50 px-2 py-0.5 font-medium text-utility-blue-700 text-xs", children: [_jsx(ArrowNarrowUpRightIcon, { className: "size-3.5 text-utility-blue-500" }), "Accumulating"] })), _jsx("div", { className: "mt-1 text-left font-medium text-lg text-text-primary-900 lg:mt-5 lg:text-2xl", children: jackpot.name }), _jsx("div", { className: twMerge('mt-1.5 w-fit rounded-md bg-bg-primary px-2 py-1 font-bold text-2xl text-brand-400 lg:mt-2 lg:text-4xl', className?.jackpotAmountRoot), children: formatNumber(jackpotAmount, {
100
100
  currency: localeInfo.currency.code,
101
101
  minDecimalPlaces: 2,
102
102
  maxDecimalPlaces: 2,
@@ -84,7 +84,9 @@ export function PersonalInformation() {
84
84
  kyc.setDone(true);
85
85
  globalStore.kyc.setOpen(false);
86
86
  globalStore.kycAccountVerificationRequired.setOpen(false);
87
- globalStore.kycReminder.setOpen(true);
87
+ if (accountQuery.data?.status === 'VERIFICATION_LOCKED') {
88
+ globalStore.kycReminder.setOpen(true);
89
+ }
88
90
  toaster.success({
89
91
  title: 'Success',
90
92
  description: 'Personal information has been set successfully.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.1035",
3
+ "version": "0.0.1037",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",