@opexa/portal-components 0.1.62 → 0.1.64
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/platformGamesFallback.d.ts +6 -0
- package/dist/client/hooks/platformGamesFallback.js +66 -0
- package/dist/client/hooks/useGamesQuery.js +40 -6
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
- package/dist/services/wallet.d.ts +3 -1
- package/dist/utils/queryKeys.d.ts +1 -0
- package/dist/utils/queryKeys.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GamesInput__Next } from '../../services/cmsPortal';
|
|
2
|
+
import type { PlatformGamesInput } from '../../services/wallet';
|
|
3
|
+
import type { Game, PaginatedQueryResult, PlatformGame } from '../../types';
|
|
4
|
+
export declare const mapGamesInputToPlatformGamesInput: (input?: GamesInput__Next) => PlatformGamesInput;
|
|
5
|
+
export declare const getPlatformGameFallbackImage: (provider: string, gameId: string) => string;
|
|
6
|
+
export declare const normalizePlatformGames: (data: PaginatedQueryResult<PlatformGame>) => PaginatedQueryResult<Game>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ObjectId } from '@opexa/object-id';
|
|
2
|
+
import { PLATFORM_ID, SITE_ID, STATIC_ENDPOINT } from '../../constants/index.js';
|
|
3
|
+
export const mapGamesInputToPlatformGamesInput = (input) => {
|
|
4
|
+
const filter = input?.filter;
|
|
5
|
+
return {
|
|
6
|
+
...(input?.first != null && { first: input.first }),
|
|
7
|
+
...(input?.after != null && { after: input.after }),
|
|
8
|
+
filter: {
|
|
9
|
+
...(filter?.reference && { id: filter.reference }),
|
|
10
|
+
...(filter?.type && { type: filter.type }),
|
|
11
|
+
...(filter?.provider && { provider: filter.provider }),
|
|
12
|
+
status: { equal: 'ACTIVE' },
|
|
13
|
+
hidden: { equal: false },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export const getPlatformGameFallbackImage = (provider, gameId) => {
|
|
18
|
+
const slug = provider.toLowerCase();
|
|
19
|
+
return `${STATIC_ENDPOINT}/images/${slug}/thumbnail-${gameId}.webp`;
|
|
20
|
+
};
|
|
21
|
+
const normalizePlatformGame = (platformGame, cursor) => {
|
|
22
|
+
const name = platformGame.displayName ?? platformGame.name;
|
|
23
|
+
if (platformGame.hidden ||
|
|
24
|
+
platformGame.status !== 'ACTIVE' ||
|
|
25
|
+
!name ||
|
|
26
|
+
!platformGame.provider ||
|
|
27
|
+
!platformGame.type) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const gameId = ObjectId.from(platformGame.id).toString('hex');
|
|
31
|
+
return {
|
|
32
|
+
id: platformGame.id,
|
|
33
|
+
game: platformGame.id,
|
|
34
|
+
name,
|
|
35
|
+
type: platformGame.type,
|
|
36
|
+
provider: platformGame.provider,
|
|
37
|
+
tags: [],
|
|
38
|
+
rank: '0',
|
|
39
|
+
site: SITE_ID,
|
|
40
|
+
image: getPlatformGameFallbackImage(platformGame.provider, gameId),
|
|
41
|
+
cursor,
|
|
42
|
+
status: 'ACTIVE',
|
|
43
|
+
platform: PLATFORM_ID,
|
|
44
|
+
reference: platformGame.id,
|
|
45
|
+
dateTimeCreated: '',
|
|
46
|
+
dateTimeLastUpdated: '',
|
|
47
|
+
favorite: false,
|
|
48
|
+
hidden: false,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export const normalizePlatformGames = (data) => {
|
|
52
|
+
const edges = data.edges.flatMap((edge) => {
|
|
53
|
+
const game = normalizePlatformGame(edge.node, edge.cursor);
|
|
54
|
+
return game ? [{ cursor: edge.cursor, node: game }] : [];
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
edges,
|
|
58
|
+
totalCount: data.totalCount,
|
|
59
|
+
pageInfo: {
|
|
60
|
+
hasNextPage: Boolean(data.pageInfo.hasNextPage && data.pageInfo.endCursor),
|
|
61
|
+
endCursor: data.pageInfo.hasNextPage
|
|
62
|
+
? data.pageInfo.endCursor
|
|
63
|
+
: undefined,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -1,25 +1,59 @@
|
|
|
1
1
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
2
|
import { getGames__next, } from '../../services/cmsPortal.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getPlatformGames } from '../../services/wallet.js';
|
|
4
|
+
import { getGamesPlatformFallbackQueryKey, getGamesQueryKey, } from '../../utils/queryKeys.js';
|
|
5
|
+
import { mapGamesInputToPlatformGamesInput, normalizePlatformGames, } from './platformGamesFallback.js';
|
|
6
|
+
import { useFeatureFlag } from './useFeatureFlag.js';
|
|
7
|
+
const parsePageParam = (pageParam) => {
|
|
8
|
+
if (pageParam?.startsWith('platform:')) {
|
|
9
|
+
return { after: pageParam.slice('platform:'.length), source: 'platform' };
|
|
10
|
+
}
|
|
11
|
+
if (pageParam?.startsWith('cms:')) {
|
|
12
|
+
return { after: pageParam.slice('cms:'.length), source: 'cms' };
|
|
13
|
+
}
|
|
14
|
+
return { after: pageParam, source: 'cms' };
|
|
15
|
+
};
|
|
4
16
|
export const useGamesQuery = (input, config) => {
|
|
17
|
+
const featureFlag = useFeatureFlag();
|
|
18
|
+
const shouldUsePlatformGames = featureFlag.enabled;
|
|
5
19
|
return useInfiniteQuery({
|
|
6
20
|
refetchOnMount: false,
|
|
7
21
|
refetchOnReconnect: false,
|
|
8
22
|
refetchOnWindowFocus: false,
|
|
9
23
|
...config,
|
|
10
|
-
queryKey:
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
queryKey: shouldUsePlatformGames
|
|
25
|
+
? getGamesPlatformFallbackQueryKey(input)
|
|
26
|
+
: getGamesQueryKey(input),
|
|
27
|
+
queryFn: async ({ pageParam, signal }) => {
|
|
28
|
+
const { after, source } = parsePageParam(pageParam);
|
|
29
|
+
if (source === 'platform') {
|
|
30
|
+
const page = await getPlatformGames(mapGamesInputToPlatformGamesInput({ ...input, after }), { signal });
|
|
31
|
+
return { ...normalizePlatformGames(page), __source: 'platform' };
|
|
32
|
+
}
|
|
33
|
+
const page = await getGames__next({
|
|
13
34
|
...input,
|
|
14
|
-
after
|
|
35
|
+
after,
|
|
15
36
|
}, {
|
|
16
37
|
signal,
|
|
17
38
|
});
|
|
39
|
+
signal.throwIfAborted();
|
|
40
|
+
if (!pageParam && shouldUsePlatformGames && page.edges.length === 0) {
|
|
41
|
+
const platformPage = await getPlatformGames(mapGamesInputToPlatformGamesInput(input), { signal });
|
|
42
|
+
return {
|
|
43
|
+
...normalizePlatformGames(platformPage),
|
|
44
|
+
__source: 'platform',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return { ...page, __source: 'cms' };
|
|
18
48
|
},
|
|
19
49
|
initialPageParam: undefined,
|
|
20
50
|
getNextPageParam(lastPage) {
|
|
21
51
|
if (lastPage?.pageInfo?.hasNextPage) {
|
|
22
|
-
|
|
52
|
+
const after = lastPage.pageInfo.endCursor;
|
|
53
|
+
if (after) {
|
|
54
|
+
const source = lastPage.__source ?? 'cms';
|
|
55
|
+
return `${source}:${after}`;
|
|
56
|
+
}
|
|
23
57
|
}
|
|
24
58
|
},
|
|
25
59
|
});
|
package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const OnlineBankDepositContext: (props: {
|
|
2
2
|
value: {
|
|
3
|
-
view: "
|
|
3
|
+
view: "vca" | "form";
|
|
4
4
|
status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
5
5
|
verify: () => void;
|
|
6
6
|
reset: () => void;
|
|
@@ -13,7 +13,7 @@ export declare const OnlineBankDepositContext: (props: {
|
|
|
13
13
|
} & {
|
|
14
14
|
children?: import("react").ReactNode | undefined;
|
|
15
15
|
}) => React.ReactNode, useOnlineBankDepositContext: () => {
|
|
16
|
-
view: "
|
|
16
|
+
view: "vca" | "form";
|
|
17
17
|
status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
18
18
|
verify: () => void;
|
|
19
19
|
reset: () => void;
|
package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Deposit } from '../../../../types';
|
|
2
2
|
export type UseOnlineBankDepositReturn = ReturnType<typeof useOnlineBankDeposit>;
|
|
3
3
|
export declare function useOnlineBankDeposit(): {
|
|
4
|
-
view: "
|
|
4
|
+
view: "vca" | "form";
|
|
5
5
|
status: "waiting" | "failed" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
|
|
6
6
|
verify: () => void;
|
|
7
7
|
reset: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Simplify, SimplifyDeep } from 'type-fest';
|
|
2
|
-
import type { BooleanFilterField, Bonus, Cashback, CashbackBonus, DateFilterField, Deposit, EnumFilterField, GameProvider, GameSession, GameType, InstapayBank, MayaSession, ObjectIdFilterField, PaginatedQueryResult, PlatformGame, PointsWallet, Promo, PromoType, StringFilterField, Wallet } from '../types';
|
|
2
|
+
import type { BooleanFilterField, Bonus, Cashback, CashbackBonus, DateFilterField, Deposit, EnumFilterField, GameProvider, GameSession, GameStatus, GameType, InstapayBank, MayaSession, ObjectIdFilterField, PaginatedQueryResult, PlatformGame, PointsWallet, Promo, PromoType, StringFilterField, Wallet } from '../types';
|
|
3
3
|
import { type GraphQLRequestOptions } from './graphqlRequest';
|
|
4
4
|
export interface PromosQuery {
|
|
5
5
|
promos: Promo[];
|
|
@@ -711,6 +711,8 @@ export interface PlatformGamesQueryVariables {
|
|
|
711
711
|
provider?: EnumFilterField<GameProvider>;
|
|
712
712
|
hasFreeBet?: BooleanFilterField;
|
|
713
713
|
hasJackpot?: BooleanFilterField;
|
|
714
|
+
status?: EnumFilterField<GameStatus>;
|
|
715
|
+
hidden?: BooleanFilterField;
|
|
714
716
|
};
|
|
715
717
|
}
|
|
716
718
|
export interface PlatformGamesQuery {
|
|
@@ -15,6 +15,7 @@ export declare const getDepositQueryKey: (id: string) => QueryKey;
|
|
|
15
15
|
export declare const getDepositRecordsQueryKey: (input?: DepositRecordsInput) => QueryKey;
|
|
16
16
|
export declare const getDepositsCountQueryKey: () => QueryKey;
|
|
17
17
|
export declare const getGamesQueryKey: (input?: GamesInput__Next) => QueryKey;
|
|
18
|
+
export declare const getGamesPlatformFallbackQueryKey: (input?: GamesInput__Next) => QueryKey;
|
|
18
19
|
export declare const getPlatformGamesQueryKey: (input?: PlatformGamesInput) => QueryKey;
|
|
19
20
|
export declare const getFavoriteGamesQueryKey: () => QueryKey;
|
|
20
21
|
export declare const getRecentGamesQueryKey: () => QueryKey;
|
package/dist/utils/queryKeys.js
CHANGED
|
@@ -12,6 +12,7 @@ export const getDepositQueryKey = (id) => [PARENT_KEY, 'deposit', id].filter(Boo
|
|
|
12
12
|
export const getDepositRecordsQueryKey = (input) => [PARENT_KEY, 'depositRecords', input].filter(Boolean);
|
|
13
13
|
export const getDepositsCountQueryKey = () => [PARENT_KEY, 'depositsCount'].filter(Boolean);
|
|
14
14
|
export const getGamesQueryKey = (input) => [PARENT_KEY, 'games', input].filter(Boolean);
|
|
15
|
+
export const getGamesPlatformFallbackQueryKey = (input) => [PARENT_KEY, 'games', 'platform-fallback', input].filter(Boolean);
|
|
15
16
|
export const getPlatformGamesQueryKey = (input) => [PARENT_KEY, 'platformGames', input].filter(Boolean);
|
|
16
17
|
export const getFavoriteGamesQueryKey = () => [PARENT_KEY, 'favoriteGames'].filter(Boolean);
|
|
17
18
|
export const getRecentGamesQueryKey = () => [PARENT_KEY, 'recentGames'].filter(Boolean);
|