@opexa/portal-components 0.0.136 → 0.0.137
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/useClaimCashbackBonusMutation.js +10 -5
- package/dist/components/Bonuses/Bonuses.client.js +22 -3
- package/dist/components/GamesSearch/GamesSearch.js +1 -1
- package/dist/components/NewsFeed/NewsFeedCarousel.js +1 -1
- package/dist/components/Promos/Cashback.js +1 -1
- package/dist/components/Promos/CustomPromo.js +1 -1
- package/dist/components/Promos/Promo.js +1 -1
- package/dist/components/Search/Search.lazy.js +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import invariant from 'tiny-invariant';
|
|
|
3
3
|
import { claimCashbackBonus } from '../../services/wallet.js';
|
|
4
4
|
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
5
5
|
import { getClaimCashbackBonusMutationKey } from '../../utils/mutationKeys.js';
|
|
6
|
-
import {
|
|
6
|
+
import { getCashbackBonusesQueryKey } from '../../utils/queryKeys.js';
|
|
7
7
|
import { getSession } from '../services/getSession.js';
|
|
8
8
|
export const useClaimCashbackBonusMutation = (config) => {
|
|
9
9
|
const queryClient = getQueryClient();
|
|
@@ -18,10 +18,15 @@ export const useClaimCashbackBonusMutation = (config) => {
|
|
|
18
18
|
Authorization: `Bearer ${session.token}`,
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
|
-
queryClient.setQueryData(getCashbackBonusesQueryKey(), (prev) => prev?.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
queryClient.setQueryData(getCashbackBonusesQueryKey(), (prev) => prev?.map((bonus) => {
|
|
22
|
+
if (bonus.id !== id) {
|
|
23
|
+
return {
|
|
24
|
+
...bonus,
|
|
25
|
+
balance: '0',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return bonus;
|
|
29
|
+
}));
|
|
25
30
|
},
|
|
26
31
|
});
|
|
27
32
|
};
|
|
@@ -13,6 +13,7 @@ import { useClaimCashbackBonusMutation } from '../../client/hooks/useClaimCashba
|
|
|
13
13
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
14
14
|
import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
|
|
15
15
|
import { useRemainingTime } from '../../client/hooks/useRemainingTime.js';
|
|
16
|
+
import { toaster } from '../../client/utils/toaster.js';
|
|
16
17
|
import { StopWatchIcon } from '../../icons/StopWatchIcon.js';
|
|
17
18
|
import moneyOnHand from '../../images/money-on-hand.png';
|
|
18
19
|
import piggyBank from '../../images/piggy-bank.png';
|
|
@@ -67,16 +68,34 @@ function CashbackBonus(props) {
|
|
|
67
68
|
const bonus = props.data;
|
|
68
69
|
const cashback = bonus.cashback;
|
|
69
70
|
const localeInfo = useLocaleInfo();
|
|
70
|
-
const claimCashbackBonusMutation = useClaimCashbackBonusMutation(
|
|
71
|
+
const claimCashbackBonusMutation = useClaimCashbackBonusMutation({
|
|
72
|
+
onSuccess() {
|
|
73
|
+
toaster.success({
|
|
74
|
+
description: 'Bonus claimed successfully!',
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
onError(error) {
|
|
78
|
+
toaster.error({
|
|
79
|
+
description: error.message,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
const balance = parseDecimal(bonus.balance, 0);
|
|
84
|
+
const total = parseDecimal(bonus.total, 0);
|
|
85
|
+
const minimumCashback = parseDecimal(props.data.cashback.minimumCashback, 0);
|
|
86
|
+
const maximumMonthlyCashback = parseDecimal(props.data.cashback.maximumMonthlyCashback, 0);
|
|
87
|
+
const disabled = balance <= 0 || total > maximumMonthlyCashback || balance < minimumCashback;
|
|
71
88
|
return (_jsxs("div", { className: "border-border-primary bg-bg-tertiary flex flex-col overflow-hidden rounded-2xl border", children: [cashback.banner?.url ? (_jsx(Image, { src: cashback.banner.url, alt: "", width: 400, height: 200, className: "h-[11.25rem] w-full object-cover" })) : (_jsx("div", { style: {
|
|
72
89
|
background: 'radial-gradient(75.21% 75.21% at 50% 50%, rgba(249, 163, 8, 0.3) 0%, rgba(0, 0, 0, 0) 100%), var(--color-bg-primary-alt)',
|
|
73
90
|
}, children: _jsx(Image, { src: moneyOnHand, alt: "", className: "mx-auto h-[11.25rem] w-auto shrink-0 object-cover", draggable: false, width: 600, height: 600 }) })), _jsxs("div", { className: "flex grow flex-col px-xl py-3xl", children: [_jsx("p", { className: "line-clamp-1 text-center text-xl font-semibold text-white", children: cashback.name }), _jsx("h2", { className: "mt-2 text-center text-3xl font-semibold text-white", children: formatNumber(bonus.balance, {
|
|
74
91
|
currency: localeInfo.currency.code,
|
|
75
92
|
}) }), _jsx("div", { className: "text-text-secondary-700 mt-2 line-clamp-1 text-center text-sm", dangerouslySetInnerHTML: {
|
|
76
93
|
__html: cashback.description,
|
|
77
|
-
} }), _jsx("div", { className: "grow" }), _jsx(Button, { size: "sm", className: "mt-6", disabled: claimCashbackBonusMutation.isPending, onClick: () => {
|
|
94
|
+
} }), _jsx("div", { className: "grow" }), _jsx(Button, { size: "sm", className: "mt-6", disabled: claimCashbackBonusMutation.isPending || disabled, onClick: () => {
|
|
78
95
|
claimCashbackBonusMutation.mutate(bonus.id);
|
|
79
|
-
},
|
|
96
|
+
}, title: disabled
|
|
97
|
+
? `You need ${formatNumber(minimumCashback - balance)} to claim this cashback.`
|
|
98
|
+
: undefined, children: "Claim" })] })] }));
|
|
80
99
|
}
|
|
81
100
|
function SpotBonus() {
|
|
82
101
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
@@ -46,7 +46,7 @@ export function GamesSearch(props) {
|
|
|
46
46
|
}, className: "block w-full shadow-sm", children: [_jsx(Image, { src: getGameImageUrl({
|
|
47
47
|
reference: game.reference,
|
|
48
48
|
provider: game.provider,
|
|
49
|
-
}), alt: "", width: 200, height: 200,
|
|
49
|
+
}), alt: "", width: 200, height: 200, loading: "lazy", unoptimized: true, className: "aspect-square w-full rounded-t-md object-cover" }), _jsx("span", { className: "bg-bg-tertiary text-text-primary-brand block w-full truncate rounded-b-md px-2 py-2.5 text-center text-xs font-semibold", children: game.name })] }, game.id))) })) }), _jsx(Presence, { present: gamesQuery.hasNextPage, children: _jsx(Button, { variant: "outline", className: "mx-auto mt-4xl w-fit", onClick: () => gamesQuery.fetchNextPage(), children: "Load More" }) })] }))] })) })) }) })] }) }));
|
|
50
50
|
}
|
|
51
51
|
function Alert({ message }) {
|
|
52
52
|
return (_jsxs("div", { className: "py-lg", role: "alert", "aria-live": "polite", children: [_jsx("div", { className: "bg-bg-secondary shadow-xs border-border-primary mx-auto flex size-12 items-center justify-center rounded-lg border", children: _jsx(SearchLgIcon, { className: "text-text-secondary-700 size-6" }) }), _jsx("p", { className: "text-text-secondary-700 mt-4 text-center", children: message })] }));
|
|
@@ -41,7 +41,7 @@ export function NewsFeedCarousel(props) {
|
|
|
41
41
|
onSelect(emblaApi);
|
|
42
42
|
emblaApi.on('reInit', onSelect).on('select', onSelect);
|
|
43
43
|
}, [emblaApi, onSelect]);
|
|
44
|
-
return (_jsxs("div", { style: props.style, className: props.className, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("h2", { className: "text-lg font-semibold", children: heading }), _jsx("div", { className: "grow" }), _jsxs("div", { className: "flex items-center justify-center gap-xl", children: [_jsxs(Link, { href: viewAllUrl, className: "text-button-tertiary-fg flex gap-sm text-sm font-semibold", children: ["See All", _jsx(ChevronRightIcon, { className: "size-5 lg:hidden" })] }), _jsxs("div", { className: "hidden lg:flex", children: [_jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-r-none border-r-0", onClick: onPrevButtonClick, disabled: prevBtnDisabled, "aria-label": "Previous", children: _jsx(ArrowLeftIcon, { className: "size-5" }) }), _jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-l-none", onClick: onNextButtonClick, disabled: nextBtnDisabled, "aria-label": "Next", children: _jsx(ArrowRightIcon, { className: "size-5" }) })] })] })] }), empty && (_jsx(Empty, { icon: Tv03Icon, title: "No News", message: "No news is currently available.", className: "mt-8" })), !empty && (_jsx(_Fragment, { children: _jsx("div", { ref: emblaRef, className: "relative mt-lg lg:overflow-hidden", children: _jsx("div", { className: twMerge('grid auto-cols-[100%] grid-flow-col gap-1.5 lg:auto-cols-[calc((100%-(1.25rem*2))/3)] lg:gap-2xl'), children: props.newsFeed.map((news) => (_jsxs("div", { className: "bg-bg-primary-alt border-border-primary flex flex-col overflow-hidden rounded-2xl border shadow-md", children: [_jsx(Image, { src: news.image, alt: "", width: 400, height: 274, className: "block h-[15.25rem] w-full object-cover" }), _jsxs("div", { className: "flex grow flex-col p-3xl", children: [_jsxs("div", { className: "grow", children: [_jsx("p", { className: "text-brand-400 text-sm font-semibold", children: news.category }), _jsx("h2", { className: "mt-2 line-clamp-1 text-lg font-semibold", children: news.title }), _jsx("p", { className: "text-text-tertiary-600 mt-xs line-clamp-3", dangerouslySetInnerHTML: {
|
|
44
|
+
return (_jsxs("div", { style: props.style, className: props.className, children: [_jsxs("div", { className: "flex items-center", children: [_jsx("h2", { className: "text-lg font-semibold", children: heading }), _jsx("div", { className: "grow" }), _jsxs("div", { className: "flex items-center justify-center gap-xl", children: [_jsxs(Link, { href: viewAllUrl, className: "text-button-tertiary-fg flex gap-sm text-sm font-semibold", children: ["See All", _jsx(ChevronRightIcon, { className: "size-5 lg:hidden" })] }), _jsxs("div", { className: "hidden lg:flex", children: [_jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-r-none border-r-0", onClick: onPrevButtonClick, disabled: prevBtnDisabled, "aria-label": "Previous", children: _jsx(ArrowLeftIcon, { className: "size-5" }) }), _jsx(Button, { variant: "outline", colorScheme: "gray", className: "rounded-l-none", onClick: onNextButtonClick, disabled: nextBtnDisabled, "aria-label": "Next", children: _jsx(ArrowRightIcon, { className: "size-5" }) })] })] })] }), empty && (_jsx(Empty, { icon: Tv03Icon, title: "No News", message: "No news is currently available.", className: "mt-8" })), !empty && (_jsx(_Fragment, { children: _jsx("div", { ref: emblaRef, className: "relative mt-lg lg:overflow-hidden", children: _jsx("div", { className: twMerge('grid auto-cols-[100%] grid-flow-col gap-1.5 lg:auto-cols-[calc((100%-(1.25rem*2))/3)] lg:gap-2xl'), children: props.newsFeed.map((news) => (_jsxs("div", { className: "bg-bg-primary-alt border-border-primary flex flex-col overflow-hidden rounded-2xl border shadow-md", children: [_jsx(Image, { src: news.image, alt: "", width: 400, height: 274, loading: "lazy", unoptimized: true, className: "block h-[15.25rem] w-full object-cover" }), _jsxs("div", { className: "flex grow flex-col p-3xl", children: [_jsxs("div", { className: "grow", children: [_jsx("p", { className: "text-brand-400 text-sm font-semibold", children: news.category }), _jsx("h2", { className: "mt-2 line-clamp-1 text-lg font-semibold", children: news.title }), _jsx("p", { className: "text-text-tertiary-600 mt-xs line-clamp-3", dangerouslySetInnerHTML: {
|
|
45
45
|
__html: news.content,
|
|
46
46
|
} })] }), _jsx(Button, { asChild: true, className: "mt-2xl", children: _jsx(Link, { href: `${viewDetailsUrl}/${news.id}`, children: "Read More" }) })] })] }, news.id))) }) }) }))] }));
|
|
47
47
|
}
|
|
@@ -11,7 +11,7 @@ export function Cashback({ data, viewDetailsUrl }) {
|
|
|
11
11
|
})));
|
|
12
12
|
const claimablePromos = useAvailablePromosQuery().data ?? [];
|
|
13
13
|
const claimable = claimablePromos.find((availablePromo) => availablePromo.id === data.id);
|
|
14
|
-
return (_jsxs("div", { className: "border-border-secondary bg-accent-50 bg-bg-primary-alt relative flex h-full flex-col overflow-hidden rounded-2xl border", children: [data.banner.url && (_jsx(Image, { src: data.banner.url, alt: data.name, width: 400, height: 202, className: "block aspect-[365/180] w-full object-cover" })), _jsxs("div", { className: "flex flex-grow flex-col px-4 pb-3xl pt-2xl", children: [_jsx("div", { className: "w-full grow text-center text-xl font-semibold", children: data.name }), _jsxs("div", { className: "mt-auto flex flex-col gap-3 pt-4 lg:flex-row", children: [claimable && (_jsx(Button, { size: "sm", onClick: () => {
|
|
14
|
+
return (_jsxs("div", { className: "border-border-secondary bg-accent-50 bg-bg-primary-alt relative flex h-full flex-col overflow-hidden rounded-2xl border", children: [data.banner.url && (_jsx(Image, { src: data.banner.url, alt: data.name, width: 400, height: 202, loading: "lazy", unoptimized: true, className: "block aspect-[365/180] w-full object-cover" })), _jsxs("div", { className: "flex flex-grow flex-col px-4 pb-3xl pt-2xl", children: [_jsx("div", { className: "w-full grow text-center text-xl font-semibold", children: data.name }), _jsxs("div", { className: "mt-auto flex flex-col gap-3 pt-4 lg:flex-row", children: [claimable && (_jsx(Button, { size: "sm", onClick: () => {
|
|
15
15
|
globalStore.depositWithdrawal.setOpen(true);
|
|
16
16
|
globalStore.depositWithdrawal.setPromo(data.id);
|
|
17
17
|
}, children: "Get bonus" })), _jsx(Button, { size: "sm", variant: "outline", asChild: true, children: _jsx(Link, { href: `${viewDetailsUrl}/${data.id}`, children: "Read more" }) })] })] })] }));
|
|
@@ -3,5 +3,5 @@ import Image from 'next/image';
|
|
|
3
3
|
import Link from 'next/link';
|
|
4
4
|
import { Button } from '../../ui/Button/index.js';
|
|
5
5
|
export function CustomPromo({ data, viewDetailsUrl }) {
|
|
6
|
-
return (_jsxs("div", { className: "border-border-secondary bg-accent-50 bg-bg-primary-alt relative flex h-full flex-col overflow-hidden rounded-2xl border", children: [_jsx(Image, { src: data.banner, alt: data.name, width: 400, height: 202, className: "block aspect-[365/180] w-full object-cover" }), _jsxs("div", { className: "flex flex-grow flex-col px-4 pb-3xl pt-2xl", children: [_jsx("div", { className: "w-full grow text-center text-xl font-semibold", children: data.name }), _jsx("div", { className: "mt-auto flex flex-col gap-3 pt-4 lg:flex-row", children: _jsx(Button, { size: "sm", variant: "outline", asChild: true, children: _jsx(Link, { href: `${viewDetailsUrl}/${data.id}`, children: "Read more" }) }) })] })] }));
|
|
6
|
+
return (_jsxs("div", { className: "border-border-secondary bg-accent-50 bg-bg-primary-alt relative flex h-full flex-col overflow-hidden rounded-2xl border", children: [_jsx(Image, { src: data.banner, alt: data.name, width: 400, height: 202, loading: "lazy", unoptimized: true, className: "block aspect-[365/180] w-full object-cover" }), _jsxs("div", { className: "flex flex-grow flex-col px-4 pb-3xl pt-2xl", children: [_jsx("div", { className: "w-full grow text-center text-xl font-semibold", children: data.name }), _jsx("div", { className: "mt-auto flex flex-col gap-3 pt-4 lg:flex-row", children: _jsx(Button, { size: "sm", variant: "outline", asChild: true, children: _jsx(Link, { href: `${viewDetailsUrl}/${data.id}`, children: "Read more" }) }) })] })] }));
|
|
7
7
|
}
|
|
@@ -11,7 +11,7 @@ export function Promo({ data, viewDetailsUrl }) {
|
|
|
11
11
|
})));
|
|
12
12
|
const claimablePromos = useAvailablePromosQuery().data ?? [];
|
|
13
13
|
const claimable = claimablePromos.find((availablePromo) => availablePromo.id === data.id);
|
|
14
|
-
return (_jsxs("div", { className: "border-border-secondary bg-accent-50 bg-bg-primary-alt relative flex h-full flex-col overflow-hidden rounded-2xl border", children: [data.banner.url && (_jsx(Image, { src: data.banner.url, alt: data.name, width: 400, height: 202, className: "block aspect-[365/180] w-full object-cover" })), _jsxs("div", { className: "flex flex-grow flex-col px-4 pb-3xl pt-2xl", children: [_jsx("div", { className: "w-full grow text-center text-xl font-semibold", children: data.name }), _jsxs("div", { className: "mt-auto flex flex-col gap-3 pt-4 lg:flex-row", children: [claimable && (_jsx(Button, { size: "sm", onClick: () => {
|
|
14
|
+
return (_jsxs("div", { className: "border-border-secondary bg-accent-50 bg-bg-primary-alt relative flex h-full flex-col overflow-hidden rounded-2xl border", children: [data.banner.url && (_jsx(Image, { src: data.banner.url, alt: data.name, width: 400, height: 202, loading: "lazy", unoptimized: true, className: "block aspect-[365/180] w-full object-cover" })), _jsxs("div", { className: "flex flex-grow flex-col px-4 pb-3xl pt-2xl", children: [_jsx("div", { className: "w-full grow text-center text-xl font-semibold", children: data.name }), _jsxs("div", { className: "mt-auto flex flex-col gap-3 pt-4 lg:flex-row", children: [claimable && (_jsx(Button, { size: "sm", onClick: () => {
|
|
15
15
|
globalStore.depositWithdrawal.setOpen(true);
|
|
16
16
|
globalStore.depositWithdrawal.setPromo(data.id);
|
|
17
17
|
}, children: "Get bonus" })), _jsx(Button, { size: "sm", variant: "outline", asChild: true, children: _jsx(Link, { href: `${viewDetailsUrl}/${data.id}`, children: "Read more" }) })] })] })] }));
|
|
@@ -78,7 +78,7 @@ export function Search(props) {
|
|
|
78
78
|
}, children: [_jsx(Image, { src: getGameImageUrl({
|
|
79
79
|
reference: game.reference,
|
|
80
80
|
provider: game.provider,
|
|
81
|
-
}), alt: "", width: 200, height: 200,
|
|
81
|
+
}), alt: "", width: 200, height: 200, loading: "lazy", unoptimized: true, className: "aspect-square w-full rounded-t-md object-cover" }), _jsx("span", { className: twMerge('bg-bg-tertiary text-text-primary-brand block w-full truncate rounded-b-md px-2 py-2.5 text-center text-xs font-semibold', classNames.gameThumbnailTitle), children: game.name })] }, game.id))) })] })), _jsx(Presence, { present: gamesQuery.hasNextPage, children: _jsx(Button, { variant: "outline", className: "mx-auto mt-12 w-fit", onClick: () => gamesQuery.fetchNextPage(), children: "Load More" }) })] }))] })) })] }) })] }) }));
|
|
82
82
|
}
|
|
83
83
|
function DebouncedInput(props) {
|
|
84
84
|
const [value, setValue] = useControllableState({
|