@opexa/portal-components 0.0.329 → 0.0.331
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/components/Bonus/Bonus.client.d.ts +1 -1
- package/dist/components/Bonus/Bonus.client.js +22 -21
- package/dist/components/Bonuses/Bonuses.client.js +5 -1
- package/dist/components/Jackpots/JackpotsList/JackpotsList.d.ts +1 -1
- package/dist/components/Jackpots/JackpotsList/JackpotsList.js +1 -3
- package/dist/handlers/postAuthenticate.js +1 -3
- package/dist/handlers/postSession.js +1 -4
- package/dist/services/auth.js +2 -1
- package/dist/services/httpRequest.js +6 -4
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { clamp } from
|
|
4
|
-
import Image from
|
|
5
|
-
import Link from
|
|
6
|
-
import { useBonusQuery } from
|
|
7
|
-
import { useLocaleInfo } from
|
|
8
|
-
import { useRemainingTime } from
|
|
9
|
-
import { ChevronLeftIcon } from
|
|
10
|
-
import { ChevronRightIcon } from
|
|
11
|
-
import { StopWatchIcon } from
|
|
12
|
-
import piggyBank from
|
|
13
|
-
import { Badge } from
|
|
14
|
-
import { Collapsible } from
|
|
15
|
-
import { Progress } from
|
|
16
|
-
import { Prose } from
|
|
17
|
-
import { capitalize } from
|
|
18
|
-
import { formatNumber } from
|
|
19
|
-
import { parseDecimal } from
|
|
3
|
+
import { clamp } from 'lodash-es';
|
|
4
|
+
import Image from 'next/image';
|
|
5
|
+
import Link from 'next/link';
|
|
6
|
+
import { useBonusQuery } from '../../client/hooks/useBonusQuery.js';
|
|
7
|
+
import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
|
|
8
|
+
import { useRemainingTime } from '../../client/hooks/useRemainingTime.js';
|
|
9
|
+
import { ChevronLeftIcon } from '../../icons/ChevronLeftIcon.js';
|
|
10
|
+
import { ChevronRightIcon } from '../../icons/ChevronRightIcon.js';
|
|
11
|
+
import { StopWatchIcon } from '../../icons/StopWatchIcon.js';
|
|
12
|
+
import piggyBank from '../../images/piggy-bank.png';
|
|
13
|
+
import { Badge } from '../../ui/Badge/index.js';
|
|
14
|
+
import { Collapsible } from '../../ui/Collapsible/index.js';
|
|
15
|
+
import { Progress } from '../../ui/Progress/index.js';
|
|
16
|
+
import { Prose } from '../../ui/Prose/index.js';
|
|
17
|
+
import { capitalize } from '../../utils/capitalize.js';
|
|
18
|
+
import { formatNumber } from '../../utils/formatNumber.js';
|
|
19
|
+
import { parseDecimal } from '../../utils/parseDecimal.js';
|
|
20
20
|
export function Bonus__client(props) {
|
|
21
21
|
const bonusQuery = useBonusQuery(props.id);
|
|
22
22
|
const bonus = bonusQuery.data;
|
|
@@ -28,9 +28,10 @@ export function Bonus__client(props) {
|
|
|
28
28
|
return null;
|
|
29
29
|
const turnoverRequirement = parseDecimal(bonus.turnoverRequirement, 0);
|
|
30
30
|
const currentTurnoverRequirementContribution = parseDecimal(bonus.currentTurnoverRequirementContribution, 0);
|
|
31
|
-
return (_jsxs("div", { className: props.className, children: [_jsxs(Link, { href: props.viewAllUrl ??
|
|
31
|
+
return (_jsxs("div", { className: props.className, children: [_jsxs(Link, { href: props.viewAllUrl ?? '/rewards', className: "flex items-center gap-lg font-semibold text-button-tertiary-fg text-lg", children: [_jsx(ChevronLeftIcon, { className: "size-6" }), "Back to all Rewards"] }), _jsx("div", { className: "mt-3xl", children: bonus.promo.banner?.url ? (_jsx(Image, { src: bonus.promo.banner.url, alt: "", width: 1024, height: 600, unoptimized: true, priority: true, className: "h-auto w-full rounded-xl" })) : (_jsx(DefaultImage, {})) }), _jsxs(Badge.Root, { size: "lg", round: false, colorScheme: remainingTime.expired ? 'danger' : 'brand-dark', className: "mt-xl lg:mt-6", children: [_jsx(Badge.Icon, { children: _jsx(StopWatchIcon, {}) }), _jsx(Badge.Label, { children: remainingTime.expired ? 'Expired' : remainingTime.toString() })] }), _jsx("h1", { className: "mt-xl font-semibold text-2xl text-text-primary-900 lg:mt-6 lg:text-3xl", children: bonus.promo.name }), _jsx("p", { className: "mt-xl text-base text-text-primary-brand lg:mt-6 lg:text-lg", children: "Complete the wagering before time runs out to convert your bonus balance into real money!" }), _jsxs("div", { className: "mt-xl flex items-center justify-between rounded-md border border-border-primary bg-bg-tertiary px-3.5 py-xl text-text-secondary-700 lg:mt-6", children: [_jsx("p", { children: "Your bonus balance" }), _jsx("p", { children: _jsx("span", { className: "text-text-primary-900", children: formatNumber(bonus.balance, {
|
|
32
32
|
currency: localeInfo.currency.code,
|
|
33
|
-
|
|
33
|
+
minDecimalPlaces: 2,
|
|
34
|
+
}) }) })] }), _jsxs("div", { className: "mt-xl rounded-md border border-border-primary bg-bg-tertiary px-3.5 py-xl text-text-secondary-700 lg:mt-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: ["Wagering", !Number.isNaN(Number(bonus.currentTurnoverRequirementContributionPercentage)) && _jsxs("p", { children: [bonus.currentTurnoverRequirementContributionPercentage, "%"] }), _jsxs("p", { children: [currentTurnoverRequirementContribution, "/", turnoverRequirement] })] }), _jsx(Progress.Root, { className: "mt-2", min: 0, max: turnoverRequirement, value: clamp(currentTurnoverRequirementContribution, 0, turnoverRequirement), children: _jsx(Progress.Track, { children: _jsx(Progress.Range, {}) }) })] }), _jsxs(Collapsible.Root, { className: "mt-xl lg:mt-6", children: [_jsxs(Collapsible.Trigger, { className: 'flex w-full items-center justify-center gap-sm font-semibold text-button-tertiary-fg text-sm sm:justify-start', children: ["Game Provider Contribution", _jsx(Collapsible.Indicator, { asChild: true, children: _jsx(ChevronRightIcon, { className: "size-5" }) })] }), _jsx(Collapsible.Content, { className: "mt-xl space-y-1.5 rounded-md border border-border-primary bg-bg-tertiary px-3.5 py-xl text-text-secondary-700 lg:mt-6", children: Object.entries(bonus.promo
|
|
34
35
|
.turnoverRequirementContributionPercentagePerGameProvider ?? {})
|
|
35
36
|
.filter(([provider]) => gameProviders.includes(provider))
|
|
36
37
|
.map(([provider, valueAsString]) => {
|
|
@@ -45,6 +46,6 @@ export function Bonus__client(props) {
|
|
|
45
46
|
}
|
|
46
47
|
function DefaultImage() {
|
|
47
48
|
return (_jsx("div", { style: {
|
|
48
|
-
background:
|
|
49
|
+
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)',
|
|
49
50
|
}, className: "overflow-hidden rounded-xl", children: _jsx(Image, { src: piggyBank, alt: "", className: "mx-auto h-auto w-[50%] shrink-0 rounded-xl", draggable: false, width: 1024, height: 1024, priority: true }) }));
|
|
50
51
|
}
|
|
@@ -65,7 +65,7 @@ export function Bonuses__client(props) {
|
|
|
65
65
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: props.className, children: [_jsx("h2", { className: "font-semibold text-lg", children: props.heading ?? 'Rewards' }), _jsxs(SegmentGroup.Root, { value: tab, onValueChange: (details) => {
|
|
66
66
|
setTab(TabSchema.parse(details.value));
|
|
67
67
|
}, className: "mt-3", children: [_jsxs(SegmentGroup.Item, { value: "all", children: [_jsx(SegmentGroup.ItemText, { children: "All" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "active", children: [_jsx(SegmentGroup.ItemText, { children: "Active" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "cashbacks", children: [_jsx(SegmentGroup.ItemText, { children: "Cashbacks" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsx(SegmentGroup.Indicator, {})] }), _jsxs("div", { className: "mt-3xl grid gap-3xl lg:mt-lg lg:grid-cols-3", children: [tab === 'all' && _jsx(SpotBonus, {}), tab !== 'cashbacks' &&
|
|
68
|
-
bonuses.map((bonus) => (_jsx(Bonus, { data: bonus, viewDetailsUrl: props.viewBonusDetailsUrl ?? '/rewards' }, bonus.id))), cashbackBonuses.map((cashbackBonus) => (_jsx(CashbackBonus, { data: cashbackBonus }, cashbackBonus.id)))] })] }), _jsx(ClaimSpotBonus, {})] }));
|
|
68
|
+
bonuses.map((bonus) => (_jsx(Bonus, { data: bonus, viewDetailsUrl: props.viewBonusDetailsUrl ?? '/rewards' }, bonus.id))), cashbackBonuses.map((cashbackBonus) => (_jsx(CashbackBonus, { data: cashbackBonus }, cashbackBonus.id))), tab === 'active' && bonuses.length === 0 && (_jsx(BonusesEmptyState, { heading: "Active" })), tab === 'cashbacks' && cashbackBonuses.length === 0 && (_jsx(BonusesEmptyState, { heading: "Cashbacks" }))] })] }), _jsx(ClaimSpotBonus, {})] }));
|
|
69
69
|
}
|
|
70
70
|
function Bonus(props) {
|
|
71
71
|
const bonus = props.data;
|
|
@@ -78,6 +78,7 @@ function Bonus(props) {
|
|
|
78
78
|
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)',
|
|
79
79
|
}, children: _jsx(Image, { src: piggyBank, alt: "", className: "mx-auto h-[11.25rem] w-auto shrink-0 object-cover", draggable: false, width: 600, height: 600 }) })), _jsxs(Badge.Root, { size: "lg", round: false, colorScheme: remainingTime.expired ? 'danger' : 'brand-dark', className: "absolute top-4 right-4", children: [_jsx(Badge.Icon, { children: _jsx(StopWatchIcon, {}) }), _jsx(Badge.Label, { children: remainingTime.expired ? 'Expired' : remainingTime.toString() })] })] }), _jsxs("div", { className: "flex grow flex-col px-xl py-3xl", children: [_jsx("h2", { className: "line-clamp-1 text-center font-semibold text-white text-xl", children: promo.name }), _jsx("div", { className: "mt-2 flex items-baseline justify-center gap-2", children: _jsx("p", { className: "font-semibold text-3xl leading-none", children: formatNumber(bonus.balance, {
|
|
80
80
|
currency: localeInfo.currency.code,
|
|
81
|
+
minDecimalPlaces: 2,
|
|
81
82
|
}) }) }), _jsxs("div", { className: "mt-md flex justify-between text-text-primary-brand", children: [_jsxs("p", { children: ["Wagering ", currentTurnoverRequirementContributionPercentage, "%"] }), _jsxs("p", { children: [bonus.currentTurnoverRequirementContribution, "/", turnoverRequirement] })] }), _jsx(Progress.Root, { min: 0, max: 100, value: clamp(currentTurnoverRequirementContributionPercentage, 0, 100), className: "mt-2", children: _jsx(Progress.Track, { children: _jsx(Progress.Range, {}) }) }), _jsx("div", { className: "grow" }), _jsx(Button, { size: "sm", variant: "outline", className: "mt-6", asChild: true, children: _jsx(Link, { href: `${props.viewDetailsUrl}/${bonus.id}`, children: "See More" }) })] })] }));
|
|
82
83
|
}
|
|
83
84
|
function CashbackBonus(props) {
|
|
@@ -135,3 +136,6 @@ function SpotBonus() {
|
|
|
135
136
|
globalStore.spotBonus.setOpen(true);
|
|
136
137
|
}, className: "mt-6", children: "Enter Promo Code" })] })] }));
|
|
137
138
|
}
|
|
139
|
+
function BonusesEmptyState({ heading }) {
|
|
140
|
+
return (_jsxs("div", { className: "col-span-full mt-11 flex w-full flex-col items-center justify-center lg:col-span-3", children: [_jsx(Image, { width: 151, height: 107, src: moneyOnHand, alt: "Money on hand", className: "size-full h-auto w-[151px] mix-blend-luminosity " }), _jsxs("div", { className: "mt-4 font-semibold text-base text-text-primary-900", children: ["No ", heading, " Rewards"] }), _jsxs("div", { className: "mt-1 text-center text-sm text-text-tertiary-600", children: ["No ", heading, " Rewards are running at the moment. ", _jsx("br", {}), "Please check back later!"] })] }));
|
|
141
|
+
}
|
|
@@ -32,5 +32,5 @@ export interface JackpotsListProps {
|
|
|
32
32
|
viewGamesUrl?: string | ((gameProvider: GameProviderData) => string);
|
|
33
33
|
animate?: boolean;
|
|
34
34
|
}
|
|
35
|
-
export declare function JackpotsList(props: JackpotsListProps): import("react/jsx-runtime").JSX.Element
|
|
35
|
+
export declare function JackpotsList(props: JackpotsListProps): import("react/jsx-runtime").JSX.Element;
|
|
36
36
|
export {};
|
|
@@ -25,13 +25,11 @@ export function JackpotsList(props) {
|
|
|
25
25
|
},
|
|
26
26
|
});
|
|
27
27
|
const jackpots = jackpotsQuery.data?.pages[0].edges.map((edge) => edge.node) ?? [];
|
|
28
|
-
if (jackpots.length <= 0)
|
|
29
|
-
return null;
|
|
30
28
|
const styles = isStyleEntries(props.style, ['root', 'itemRoot'])
|
|
31
29
|
? props.style
|
|
32
30
|
: { root: props.style };
|
|
33
31
|
const classNames = isString(props.className)
|
|
34
32
|
? { root: props.className }
|
|
35
33
|
: (props.className ?? {});
|
|
36
|
-
return (_jsx(JackpotsListPropsContext, { value: props, children: _jsxs("div", { style: styles.root, className: classNames.root, children: [_jsx("div", { className: "mb-3 font-semibold text-lg lg:mb-4.5", children: props.heading ?? 'Jackpots' }), jackpots.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "hidden flex-col gap-6 lg:flex", children: jackpots.map((jackpot) => (_jsx(JackpotsListItemContext, { value: jackpot, children: _jsx(JackpotsListItemDesktop, { style: styles.itemRoot, className: classNames.itemRoot, animate: props.animate }) }, jackpot.id))) }), _jsx("div", { className: "flex flex-col gap-6 lg:hidden", children: jackpots.map((jackpot) => (_jsx(JackpotsListItemContext, { value: jackpot, children: _jsx(JackpotsListItemMobile, { style: styles.itemRoot, className: classNames.itemRoot, animate: props.animate }) }, jackpot.id))) })] })) : (_jsxs("div", { className:
|
|
34
|
+
return (_jsx(JackpotsListPropsContext, { value: props, children: _jsxs("div", { style: styles.root, className: classNames.root, children: [_jsx("div", { className: "mb-3 font-semibold text-lg lg:mb-4.5", children: props.heading ?? 'Jackpots' }), jackpots.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "hidden flex-col gap-6 lg:flex", children: jackpots.map((jackpot) => (_jsx(JackpotsListItemContext, { value: jackpot, children: _jsx(JackpotsListItemDesktop, { style: styles.itemRoot, className: classNames.itemRoot, animate: props.animate }) }, jackpot.id))) }), _jsx("div", { className: "flex flex-col gap-6 lg:hidden", children: jackpots.map((jackpot) => (_jsx(JackpotsListItemContext, { value: jackpot, children: _jsx(JackpotsListItemMobile, { style: styles.itemRoot, className: classNames.itemRoot, animate: props.animate }) }, jackpot.id))) })] })) : (_jsxs("div", { className: 'mt-5 flex h-fit flex-col items-center justify-center lg:mt-0 lg:h-62', children: [_jsx(Image, { width: 100, height: 100, src: closeChest, alt: "closeChest", className: "size-full h-29.5 w-29.5 mix-blend-luminosity lg:h-25 lg:w-25" }), _jsxs("div", { className: "mt-4 font-semibold text-base text-text-primary-900", children: ["No ", props.heading ?? 'Jackpots'] }), _jsxs("div", { className: "mt-1 text-center text-sm text-text-tertiary-600", children: ["No ", props.heading?.toLocaleLowerCase() ?? 'jackpots', " are running at the moment. ", _jsx("br", {}), "Please check back later!"] })] }))] }) }));
|
|
37
35
|
}
|
|
@@ -13,10 +13,8 @@ export async function postAuthenticate(request) {
|
|
|
13
13
|
const parsed = AuthenticateDefinition.safeParse(body);
|
|
14
14
|
const userAgent = request.headers.get('user-agent');
|
|
15
15
|
const forwarded = request.headers.get('x-forwarded-for');
|
|
16
|
-
const
|
|
17
|
-
const ipaddress = forwarded || realIp || 'unknown';
|
|
16
|
+
const ipaddress = forwarded?.split(',')[0];
|
|
18
17
|
console.log(forwarded, 'forwarded');
|
|
19
|
-
console.log(realIp, 'realIp');
|
|
20
18
|
if (!parsed.success) {
|
|
21
19
|
return NextResponse.json({
|
|
22
20
|
ok: false,
|
|
@@ -32,10 +32,7 @@ export async function postSession(request) {
|
|
|
32
32
|
const parsed = CreateSessionDefinition.safeParse(body);
|
|
33
33
|
const userAgent = request.headers.get('user-agent');
|
|
34
34
|
const forwarded = request.headers.get('x-forwarded-for');
|
|
35
|
-
const
|
|
36
|
-
const ipaddress = forwarded || realIp || 'unknown';
|
|
37
|
-
console.log(forwarded, 'forwarded');
|
|
38
|
-
console.log(realIp, 'realIp');
|
|
35
|
+
const ipaddress = forwarded?.split(',')[0];
|
|
39
36
|
if (!parsed.success) {
|
|
40
37
|
return NextResponse.json({
|
|
41
38
|
ok: false,
|
package/dist/services/auth.js
CHANGED
|
@@ -25,8 +25,8 @@ export async function createSession(input, options) {
|
|
|
25
25
|
new Headers(options?.headers).forEach((value, key) => {
|
|
26
26
|
headers.set(key, value);
|
|
27
27
|
});
|
|
28
|
-
console.log('post session headers', headers);
|
|
29
28
|
try {
|
|
29
|
+
console.log('post session headers', headers);
|
|
30
30
|
return await httpRequest.json(`${AUTH_ENDPOINT}/sessions`, {
|
|
31
31
|
...options,
|
|
32
32
|
method: 'POST',
|
|
@@ -34,6 +34,7 @@ export async function createSession(input, options) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
catch (e) {
|
|
37
|
+
console.log('Error creating session:', e);
|
|
37
38
|
if (e instanceof Error) {
|
|
38
39
|
throw e;
|
|
39
40
|
}
|
|
@@ -10,10 +10,6 @@ export async function httpRequest(url, opts = {}) {
|
|
|
10
10
|
new Headers(opts.headers).forEach((value, key) => {
|
|
11
11
|
headers.set(key, value);
|
|
12
12
|
});
|
|
13
|
-
console.log('https');
|
|
14
|
-
console.log('HTTP URL:', url);
|
|
15
|
-
console.dir({ headers }, { depth: null });
|
|
16
|
-
console.log('option headers', opts.headers);
|
|
17
13
|
const res = await fetch(url, {
|
|
18
14
|
...opts,
|
|
19
15
|
headers,
|
|
@@ -47,6 +43,12 @@ httpRequest.json = async (url, opts = {}) => {
|
|
|
47
43
|
new Headers(opts.headers).forEach((value, key) => {
|
|
48
44
|
headers.set(key, value);
|
|
49
45
|
});
|
|
46
|
+
if (opts.method === 'POST') {
|
|
47
|
+
console.log('Method:', opts.method);
|
|
48
|
+
console.log('HTTP URL:', url);
|
|
49
|
+
console.log('UPDATED HEADERS', headers);
|
|
50
|
+
console.log('HTTP REQUEST HEADERS', opts.headers);
|
|
51
|
+
}
|
|
50
52
|
const response = await fetch(url, {
|
|
51
53
|
...opts,
|
|
52
54
|
headers,
|