@opexa/portal-components 0.0.992 → 0.0.993

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.
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import Image from 'next/image';
4
4
  import Link from 'next/link';
5
- import { useRef, useState } from 'react';
5
+ import { useEffect, useRef, useState } from 'react';
6
6
  import { useShallow } from 'zustand/shallow';
7
7
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
8
8
  import { AlertCircleIcon } from '../../icons/AlertCircleIcon.js';
@@ -20,9 +20,23 @@ export function DisclaimerV1(props) {
20
20
  const acceptTriggerRef = useRef(null);
21
21
  const globalStore = useGlobalStore(useShallow((ctx) => ({
22
22
  termsOfUse: ctx.termsOfUse,
23
+ termsAndConditions: ctx.termsAndConditions,
23
24
  })));
24
25
  const checked = globalStore.termsOfUse.accepted;
25
26
  const [warn, setWarn] = useState(false);
27
+ // Sync checkbox with global store changes
28
+ useEffect(() => {
29
+ // Only update if termsAndConditions is accepted but termsOfUse is not
30
+ // This prevents infinite loops
31
+ if (globalStore.termsAndConditions.accepted &&
32
+ !globalStore.termsOfUse.accepted) {
33
+ globalStore.termsOfUse.setAccepted(true);
34
+ }
35
+ }, [
36
+ globalStore.termsAndConditions.accepted,
37
+ globalStore.termsOfUse.accepted,
38
+ globalStore.termsOfUse.setAccepted,
39
+ ]);
26
40
  return (_jsx(Dialog.Root, { open: disclaimer.open, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, initialFocusEl: () => acceptTriggerRef.current, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)]", children: _jsxs(Dialog.Content, { "data-testid": "disclaimer-v1-dialog", className: "flex h-full w-full flex-col items-start overflow-y-auto p-3xl lg:mx-auto lg:h-auto lg:max-h-[80vh] lg:w-[400px] lg:rounded-xl", style: { msOverflowStyle: 'none', scrollbarWidth: 'none' }, children: [_jsx(Image, { src: props.logo, alt: "", width: 142, height: 30, className: "mx-auto h-auto w-[8.875rem]", draggable: false }), _jsxs("div", { className: "w-full grow", children: [_jsxs("div", { className: "mt-5 flex items-center justify-center gap-3xl", children: [_jsx(Image, { src: pagcorLogo, alt: "", height: 74, width: 88, className: "h-[5.5rem] w-auto shrink-0", draggable: false }), _jsx(Image, { src: responsibleGamingLogo, alt: "", height: 62, width: 185, className: "h-[3.875rem] w-auto shrink-0", draggable: false })] }), _jsx("p", { className: "mt-4 text-center text-sm", children: "The following individuals are prohibited from registering or participating in this online gaming platform." }), _jsx("div", { className: "mt-5", children: _jsx("ul", { className: "space-y-1", "data-testid": "disclaimer-v1-restrictions-list", children: items.map((item, index) => (_jsxs("li", { className: "flex items-start gap-md text-sm text-text-secondary-700", children: [_jsx("div", { className: "mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full bg-bg-brand-solid", children: _jsx("div", { className: "size-1.5 rounded-full bg-cyan-950" }) }), item] }, index))) }) }), _jsxs(Field.Root, { invalid: warn, className: "mt-2xl", children: [_jsxs(Checkbox.Root, { checked: checked, onCheckedChange: (e) => {
27
41
  if (e.checked === 'indeterminate')
28
42
  return;
@@ -30,7 +44,12 @@ export function DisclaimerV1(props) {
30
44
  setWarn(!e.checked);
31
45
  }, children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsxs(Checkbox.Label, { className: "text-sm", children: ["I am at least 21 years of age, I accept the", ' ', _jsx(Link, { href: props.termsOfUseUrl ?? '/terms-of-use', className: "text-brand-400 underline underline-offset-2", "data-testid": "disclaimer-v1-terms-link", onClick: () => {
32
46
  globalStore.termsOfUse.setOpen(false);
33
- }, children: "Terms of Use" }), ' ', "and I am not playing in open or public space."] }), _jsx(Checkbox.HiddenInput, {})] }), _jsxs(Field.ErrorText, { className: "!mt-2xl flex items-center justify-center gap-2 text-error-600 text-sm", children: [_jsx(AlertCircleIcon, { className: "size-4 shrink-0 text-error-600" }), "Please agree to ", props.siteName, "\u2019s Terms of Use to proceed."] })] }), _jsx("p", { className: "mt-2xl text-sm", children: "Funds or credits in the account of any individual found ineligible to participate will be forfeited and turned over to the government as required by law." }), _jsxs("div", { className: "flex w-full flex-col gap-lg", children: [_jsx(Button, { ref: acceptTriggerRef, type: "button", className: "mt-4xl", onClick: disclaimer.close, disabled: !checked, "data-testid": "disclaimer-v1-accept-btn", children: "Accept" }), _jsx(Button, { variant: "outline", type: "button", className: "mt-lg", "data-testid": "disclaimer-v1-exit-btn", onClick: () => {
47
+ }, children: "Terms of Use" }), ' ', "and I am not playing in open or public space."] }), _jsx(Checkbox.HiddenInput, {})] }), _jsxs(Field.ErrorText, { className: "!mt-2xl flex items-center justify-center gap-2 text-error-600 text-sm", children: [_jsx(AlertCircleIcon, { className: "size-4 shrink-0 text-error-600" }), "Please agree to ", props.siteName, "\u2019s Terms of Use to proceed."] })] }), _jsx("p", { className: "mt-2xl text-sm", children: "Funds or credits in the account of any individual found ineligible to participate will be forfeited and turned over to the government as required by law." }), _jsxs("div", { className: "flex w-full flex-col gap-lg", children: [_jsx(Button, { ref: acceptTriggerRef, type: "button", className: "mt-4xl", onClick: () => {
48
+ // Reset terms and responsible gaming acceptance states
49
+ // so users must re-accept in SignIn forms
50
+ globalStore.termsAndConditions.setAccepted(false);
51
+ disclaimer.close();
52
+ }, disabled: !checked, "data-testid": "disclaimer-v1-accept-btn", children: "Accept" }), _jsx(Button, { variant: "outline", type: "button", className: "mt-lg", "data-testid": "disclaimer-v1-exit-btn", onClick: () => {
34
53
  if (props.exitRedirect) {
35
54
  window.location.href = props.exitRedirect;
36
55
  return;
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Capacitor } from '@capacitor/core';
4
4
  import { isString } from 'lodash-es';
5
5
  import Image from 'next/image';
6
- import { useState } from 'react';
6
+ import { useEffect, useState } from 'react';
7
7
  import { twMerge } from 'tailwind-merge';
8
8
  import { useShallow } from 'zustand/shallow';
9
9
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
@@ -33,11 +33,25 @@ export function DisclaimerV2(props) {
33
33
  const globalStore = useGlobalStore(useShallow((ctx) => ({
34
34
  termsOfUse: ctx.termsOfUse,
35
35
  responsibleGaming: ctx.responsibleGaming,
36
+ termsAndConditions: ctx.termsAndConditions,
36
37
  })));
37
38
  const sessionQuery = useSessionQuery();
38
39
  const isAuthenticated = sessionQuery.data?.status === 'authenticated';
39
40
  const checked = globalStore.termsOfUse.accepted && globalStore.responsibleGaming.accepted;
40
41
  const [showWarning, setShowWarning] = useState(false);
42
+ // Sync checkbox with global store changes
43
+ useEffect(() => {
44
+ // Only update if termsAndConditions is accepted but termsOfUse is not
45
+ // This prevents infinite loops
46
+ if (globalStore.termsAndConditions.accepted &&
47
+ !globalStore.termsOfUse.accepted) {
48
+ globalStore.termsOfUse.setAccepted(true);
49
+ }
50
+ }, [
51
+ globalStore.termsAndConditions.accepted,
52
+ globalStore.termsOfUse.accepted,
53
+ globalStore.termsOfUse.setAccepted,
54
+ ]);
41
55
  const signOutMutation = useSignOutMutation({
42
56
  async onSuccess() {
43
57
  // Clear everything except the 'biometric' entry
@@ -92,6 +106,10 @@ export function DisclaimerV2(props) {
92
106
  setTimeout(() => setShowWarning(false), 4000);
93
107
  return;
94
108
  }
109
+ // Reset terms and responsible gaming acceptance states
110
+ // so users must re-accept in SignIn forms
111
+ globalStore.termsAndConditions.setAccepted(false);
112
+ globalStore.responsibleGaming.setAccepted(false);
95
113
  disclaimer.close();
96
114
  if (isAuthenticated) {
97
115
  globalStore.termsOfUse.setOpen(true);
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { App } from '@capacitor/app';
4
4
  import { Capacitor } from '@capacitor/core';
5
5
  import Image from 'next/image';
6
- import { useState } from 'react';
6
+ import { useEffect, useState } from 'react';
7
7
  import { twMerge } from 'tailwind-merge';
8
8
  import { useShallow } from 'zustand/shallow';
9
9
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
@@ -26,11 +26,25 @@ export function DisclaimerV3(props) {
26
26
  termsOfUse: ctx.termsOfUse,
27
27
  responsibleGaming: ctx.responsibleGaming,
28
28
  onboarding: ctx.onboarding,
29
+ termsAndConditions: ctx.termsAndConditions,
29
30
  })));
30
31
  const sessionQuery = useSessionQuery();
31
32
  const isAuthenticated = sessionQuery.data?.status === 'authenticated';
32
33
  const checked = globalStore.termsOfUse.accepted && globalStore.responsibleGaming.accepted;
33
34
  const [showWarning, setShowWarning] = useState(false);
35
+ // Sync checkbox with global store changes
36
+ useEffect(() => {
37
+ // Only update if termsAndConditions is accepted but termsOfUse is not
38
+ // This prevents infinite loops
39
+ if (globalStore.termsAndConditions.accepted &&
40
+ !globalStore.termsOfUse.accepted) {
41
+ globalStore.termsOfUse.setAccepted(true);
42
+ }
43
+ }, [
44
+ globalStore.termsAndConditions.accepted,
45
+ globalStore.termsOfUse.accepted,
46
+ globalStore.termsOfUse.setAccepted,
47
+ ]);
34
48
  const signOutMutation = useSignOutMutation();
35
49
  const handleExit = () => {
36
50
  if (props.redirectUrlOnNoConsent) {
@@ -64,6 +78,10 @@ export function DisclaimerV3(props) {
64
78
  setTimeout(() => setShowWarning(false), 4000);
65
79
  return;
66
80
  }
81
+ // Reset terms and responsible gaming acceptance states
82
+ // so users must re-accept in SignIn forms
83
+ globalStore.termsAndConditions.setAccepted(false);
84
+ globalStore.responsibleGaming.setAccepted(false);
67
85
  disclaimer.close();
68
86
  if (isAuthenticated) {
69
87
  globalStore.termsOfUse.setOpen(true);
@@ -14,11 +14,14 @@ export function ResponsibleGaming(props) {
14
14
  signUp: ctx.signUp,
15
15
  disclaimer: ctx.disclaimer,
16
16
  responsibleGaming: ctx.responsibleGaming,
17
+ termsAndConditions: ctx.termsAndConditions,
17
18
  })));
18
19
  return (_jsx(Dialog.Root, { open: globalStore.responsibleGaming.open, onOpenChange: (details) => {
19
20
  globalStore.responsibleGaming.setOpen(details.open);
20
- if (!details.open)
21
+ if (!details.open) {
21
22
  globalStore.responsibleGaming.setAccepted(true);
23
+ globalStore.termsAndConditions.setAccepted(true);
24
+ }
22
25
  }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
23
26
  if (globalStore.responsibleGaming.next === 'SIGN_IN') {
24
27
  globalStore.signIn.setOpen(true);
@@ -18,6 +18,7 @@ export function ResponsibleGamingV2(props) {
18
18
  signUp: ctx.signUp,
19
19
  disclaimer: ctx.disclaimer,
20
20
  responsibleGaming: ctx.responsibleGaming,
21
+ termsAndConditions: ctx.termsAndConditions,
21
22
  })));
22
23
  useEffect(() => {
23
24
  if (scrollableContentRef.current) {
@@ -31,8 +32,10 @@ export function ResponsibleGamingV2(props) {
31
32
  }, []);
32
33
  return (_jsx(Dialog.Root, { open: globalStore.responsibleGaming.open, onOpenChange: (details) => {
33
34
  globalStore.responsibleGaming.setOpen(details.open);
34
- if (!details.open)
35
+ if (!details.open) {
35
36
  globalStore.responsibleGaming.setAccepted(true);
37
+ globalStore.termsAndConditions.setAccepted(true);
38
+ }
36
39
  }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
37
40
  if (globalStore.responsibleGaming.next === 'SIGN_IN') {
38
41
  globalStore.signIn.setOpen(true);
@@ -19,6 +19,7 @@ export function ResponsibleGamingV3(props) {
19
19
  signUp: ctx.signUp,
20
20
  disclaimer: ctx.disclaimer,
21
21
  responsibleGaming: ctx.responsibleGaming,
22
+ termsAndConditions: ctx.termsAndConditions,
22
23
  })));
23
24
  useEffect(() => {
24
25
  if (scrollableContentRef.current) {
@@ -32,8 +33,10 @@ export function ResponsibleGamingV3(props) {
32
33
  }, []);
33
34
  return (_jsx(Dialog.Root, { open: globalStore.responsibleGaming.open, onOpenChange: (details) => {
34
35
  globalStore.responsibleGaming.setOpen(details.open);
35
- if (!details.open)
36
+ if (!details.open) {
36
37
  globalStore.responsibleGaming.setAccepted(true);
38
+ globalStore.termsAndConditions.setAccepted(true);
39
+ }
37
40
  }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
38
41
  if (globalStore.responsibleGaming.next === 'SIGN_IN') {
39
42
  globalStore.signIn.setOpen(true);
@@ -4,7 +4,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
4
4
  import dynamic from 'next/dynamic';
5
5
  import Image from 'next/image';
6
6
  import { useRouter } from 'next/navigation';
7
- import { useRef } from 'react';
7
+ import { useEffect, useRef } from 'react';
8
8
  import { Controller, useForm } from 'react-hook-form';
9
9
  import { twMerge } from 'tailwind-merge';
10
10
  import invariant from 'tiny-invariant';
@@ -186,6 +186,17 @@ export function MobileNumberSignIn() {
186
186
  : false,
187
187
  },
188
188
  });
189
+ // Sync termsAccepted checkbox with global store
190
+ useEffect(() => {
191
+ if (globalStore.termsAndConditions.accepted ||
192
+ globalStore.responsibleGaming.accepted) {
193
+ step1Form.setValue('termsAccepted', true);
194
+ }
195
+ }, [
196
+ globalStore.termsAndConditions.accepted,
197
+ globalStore.responsibleGaming.accepted,
198
+ step1Form,
199
+ ]);
189
200
  const step2Form = useForm({
190
201
  resolver: zodResolver(Step2Definition),
191
202
  defaultValues: {
@@ -5,7 +5,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
5
5
  import dynamic from 'next/dynamic';
6
6
  import Image from 'next/image';
7
7
  import { useRouter } from 'next/navigation';
8
- import { useState } from 'react';
8
+ import { useEffect, useState } from 'react';
9
9
  import { Controller, useForm } from 'react-hook-form';
10
10
  import { twMerge } from 'tailwind-merge';
11
11
  import invariant from 'tiny-invariant';
@@ -248,6 +248,17 @@ export function NameAndPasswordSignIn() {
248
248
  : false,
249
249
  },
250
250
  });
251
+ // Sync termsAccepted checkbox with global store
252
+ useEffect(() => {
253
+ if (globalStore.termsAndConditions.accepted ||
254
+ globalStore.responsibleGaming.accepted) {
255
+ form.setValue('termsAccepted', true);
256
+ }
257
+ }, [
258
+ globalStore.termsAndConditions.accepted,
259
+ globalStore.responsibleGaming.accepted,
260
+ form,
261
+ ]);
251
262
  const secretQuestion = signInMutation.data
252
263
  ? z
253
264
  .union([
@@ -173,7 +173,7 @@ export default function SignUpLongForm() {
173
173
  description: error.message,
174
174
  });
175
175
  },
176
- onMutate: async (data) => {
176
+ onMutate: async (_data) => {
177
177
  const queryClient = getQueryClient();
178
178
  await queryClient.cancelQueries({
179
179
  queryKey: getMemberVerificationQueryKey(),
@@ -14,11 +14,14 @@ export function TermsAndConditions({ logo, siteName, content, ...props }) {
14
14
  signUp: ctx.signUp,
15
15
  disclaimer: ctx.disclaimer,
16
16
  termsAndConditions: ctx.termsAndConditions,
17
+ responsibleGaming: ctx.responsibleGaming,
17
18
  })));
18
19
  return (_jsx(Dialog.Root, { open: globalStore.termsAndConditions.open, onOpenChange: (details) => {
19
20
  globalStore.termsAndConditions.setOpen(details.open);
20
- if (!details.open)
21
+ if (!details.open) {
21
22
  globalStore.termsAndConditions.setAccepted(true);
23
+ globalStore.responsibleGaming.setAccepted(true);
24
+ }
22
25
  }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: () => {
23
26
  if (globalStore.termsAndConditions.next === 'SIGN_IN') {
24
27
  globalStore.signIn.setOpen(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.992",
3
+ "version": "0.0.993",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",