@opexa/portal-components 0.0.222 → 0.0.224
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.
- package/dist/client/hooks/useCamera.js +9 -1
- package/dist/client/hooks/useClaimCashbackBonusMutation.js +1 -1
- package/dist/components/Bonuses/Bonuses.client.js +6 -0
- package/dist/components/Disclaimer/Disclaimer.d.ts +1 -0
- package/dist/components/Disclaimer/Disclaimer.js +1 -1
- package/dist/components/Disclaimer/DisclaimerV2.d.ts +1 -0
- package/dist/components/Disclaimer/DisclaimerV2.js +19 -2
- package/dist/components/shared/IdDocumentField.d.ts +2 -3
- package/dist/components/shared/IdDocumentField.js +1 -21
- package/dist/components/shared/SelfieField.d.ts +2 -3
- package/dist/components/shared/SelfieField.js +1 -21
- package/dist/utils/validateFile.d.ts +28 -0
- package/dist/utils/validateFile.js +37 -0
- package/package.json +1 -1
|
@@ -89,7 +89,15 @@ export function useCamera(options = {}) {
|
|
|
89
89
|
video.currentTime = 1;
|
|
90
90
|
const videoRect = video.getBoundingClientRect();
|
|
91
91
|
const lowResolution = video.videoWidth < 640 || video.videoHeight < 480;
|
|
92
|
-
const
|
|
92
|
+
const hdResolution = video.videoWidth >= 1280 && video.videoHeight >= 720;
|
|
93
|
+
const highResolution = video.videoWidth >= 1920 && video.videoHeight >= 1080;
|
|
94
|
+
const scaleFactor = lowResolution
|
|
95
|
+
? (opts.scale ?? 2)
|
|
96
|
+
: highResolution
|
|
97
|
+
? 1
|
|
98
|
+
: hdResolution
|
|
99
|
+
? 1.15
|
|
100
|
+
: 1.25;
|
|
93
101
|
let x = 0;
|
|
94
102
|
let y = 0;
|
|
95
103
|
let w = video.videoWidth;
|
|
@@ -24,7 +24,9 @@ import { Popover } from '../../ui/Popover/index.js';
|
|
|
24
24
|
import { Progress } from '../../ui/Progress/index.js';
|
|
25
25
|
import { SegmentGroup } from '../../ui/SegmentGroup/index.js';
|
|
26
26
|
import { formatNumber } from '../../utils/formatNumber.js';
|
|
27
|
+
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
27
28
|
import { parseDecimal } from '../../utils/parseDecimal.js';
|
|
29
|
+
import { getCashbackBonusesQueryKey } from '../../utils/queryKeys.js';
|
|
28
30
|
import { ClaimSpotBonus } from './ClaimSpotBonus.js';
|
|
29
31
|
const TabSchema = z
|
|
30
32
|
.enum(['all', 'active', 'cashbacks'])
|
|
@@ -84,11 +86,15 @@ function CashbackBonus(props) {
|
|
|
84
86
|
const bonus = props.data;
|
|
85
87
|
const cashback = bonus.cashback;
|
|
86
88
|
const localeInfo = useLocaleInfo();
|
|
89
|
+
const queryClient = getQueryClient();
|
|
87
90
|
const claimCashbackBonusMutation = useClaimCashbackBonusMutation({
|
|
88
91
|
onSuccess() {
|
|
89
92
|
toaster.success({
|
|
90
93
|
description: 'Bonus claimed successfully!',
|
|
91
94
|
});
|
|
95
|
+
queryClient.invalidateQueries({
|
|
96
|
+
queryKey: getCashbackBonusesQueryKey(),
|
|
97
|
+
});
|
|
92
98
|
},
|
|
93
99
|
onError(error) {
|
|
94
100
|
toaster.error({
|
|
@@ -8,6 +8,7 @@ type DisclaimerProps = DisclaimerV1Props | {
|
|
|
8
8
|
responsibleGamingContent: string | ReactNode;
|
|
9
9
|
termsOfUseContent: string | ReactNode;
|
|
10
10
|
responsibleGamingLogo?: ImageProps['src'];
|
|
11
|
+
redirectUrlOnNoConsent: string;
|
|
11
12
|
};
|
|
12
13
|
export declare function Disclaimer(props: DisclaimerProps): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -4,7 +4,7 @@ import { DisclaimerV1 } from './DisclaimerV1.js';
|
|
|
4
4
|
import { DisclaimerV2 } from './DisclaimerV2.js';
|
|
5
5
|
export function Disclaimer(props) {
|
|
6
6
|
if (props.version === 'v2') {
|
|
7
|
-
return (_jsx(DisclaimerV2, { logo: props.logo, siteName: props.siteName, responsibleGamingContent: props.responsibleGamingContent, termsOfUseContent: props.termsOfUseContent, responsibleGamingLogo: props.responsibleGamingLogo }));
|
|
7
|
+
return (_jsx(DisclaimerV2, { logo: props.logo, siteName: props.siteName, responsibleGamingContent: props.responsibleGamingContent, termsOfUseContent: props.termsOfUseContent, responsibleGamingLogo: props.responsibleGamingLogo, redirectUrlOnNoConsent: props.redirectUrlOnNoConsent }));
|
|
8
8
|
}
|
|
9
9
|
return _jsx(DisclaimerV1, { ...props });
|
|
10
10
|
}
|
|
@@ -6,5 +6,6 @@ export interface DisclaimerProps {
|
|
|
6
6
|
responsibleGamingContent: ReactNode;
|
|
7
7
|
termsOfUseContent: ReactNode;
|
|
8
8
|
responsibleGamingLogo?: ImageProps['src'];
|
|
9
|
+
redirectUrlOnNoConsent: string;
|
|
9
10
|
}
|
|
10
11
|
export declare function DisclaimerV2(props: DisclaimerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,10 +17,27 @@ export function DisclaimerV2(props) {
|
|
|
17
17
|
const acceptTriggerRef = useRef(null);
|
|
18
18
|
const [isResponsibleGamingOpen, setResponsibleGamingOpen] = useState(false);
|
|
19
19
|
const [isTermsOfUseOpen, setTermsOfUseOpen] = useState(false);
|
|
20
|
-
|
|
20
|
+
const [isChecked, setIsChecked] = useState(true);
|
|
21
|
+
return (_jsxs(_Fragment, { children: [_jsx(ResponsibleGaming, { responsibleGamingContent: props.responsibleGamingContent, logo: props.logo, open: isResponsibleGamingOpen, onCloseAction: () => setResponsibleGamingOpen(false) }), _jsx(TermsOfUse, { termsOfUseContent: props.termsOfUseContent, siteName: props.siteName, logo: props.logo, open: isTermsOfUseOpen, onCloseAction: () => setTermsOfUseOpen(false) }), _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-sticky" }), _jsx(Dialog.Positioner, { className: "z-sticky", children: _jsxs(Dialog.Content, { className: "flex h-full w-full flex-col items-start gap-y-4 p-3xl lg:mx-auto lg:h-auto lg:w-[400px] lg:rounded-xl", children: [_jsx(Image, { src: props.logo, alt: "", width: 200, height: 100, className: "mx-auto h-auto w-[120px]", draggable: false }), _jsxs("div", { className: "flex w-full items-center justify-center gap-3xl", children: [_jsx(Image, { src: pagcorLogo, alt: "", height: 43, width: 88, className: "h-[43px] w-auto shrink-0", draggable: false }), _jsx(Image, { src: props.responsibleGamingLogo ?? responsibleGamingLogo, alt: "", height: 50, width: 186, className: "h-[50px] w-auto shrink-0", draggable: false })] }), _jsx("div", { className: "text-sm", children: "The following individuals are prohibited from registering or participating in this online gaming platform." }), _jsx("div", { className: "w-full grow", children: _jsxs(Dialog.Description, { className: "space-y-4 text-sm", children: [_jsxs("ul", { className: "space-y-1.5 text-left", children: [_jsxs("li", { className: "flex gap-4", children: [_jsx(Circle, {}), "Persons below the legal gambling age of 21."] }), _jsxs("li", { className: "flex gap-4", children: [_jsx(Circle, {}), "Any government official or employee directly involved in the operations of the government or its agencies."] }), _jsxs("li", { className: "flex gap-4", children: [_jsx(Circle, {}), "Member of the Armed Forces of the Philippines, including the Army, Navy, Air Force and the Philippine National Police."] }), _jsxs("li", { className: "flex gap-4", children: [_jsx(Circle, {}), "Individuals listed in PAGCOR's National Database of Restricted Persons (NDRP)"] }), _jsxs("li", { className: "flex gap-4", children: [_jsx(Circle, {}), "Holders of a valid Gaming Employment License (GEL)"] })] }), _jsxs(Checkbox.Root, { checked: isChecked, onCheckedChange: (e) => {
|
|
22
|
+
setIsChecked(!!e.checked);
|
|
23
|
+
}, children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsxs(Checkbox.Label, { children: ["I have read and agreed to ", props.siteName, ' ', _jsx("button", { type: "button", className: "text-brand-400 underline underline-offset-2", onClick: () => {
|
|
21
24
|
setTermsOfUseOpen(true);
|
|
22
25
|
}, children: "Terms of Use" }), ' ', "and", ' ', _jsx("button", { type: "button", className: "text-brand-400 underline underline-offset-2", onClick: () => {
|
|
23
26
|
setResponsibleGamingOpen(true);
|
|
24
|
-
}, children: "Responsible Gaming" })] }), _jsx(Checkbox.HiddenInput, {})] }), _jsx("div", { 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: "mt-4 flex w-full gap-3", children: [_jsx(Button, { type: "button", onClick:
|
|
27
|
+
}, children: "Responsible Gaming" })] }), _jsx(Checkbox.HiddenInput, {})] }), _jsx("div", { 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: "mt-4 flex w-full gap-3", children: [_jsx(Button, { type: "button", onClick: () => {
|
|
28
|
+
if (isChecked) {
|
|
29
|
+
disclaimer.close();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
window.location.href = props.redirectUrlOnNoConsent;
|
|
33
|
+
}
|
|
34
|
+
}, variant: "outline", children: "Exit" }), _jsx(Button, { ref: acceptTriggerRef, type: "button", onClick: () => {
|
|
35
|
+
if (isChecked) {
|
|
36
|
+
disclaimer.close();
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
window.location.href = props.redirectUrlOnNoConsent;
|
|
40
|
+
}
|
|
41
|
+
}, children: "Accept" })] })] }) })] }) })] }));
|
|
25
42
|
}
|
|
26
43
|
const Circle = () => (_jsx("div", { children: _jsx("div", { className: "border-brand-400 flex h-4.5 w-4.5 items-center justify-center rounded-full border", children: _jsx("div", { className: "bg-brand-400 h-3 w-3 rounded-full" }) }) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CSSProperties, type Ref } from 'react';
|
|
2
|
-
|
|
2
|
+
import { type ValidateFileError } from '../../utils/validateFile';
|
|
3
3
|
export interface IdDocumentFieldProps {
|
|
4
4
|
ref?: Ref<HTMLDivElement>;
|
|
5
5
|
id?: string;
|
|
@@ -12,7 +12,6 @@ export interface IdDocumentFieldProps {
|
|
|
12
12
|
readOnly?: boolean;
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
required?: boolean;
|
|
15
|
-
onError?: (
|
|
15
|
+
onError?: (error: ValidateFileError) => void;
|
|
16
16
|
}
|
|
17
17
|
export declare function IdDocumentField(props: IdDocumentFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export {};
|
|
@@ -22,6 +22,7 @@ import { Button } from '../../ui/Button/index.js';
|
|
|
22
22
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
23
23
|
import { Portal } from '../../ui/Portal/index.js';
|
|
24
24
|
import { dataAttr } from '../../utils/dataAttr.js';
|
|
25
|
+
import { validateFile } from '../../utils/validateFile.js';
|
|
25
26
|
export function IdDocumentField(props) {
|
|
26
27
|
const field = useFieldContext();
|
|
27
28
|
const [value, setValue] = useControllableState({
|
|
@@ -131,24 +132,3 @@ export function IdDocumentField(props) {
|
|
|
131
132
|
camera.reset();
|
|
132
133
|
}, children: [_jsx(RefreshCcw01Icon, { className: "size-5" }), " Retake"] })] }))] }) })] }) })] }));
|
|
133
134
|
}
|
|
134
|
-
function validateFile(file) {
|
|
135
|
-
if (![
|
|
136
|
-
/**/
|
|
137
|
-
'image/png',
|
|
138
|
-
'image/jpg',
|
|
139
|
-
'image/jpeg',
|
|
140
|
-
].includes(file.type)) {
|
|
141
|
-
return 'FILE_TYPE_NOT_SUPPORTED';
|
|
142
|
-
}
|
|
143
|
-
if (10 < file.size / (1024 * 1024)) {
|
|
144
|
-
return 'FILE_SIZE_TOO_LARGE';
|
|
145
|
-
}
|
|
146
|
-
if (48 <
|
|
147
|
-
file.name
|
|
148
|
-
.split('.')
|
|
149
|
-
.filter((_, i, self) => i + 1 < self.length)
|
|
150
|
-
.join('.').length) {
|
|
151
|
-
return 'FILE_NAME_TOO_LONG';
|
|
152
|
-
}
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CSSProperties, type Ref } from 'react';
|
|
2
|
-
|
|
2
|
+
import { type ValidateFileError } from '../../utils/validateFile';
|
|
3
3
|
export interface SelfieFieldProps {
|
|
4
4
|
ref?: Ref<HTMLDivElement>;
|
|
5
5
|
id?: string;
|
|
@@ -12,7 +12,6 @@ export interface SelfieFieldProps {
|
|
|
12
12
|
readOnly?: boolean;
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
required?: boolean;
|
|
15
|
-
onError?: (
|
|
15
|
+
onError?: (error: ValidateFileError) => void;
|
|
16
16
|
}
|
|
17
17
|
export declare function SelfieField(props: SelfieFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export {};
|
|
@@ -21,6 +21,7 @@ import { Button } from '../../ui/Button/index.js';
|
|
|
21
21
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
22
22
|
import { Portal } from '../../ui/Portal/index.js';
|
|
23
23
|
import { dataAttr } from '../../utils/dataAttr.js';
|
|
24
|
+
import { validateFile } from '../../utils/validateFile.js';
|
|
24
25
|
export function SelfieField(props) {
|
|
25
26
|
const field = useFieldContext();
|
|
26
27
|
const [value, setValue] = useControllableState({
|
|
@@ -125,24 +126,3 @@ export function SelfieField(props) {
|
|
|
125
126
|
camera.reset();
|
|
126
127
|
}, children: [_jsx(RefreshCcw01Icon, { className: "size-5" }), " Retake"] })] }))] }) })] }) })] }));
|
|
127
128
|
}
|
|
128
|
-
function validateFile(file) {
|
|
129
|
-
if (![
|
|
130
|
-
/**/
|
|
131
|
-
'image/png',
|
|
132
|
-
'image/jpg',
|
|
133
|
-
'image/jpeg',
|
|
134
|
-
].includes(file.type)) {
|
|
135
|
-
return 'FILE_TYPE_NOT_SUPPORTED';
|
|
136
|
-
}
|
|
137
|
-
if (10 < file.size / (1024 * 1024)) {
|
|
138
|
-
return 'FILE_SIZE_TOO_LARGE';
|
|
139
|
-
}
|
|
140
|
-
if (48 <
|
|
141
|
-
file.name
|
|
142
|
-
.split('.')
|
|
143
|
-
.filter((_, i, self) => i + 1 < self.length)
|
|
144
|
-
.join('.').length) {
|
|
145
|
-
return 'FILE_NAME_TOO_LONG';
|
|
146
|
-
}
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ValidateFileOptions {
|
|
2
|
+
/**
|
|
3
|
+
* @description Maximum file size in MB.
|
|
4
|
+
* @default 10
|
|
5
|
+
*/
|
|
6
|
+
maxFileSize?: number;
|
|
7
|
+
/**
|
|
8
|
+
* @description Maximum file name length.
|
|
9
|
+
* @default 48
|
|
10
|
+
*/
|
|
11
|
+
maxFileName?: number;
|
|
12
|
+
/**
|
|
13
|
+
* @description Supported mime types.
|
|
14
|
+
* @default
|
|
15
|
+
* [
|
|
16
|
+
* 'image/png',
|
|
17
|
+
* 'image/jpg',
|
|
18
|
+
* 'image/jpeg'
|
|
19
|
+
* ]
|
|
20
|
+
*/
|
|
21
|
+
supportedFiles?: string[];
|
|
22
|
+
}
|
|
23
|
+
export type ValidateFileErrorName = 'FILE_NAME_TOO_LONG' | 'FILE_SIZE_TOO_LARGE' | 'FILE_TYPE_NOT_SUPPORTED';
|
|
24
|
+
export interface ValidateFileError {
|
|
25
|
+
name: ValidateFileErrorName;
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function validateFile(file: File, options?: ValidateFileOptions): ValidateFileError | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function validateFile(file, options) {
|
|
2
|
+
const maxFileSize = options?.maxFileSize ?? 10;
|
|
3
|
+
const maxFileName = options?.maxFileName ?? 48;
|
|
4
|
+
const supportedFiles = options?.supportedFiles ?? [
|
|
5
|
+
'image/png',
|
|
6
|
+
'image/jpg',
|
|
7
|
+
'image/jpeg',
|
|
8
|
+
];
|
|
9
|
+
if (!supportedFiles.includes(file.type)) {
|
|
10
|
+
return {
|
|
11
|
+
name: 'FILE_TYPE_NOT_SUPPORTED',
|
|
12
|
+
message: 'File type not supported.',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (mb(file.size) > maxFileSize) {
|
|
16
|
+
return {
|
|
17
|
+
name: 'FILE_SIZE_TOO_LARGE',
|
|
18
|
+
message: 'File size too large.',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (basename(file.name).length > maxFileName) {
|
|
22
|
+
return {
|
|
23
|
+
name: 'FILE_NAME_TOO_LONG',
|
|
24
|
+
message: 'File name is too long.',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function mb(bytes) {
|
|
30
|
+
return bytes / (1024 * 1024);
|
|
31
|
+
}
|
|
32
|
+
function basename(name) {
|
|
33
|
+
return name
|
|
34
|
+
.split('.')
|
|
35
|
+
.filter((_, i, self) => i + 1 < self.length)
|
|
36
|
+
.join('.');
|
|
37
|
+
}
|