@opexa/portal-components 0.0.734 → 0.0.736
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.d.ts +1 -1
- package/dist/client/hooks/useCamera.js +5 -1
- package/dist/components/GameLaunch/GameLaunchTrigger.js +21 -0
- package/dist/components/Jackpots/JackpotsListNext/JackpotsListItemGameProviders.d.ts +7 -1
- package/dist/components/Jackpots/JackpotsListNext/JackpotsListItemGameProviders.js +2 -11
- package/dist/components/PortalProvider/PushNotifications.js +1 -2
- package/dist/components/SignIn/SignInTrigger.js +22 -1
- package/dist/components/shared/IdFrontImageField/IdFrontImageField.client.js +1 -1
- package/dist/components/shared/SelfieImageField/SelfieImageField.client.js +1 -1
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ export interface CameraData {
|
|
|
11
11
|
}
|
|
12
12
|
export interface UseCameraReturn<T extends string = never> {
|
|
13
13
|
open(): Promise<void>;
|
|
14
|
-
openNativeCamera(): Promise<File | null>;
|
|
14
|
+
openNativeCamera(direction: 'front' | 'back'): Promise<File | null>;
|
|
15
15
|
close(): Promise<void>;
|
|
16
16
|
snap(): Promise<CameraData | null>;
|
|
17
17
|
reopen(): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CameraDirection } from '@capacitor/camera';
|
|
1
2
|
import { isBoolean } from 'lodash-es';
|
|
2
3
|
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
3
4
|
import invariant from 'tiny-invariant';
|
|
@@ -80,7 +81,7 @@ export function useCamera(options = {}) {
|
|
|
80
81
|
}
|
|
81
82
|
}, [options, desktop]);
|
|
82
83
|
// biome-ignore lint/correctness/useExhaustiveDependencies: Intentional empty deps: we need a stable openNativeCamera reference.
|
|
83
|
-
const openNativeCamera = useCallback(async () => {
|
|
84
|
+
const openNativeCamera = useCallback(async (direction) => {
|
|
84
85
|
setData(null);
|
|
85
86
|
setError(null);
|
|
86
87
|
setSnapping(true);
|
|
@@ -91,6 +92,9 @@ export function useCamera(options = {}) {
|
|
|
91
92
|
quality: 80,
|
|
92
93
|
resultType: CameraResultType.Base64,
|
|
93
94
|
allowEditing: false,
|
|
95
|
+
direction: direction === 'front'
|
|
96
|
+
? CameraDirection.Front
|
|
97
|
+
: CameraDirection.Rear,
|
|
94
98
|
});
|
|
95
99
|
if (!photo.base64String) {
|
|
96
100
|
throw new Error('No photo returned from native camera');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { ark } from '@ark-ui/react/factory';
|
|
4
|
+
import { Capacitor } from '@capacitor/core';
|
|
4
5
|
import { BiometricAuthError } from 'capacitor-native-biometric';
|
|
5
6
|
import { useState } from 'react';
|
|
6
7
|
import { useShallow } from 'zustand/shallow';
|
|
@@ -13,8 +14,10 @@ import { signIn } from '../../client/services/signIn.js';
|
|
|
13
14
|
import { deleteBiometricCredentials, getBiometricCredentials, getBiometricInfo, hasSavedBiometry, performBiometricVerification, saveBiometricCredentials, } from '../../client/utils/biometric.js';
|
|
14
15
|
import { toaster } from '../../client/utils/toaster.js';
|
|
15
16
|
import { createSingleUseToken } from '../../services/auth.js';
|
|
17
|
+
import { registerFCMDevice, unregisterFCMDevice } from '../../services/trigger.js';
|
|
16
18
|
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
17
19
|
import { getSessionQueryKey } from '../../utils/queryKeys.js';
|
|
20
|
+
import { LOCALSTORAGE_PUSH_NOTIFICATION_TOKEN_KEY } from '../PortalProvider/PushNotifications.js';
|
|
18
21
|
export function GameLaunchTrigger(props) {
|
|
19
22
|
const sessionQuery = useSessionQuery();
|
|
20
23
|
const verificationQuery = useMemberVerificationQuery();
|
|
@@ -95,6 +98,24 @@ export function GameLaunchTrigger(props) {
|
|
|
95
98
|
queryKey: getSessionQueryKey(),
|
|
96
99
|
});
|
|
97
100
|
const session = await getSession();
|
|
101
|
+
const pushToken = localStorage.getItem(LOCALSTORAGE_PUSH_NOTIFICATION_TOKEN_KEY);
|
|
102
|
+
await unregisterFCMDevice({
|
|
103
|
+
type: ['IOS', 'ANDROID'],
|
|
104
|
+
}, {
|
|
105
|
+
headers: {
|
|
106
|
+
Authorization: `Bearer ${session.token}`,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
if (pushToken) {
|
|
110
|
+
await registerFCMDevice({
|
|
111
|
+
type: Capacitor.getPlatform() === 'android' ? 'ANDROID' : 'IOS',
|
|
112
|
+
token: pushToken,
|
|
113
|
+
}, {
|
|
114
|
+
headers: {
|
|
115
|
+
Authorization: `Bearer ${session.token}`,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
98
119
|
const r = await createSingleUseToken({
|
|
99
120
|
headers: {
|
|
100
121
|
Authorization: `Bearer ${session.token}`,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { type ImageProps } from 'next/image';
|
|
1
2
|
import type { GameProviderData } from '../../../types';
|
|
3
|
+
interface JackpotGameProvider extends GameProviderData {
|
|
4
|
+
redirectUrl: string;
|
|
5
|
+
providedLogo?: ImageProps['src'];
|
|
6
|
+
}
|
|
2
7
|
export interface JackpotsListItemGameProvidersProps {
|
|
3
|
-
gameProviders:
|
|
8
|
+
gameProviders: JackpotGameProvider[];
|
|
4
9
|
}
|
|
5
10
|
export declare function JackpotsListItemGameProviders({ gameProviders, }: JackpotsListItemGameProvidersProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
3
3
|
import { isString } from 'lodash-es';
|
|
4
|
-
import Image from 'next/image';
|
|
4
|
+
import Image, {} from 'next/image';
|
|
5
5
|
import Link from 'next/link';
|
|
6
6
|
import { useCallback, useEffect, useState } from 'react';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
8
|
import { ArrowLeftIcon } from '../../../icons/ArrowLeftIcon.js';
|
|
9
9
|
import { ArrowRightIcon } from '../../../icons/ArrowRightIcon.js';
|
|
10
10
|
import { Button } from '../../../ui/Button/index.js';
|
|
11
|
-
import { callIfFn } from '../../../utils/callIfFn.js';
|
|
12
11
|
import { useJackpotsListPropsContext } from './JackpotsListContext.js';
|
|
13
12
|
export function JackpotsListItemGameProviders({ gameProviders, }) {
|
|
14
13
|
const jackpotsProps = useJackpotsListPropsContext();
|
|
15
|
-
const viewGamesUrl = (data) => {
|
|
16
|
-
return jackpotsProps.viewGamesUrl
|
|
17
|
-
? callIfFn(jackpotsProps.viewGamesUrl, data)
|
|
18
|
-
.replace(':id', data.id)
|
|
19
|
-
.replace(':slug', data.slug)
|
|
20
|
-
: `/providers/${data.slug}`;
|
|
21
|
-
};
|
|
22
14
|
const classNames = isString(jackpotsProps.className)
|
|
23
15
|
? { root: jackpotsProps.className }
|
|
24
16
|
: (jackpotsProps.className ?? {});
|
|
@@ -49,6 +41,5 @@ export function JackpotsListItemGameProviders({ gameProviders, }) {
|
|
|
49
41
|
emblaApi.on('select', onSelect);
|
|
50
42
|
emblaApi.on('reInit', onSelect);
|
|
51
43
|
}, [emblaApi, onSelect]);
|
|
52
|
-
return (_jsxs("div", { className: twMerge('p-4 pb-8', classNames.providerRoot), children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: twMerge('font-semibold text-lg text-text-primary-900', classNames.providerHeading), children: "Jackpot Game Providers" }), _jsxs("div", { className: "hidden lg:flex", children: [_jsx(Button, { disabled: !canScrollPrev, onClick: scrollPrev, variant: "outline", colorScheme: "gray", className: twMerge('rounded-r-none border-r-0', classNames.providerNavigationButton), "aria-label": "Previous", children: _jsx(ArrowLeftIcon, { className: "size-5" }) }), _jsxs(Button, { disabled: !canScrollNext, onClick: scrollNext, variant: "outline", colorScheme: "gray", className: twMerge('rounded-l-none', classNames.providerNavigationButton), "aria-label": "Next", children: [_jsx("span", { className: "sr-only", children: "Next" }), _jsx(ArrowRightIcon, { className: "size-5" })] })] })] }), _jsx("div", { className: "relative mt-3 overflow-hidden", ref: emblaRef, children: _jsx("div", { className: "flex gap-3.5", children: gameProviders.map((provider) => (_jsx(Link, { href:
|
|
53
|
-
provider.logo, alt: "provider", className: twMerge('size-full', classNames.providerThumbnailImage), width: 300, height: 150 }) }, provider.slug))) }) })] }));
|
|
44
|
+
return (_jsxs("div", { className: twMerge('p-4 pb-8', classNames.providerRoot), children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: twMerge('font-semibold text-lg text-text-primary-900', classNames.providerHeading), children: "Jackpot Game Providers" }), _jsxs("div", { className: "hidden lg:flex", children: [_jsx(Button, { disabled: !canScrollPrev, onClick: scrollPrev, variant: "outline", colorScheme: "gray", className: twMerge('rounded-r-none border-r-0', classNames.providerNavigationButton), "aria-label": "Previous", children: _jsx(ArrowLeftIcon, { className: "size-5" }) }), _jsxs(Button, { disabled: !canScrollNext, onClick: scrollNext, variant: "outline", colorScheme: "gray", className: twMerge('rounded-l-none', classNames.providerNavigationButton), "aria-label": "Next", children: [_jsx("span", { className: "sr-only", children: "Next" }), _jsx(ArrowRightIcon, { className: "size-5" })] })] })] }), _jsx("div", { className: "relative mt-3 overflow-hidden", ref: emblaRef, children: _jsx("div", { className: "flex gap-3.5", children: gameProviders.map((provider) => (_jsx(Link, { href: provider.redirectUrl, className: twMerge('min-w-27.5 rounded-md bg-brand-800 lg:bg-bg-primary-900', classNames.providerThumbnailRoot), children: _jsx(Image, { src: provider.providedLogo ?? provider.logo, alt: "provider", className: twMerge('size-full', classNames.providerThumbnailImage), width: 300, height: 150 }) }, provider.slug))) }) })] }));
|
|
54
45
|
}
|
|
@@ -7,8 +7,6 @@ import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
|
|
|
7
7
|
import { registerFCMDevice } from '../../services/trigger.js';
|
|
8
8
|
export const LOCALSTORAGE_PUSH_NOTIFICATION_TOKEN_KEY = 'push-notication-token';
|
|
9
9
|
export const PushNotification = () => {
|
|
10
|
-
console.log('remove listeners on each render to avoid duplicates');
|
|
11
|
-
PushNotifications.removeAllListeners();
|
|
12
10
|
const session = useSessionQuery();
|
|
13
11
|
useEffect(() => {
|
|
14
12
|
const platform = Capacitor.getPlatform();
|
|
@@ -38,6 +36,7 @@ export const PushNotification = () => {
|
|
|
38
36
|
}
|
|
39
37
|
localStorage.setItem(LOCALSTORAGE_PUSH_NOTIFICATION_TOKEN_KEY, value);
|
|
40
38
|
if (session.data?.status === 'authenticated') {
|
|
39
|
+
console.log('registering push token with backend');
|
|
41
40
|
await registerFCMDevice({
|
|
42
41
|
type: platform === 'android' ? 'ANDROID' : 'IOS',
|
|
43
42
|
token: value,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { ark } from '@ark-ui/react/factory';
|
|
4
|
+
import { Capacitor } from '@capacitor/core';
|
|
4
5
|
import { useState } from 'react';
|
|
5
6
|
import { useShallow } from 'zustand/shallow';
|
|
6
7
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
@@ -9,8 +10,10 @@ import { signIn } from '../../client/services/signIn.js';
|
|
|
9
10
|
import { BiometricAuthError, deleteBiometricCredentials, getBiometricCredentials, getBiometricInfo, hasSavedBiometry, performBiometricVerification, saveBiometricCredentials, } from '../../client/utils/biometric.js';
|
|
10
11
|
import { toaster } from '../../client/utils/toaster.js';
|
|
11
12
|
import { createSingleUseToken } from '../../services/auth.js';
|
|
13
|
+
import { registerFCMDevice, unregisterFCMDevice } from '../../services/trigger.js';
|
|
12
14
|
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
13
15
|
import { getSessionQueryKey } from '../../utils/queryKeys.js';
|
|
16
|
+
import { LOCALSTORAGE_PUSH_NOTIFICATION_TOKEN_KEY } from '../PortalProvider/PushNotifications.js';
|
|
14
17
|
export function SignInTrigger(props) {
|
|
15
18
|
const [hasCancelledBiometric, setHasCancelledBiometric] = useState(false);
|
|
16
19
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
@@ -63,10 +66,28 @@ export function SignInTrigger(props) {
|
|
|
63
66
|
deleteBiometricCredentials();
|
|
64
67
|
globalStore.signIn.setOpen(!globalStore.signIn.open);
|
|
65
68
|
}
|
|
69
|
+
const pushToken = localStorage.getItem(LOCALSTORAGE_PUSH_NOTIFICATION_TOKEN_KEY);
|
|
70
|
+
const session = await getSession();
|
|
71
|
+
await unregisterFCMDevice({
|
|
72
|
+
type: ['IOS', 'ANDROID'],
|
|
73
|
+
}, {
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: `Bearer ${session.token}`,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
if (pushToken) {
|
|
79
|
+
await registerFCMDevice({
|
|
80
|
+
type: Capacitor.getPlatform() === 'android' ? 'ANDROID' : 'IOS',
|
|
81
|
+
token: pushToken,
|
|
82
|
+
}, {
|
|
83
|
+
headers: {
|
|
84
|
+
Authorization: `Bearer ${session.token}`,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
66
88
|
getQueryClient().invalidateQueries({
|
|
67
89
|
queryKey: getSessionQueryKey(),
|
|
68
90
|
});
|
|
69
|
-
const session = await getSession();
|
|
70
91
|
const r = await createSingleUseToken({
|
|
71
92
|
headers: {
|
|
72
93
|
Authorization: `Bearer ${session.token}`,
|
|
@@ -55,7 +55,7 @@ export function IdFrontImageField__client(props) {
|
|
|
55
55
|
localProps.disabled ||
|
|
56
56
|
localProps.readOnly, className: "font-semibold text-button-secondary-fg disabled:opacity-60", children: "Click to upload" }), ' ', "or drag and drop"] }), _jsx("span", { className: "mt-xs block text-center text-xs", children: "PNG, JPG or JPEG (max. 10mb)" }), _jsx("span", { className: "m-txs block text-center text-xs", children: "or" })] }), _jsx(Button, { size: "sm", variant: "outline", className: "mx-auto mt-md w-auto", onClick: async () => {
|
|
57
57
|
if (Capacitor.isNativePlatform()) {
|
|
58
|
-
const file = await context.camera.openNativeCamera();
|
|
58
|
+
const file = await context.camera.openNativeCamera('back');
|
|
59
59
|
if (!file)
|
|
60
60
|
return;
|
|
61
61
|
context.mutation.mutate({ file });
|
|
@@ -55,7 +55,7 @@ export function SelfieImageField__client(props) {
|
|
|
55
55
|
localProps.disabled ||
|
|
56
56
|
localProps.readOnly, className: "font-semibold text-button-secondary-fg disabled:opacity-60", children: "Click to upload" }), ' ', "or drag and drop"] }), _jsx("span", { className: "mt-xs block text-center text-xs", children: "PNG, JPG or JPEG (max. 10mb)" }), _jsx("span", { className: "m-txs block text-center text-xs", children: "or" })] }), _jsx(Button, { size: "sm", variant: "outline", className: "mx-auto mt-md w-auto", onClick: async () => {
|
|
57
57
|
if (Capacitor.isNativePlatform()) {
|
|
58
|
-
const file = await context.camera.openNativeCamera();
|
|
58
|
+
const file = await context.camera.openNativeCamera('front');
|
|
59
59
|
if (!file)
|
|
60
60
|
return;
|
|
61
61
|
context.mutation.mutate({ file });
|