@opexa/portal-components 0.0.1100 → 0.0.1102
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,15 +1,37 @@
|
|
|
1
|
-
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
1
|
+
import { useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { useEffect } from 'react';
|
|
2
3
|
import { getJackpots } from '../../services/report.js';
|
|
3
|
-
import {
|
|
4
|
+
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
5
|
+
import { getJackpotsQueryKey, getSessionQueryKey } from '../../utils/queryKeys.js';
|
|
6
|
+
import { getSession } from '../services/getSession.js';
|
|
7
|
+
import { useSessionQuery } from './useSessionQuery.js';
|
|
4
8
|
export const useJackpotsQuery = (input, config) => {
|
|
9
|
+
const sessionQuery = useSessionQuery();
|
|
10
|
+
const queryClient = useQueryClient();
|
|
11
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: intentionally only re-runs on session status change; input is stable per call site and queryClient is stable from useQueryClient
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (sessionQuery.data?.status === 'authenticated') {
|
|
14
|
+
queryClient.invalidateQueries({
|
|
15
|
+
queryKey: getJackpotsQueryKey(input),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}, [sessionQuery.data?.status]);
|
|
5
19
|
const query = useInfiniteQuery({
|
|
6
20
|
refetchOnMount: false,
|
|
7
21
|
refetchOnReconnect: false,
|
|
8
22
|
refetchOnWindowFocus: false,
|
|
23
|
+
staleTime: 0,
|
|
9
24
|
...config,
|
|
10
25
|
queryKey: getJackpotsQueryKey(input),
|
|
11
|
-
queryFn: ({ pageParam, signal }) => {
|
|
12
|
-
|
|
26
|
+
queryFn: async ({ pageParam, signal }) => {
|
|
27
|
+
const session = await getQueryClient().fetchQuery({
|
|
28
|
+
queryKey: getSessionQueryKey(),
|
|
29
|
+
queryFn: async () => getSession(),
|
|
30
|
+
});
|
|
31
|
+
const authHeader = session.status === 'authenticated'
|
|
32
|
+
? { Authorization: `Bearer ${session.token}` }
|
|
33
|
+
: {};
|
|
34
|
+
return getJackpots({ ...input, after: pageParam }, { signal, headers: authHeader });
|
|
13
35
|
},
|
|
14
36
|
initialPageParam: undefined,
|
|
15
37
|
getNextPageParam(lastPage) {
|
|
@@ -40,7 +40,7 @@ export function WageringQuest(props) {
|
|
|
40
40
|
const numericValue = parseFloat(value);
|
|
41
41
|
return Math.floor(numericValue).toString();
|
|
42
42
|
};
|
|
43
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: twMerge('flex h-full w-full flex-col space-y-6 rounded-2xl border border-border-primary bg-bg-tertiary px-4 pt-5 pb-6', classNames?.root), children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-start justify-between", children: [_jsx(RemainingTime, {}), _jsx("button", { type: "button", className: "flex size-9 cursor-pointer items-center justify-center rounded-md border border-border-secondary bg-bg-primary", onClick: () => disclosure.setOpen(true), "aria-label": "View Rules", children: _jsx(InfoCircleIcon, { className: "size-5 text-text-disabled" }) })] }), _jsx("p", { className: "font-semibold text-xl", children: name }), _jsx(Prose, { className: "text-wrap font-normal text-sm text-text-secondary-700", dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsxs("div", { className: "group flex items-center justify-between text-text-primary-brand", children: [_jsxs("p", { children: ["Progress ", progressValue.toFixed(0), "%"] }), _jsxs("p", { children: [formatTurnover(turnover), _jsxs("span", { className: "text-text-quarterary-brand", children: ["/", targetTurnover, " ", localeInfo.currency.code] })] })] }), _jsx("div", { className: twMerge('h-2 w-full overflow-hidden rounded-full bg-bg-primary', classNames?.progressBarContainer), children: _jsx("div", { className: twMerge('h-full rounded-full bg-utility-brand-600 transition-all duration-300', classNames?.progressBar), style: { width: `${progressValue}%` } }) })] }), _jsx("div", { className: "flex h-full items-end", children: _jsx("div", { className: twMerge('w-full rounded-md border border-bg-primary-hover bg-button-secondary-bg px-3.5 py-2.5 text-center', classNames?.bonusContainer), children: status === 'COMPLETED' && customComplete ? (_jsx("div", { className: twMerge(classNames?.bonusText), children: customComplete })) : (_jsxs("p", { className: twMerge((remainingTime.expired ||
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: twMerge('flex h-full w-full flex-col space-y-6 rounded-2xl border border-border-primary bg-bg-tertiary px-4 pt-5 pb-6', classNames?.root), children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-start justify-between", children: [_jsx(RemainingTime, {}), _jsx("button", { type: "button", className: "flex size-9 cursor-pointer items-center justify-center rounded-md border border-border-secondary bg-bg-primary", onClick: () => disclosure.setOpen(true), "aria-label": "View Rules", children: _jsx(InfoCircleIcon, { className: "size-5 text-text-disabled" }) })] }), _jsx("p", { className: "font-semibold text-xl", children: name }), _jsx(Prose, { className: "text-wrap font-normal text-sm text-text-secondary-700", dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsxs("div", { className: "group flex items-center justify-between text-text-primary-brand", children: [_jsxs("p", { children: ["Progress ", progressValue.toFixed(0), "%"] }), _jsxs("p", { children: [formatTurnover(turnover), _jsxs("span", { className: "text-text-quarterary-brand", children: ["/", targetTurnover, " ", localeInfo.currency.code] })] })] }), _jsx("div", { className: twMerge('h-2 w-full min-w-0 overflow-hidden rounded-full bg-bg-primary', classNames?.progressBarContainer), children: _jsx("div", { className: twMerge('block h-full rounded-full bg-utility-brand-600 transition-all duration-300', classNames?.progressBar), style: { width: `${progressValue}%` } }) })] }), _jsx("div", { className: "flex h-full items-end", children: _jsx("div", { className: twMerge('w-full rounded-md border border-bg-primary-hover bg-button-secondary-bg px-3.5 py-2.5 text-center', classNames?.bonusContainer), children: status === 'COMPLETED' && customComplete ? (_jsx("div", { className: twMerge(classNames?.bonusText), children: customComplete })) : (_jsxs("p", { className: twMerge((remainingTime.expired ||
|
|
44
44
|
status === 'COMPLETED' ||
|
|
45
45
|
status === 'FAILED') &&
|
|
46
46
|
'opacity-50 grayscale', classNames?.bonusText), children: ["Complete to get", ' ', _jsxs("span", { className: twMerge('text-brand-400', classNames?.bonusAmount), children: ["\u20B1", bonus] }), ' ', "bonus!"] })) }) })] }), _jsx(Rules, { open: disclosure.open, onOpenChange: disclosure.setOpen, gameProviderCarousel: props.gameProviderCarousel, gameProviders: Object.entries(quest.turnoverRequirementContributionPercentagePerGameProvider ?? [])
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Progress } from '@ark-ui/react';
|
|
4
3
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
5
4
|
import { isString } from 'lodash-es';
|
|
6
5
|
import Image from 'next/image';
|
|
@@ -56,7 +55,7 @@ export function WageringQuestNext(props) {
|
|
|
56
55
|
completedBadgeLabel: classNames?.completedBadgeLabel,
|
|
57
56
|
failedBadgeRoot: classNames?.failedBadgeRoot,
|
|
58
57
|
failedBadgeLabel: classNames?.failedBadgeLabel,
|
|
59
|
-
} })] }), _jsx("p", { className: twMerge('font-semibold text-xl', classNames?.title), children: name }), _jsx(Prose, { className: twMerge('text-wrap font-normal text-sm text-text-secondary-700', classNames?.description), dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsxs("div", { className: twMerge('group flex items-center justify-between text-text-primary-brand', classNames?.progressLabel), children: [_jsxs("p", { children: ["Progress ", progressValue.toFixed(0), "%"] }), _jsxs("p", { children: [formatTurnover(turnover), _jsxs("span", { children: ["/", targetTurnover, " ", localeInfo.currency.code] })] })] }), _jsx(
|
|
58
|
+
} })] }), _jsx("p", { className: twMerge('font-semibold text-xl', classNames?.title), children: name }), _jsx(Prose, { className: twMerge('text-wrap font-normal text-sm text-text-secondary-700', classNames?.description), dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsxs("div", { className: twMerge('group flex items-center justify-between text-text-primary-brand', classNames?.progressLabel), children: [_jsxs("p", { children: ["Progress ", progressValue.toFixed(0), "%"] }), _jsxs("p", { children: [formatTurnover(turnover), _jsxs("span", { children: ["/", targetTurnover, " ", localeInfo.currency.code] })] })] }), _jsx("div", { className: twMerge('h-2 w-full overflow-hidden rounded-full bg-bg-primary', classNames?.progressRoot, classNames?.progressTrack), children: _jsx("div", { className: twMerge('h-full rounded-full bg-utility-brand-600 transition-all duration-300', classNames?.progressRange), style: { width: `${progressValue}%` } }) }), _jsxs("div", { className: "group flex items-center justify-between text-text-primary-brand", children: [_jsxs("p", { className: classNames?.stageProgress, children: ["Stage ", currentStage, " of ", quest?.program.stages?.length] }), _jsx(Badge.Root, { className: twMerge('rounded-[6px] border border-utility-brand-200 bg-utility-brand-50 px-1.5 py-0.5', classNames?.bonusBadgeRoot), children: _jsxs(Badge.Label, { className: twMerge('font-medium text-utility-brand-700 text-xs leading-tight', classNames?.bonusBadgeLabel), children: ["+", ' ', formatNumber(bonus, {
|
|
60
59
|
currency: localeInfo.currency.code,
|
|
61
60
|
}), ' ', "Bonus"] }) })] })] }), status === 'IN_PROGRESS' && (_jsx("div", { className: "flex h-full items-end", children: _jsx(Button, { size: "sm", onClick: () => disclosure.setOpen(true), "aria-label": "View Details", disabled: false, className: "disabled:bg-bg-primary disabled:text-text-disabled", children: "View Details" }) }))] }), _jsx(Rules, { open: disclosure.open, onOpenChange: disclosure.setOpen, gameProviderCarousel: props.gameProviderCarousel, gameProviders: Object.entries(quest.turnoverRequirementContributionPercentagePerGameProvider ?? [])
|
|
62
61
|
.filter(([_, value]) => +value > 0)
|