@opexa/portal-components 0.0.1073 → 0.0.1075

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.
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { clamp } from 'lodash-es';
4
4
  import Image from 'next/image';
5
5
  import Link from 'next/link';
6
+ import { useMemo } from 'react';
6
7
  import { useBonusQuery } from '../../client/hooks/useBonusQuery.js';
7
8
  import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
8
9
  import { useRemainingTime } from '../../client/hooks/useRemainingTime.js';
@@ -23,7 +24,14 @@ export function Bonus__client(props) {
23
24
  const gameProviders = props.gameProviders ?? [];
24
25
  const enabledGameProviders = bonus?.enabledGameProviders ?? [];
25
26
  const localeInfo = useLocaleInfo();
26
- const remainingTime = useRemainingTime(bonus?.expiration ?? new Date());
27
+ const targetDate = useMemo(() => {
28
+ if (!bonus)
29
+ return new Date();
30
+ const date = new Date(bonus.dateTimeLastUpdated);
31
+ date.setDate(date.getDate() + bonus.promo.daysToClear);
32
+ return date;
33
+ }, [bonus]);
34
+ const remainingTime = useRemainingTime(targetDate);
27
35
  if (!bonus)
28
36
  return null;
29
37
  const turnoverRequirement = parseDecimal(bonus.turnoverRequirement, 0);
@@ -31,9 +39,10 @@ export function Bonus__client(props) {
31
39
  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
40
  currency: localeInfo.currency.code,
33
41
  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
42
+ }) }) })] }), _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
35
43
  .turnoverRequirementContributionPercentagePerGameProvider ?? {})
36
- .filter(([provider, valueAsString]) => gameProviders.includes(provider) && valueAsString !== "0")
44
+ .filter(([provider, valueAsString]) => gameProviders.includes(provider) &&
45
+ valueAsString !== '0')
37
46
  .map(([provider, valueAsString]) => {
38
47
  const value = parseDecimal(valueAsString, 0);
39
48
  return (_jsxs("div", { className: "flex items-center justify-between gap-md", children: [_jsx("p", { className: "w-[11.25rem] shrink-0", children: capitalize(provider, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.1073",
3
+ "version": "0.0.1075",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",