@opexa/portal-components 0.0.1091 → 0.0.1093
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,20 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { tz } from '@date-fns/tz';
|
|
4
|
+
import { format } from 'date-fns';
|
|
4
5
|
import { isString } from 'lodash-es';
|
|
5
6
|
import Image from 'next/image';
|
|
6
7
|
import Link from 'next/link';
|
|
7
|
-
import { useMemo } from 'react';
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
9
9
|
import { useShallow } from 'zustand/shallow';
|
|
10
10
|
import { useAvailablePromosQuery } from '../../client/hooks/useAvailablePromosQuery.js';
|
|
11
11
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
12
|
+
import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
|
|
12
13
|
import { usePromoQuery } from '../../client/hooks/usePromoQuery.js';
|
|
13
|
-
import { useRemainingTime } from '../../client/hooks/useRemainingTime.js';
|
|
14
14
|
import { ChevronLeftIcon } from '../../icons/ChevronLeftIcon.js';
|
|
15
15
|
import { Button } from '../../ui/Button/index.js';
|
|
16
16
|
import { Prose } from '../../ui/Prose/index.js';
|
|
17
17
|
export function Promo__client({ useEndOfDay = false, ...props }) {
|
|
18
|
+
const localeInfo = useLocaleInfo();
|
|
18
19
|
const availablePromosQuery = useAvailablePromosQuery();
|
|
19
20
|
const availablePromos = availablePromosQuery.data ?? [];
|
|
20
21
|
const promoQuery = usePromoQuery(props.id);
|
|
@@ -23,20 +24,6 @@ export function Promo__client({ useEndOfDay = false, ...props }) {
|
|
|
23
24
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
24
25
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
25
26
|
})));
|
|
26
|
-
const targetDateTime = useMemo(() => {
|
|
27
|
-
if (promo?.daysToClear) {
|
|
28
|
-
const date = new Date(promo.dateTimeCreated);
|
|
29
|
-
date.setDate(date.getDate() + Number(promo.daysToClear));
|
|
30
|
-
return useEndOfDay ? endOfDay(date) : date;
|
|
31
|
-
}
|
|
32
|
-
return new Date(promo?.activationEndDateTime ?? 0);
|
|
33
|
-
}, [
|
|
34
|
-
promo?.dateTimeCreated,
|
|
35
|
-
promo?.daysToClear,
|
|
36
|
-
promo?.activationEndDateTime,
|
|
37
|
-
useEndOfDay,
|
|
38
|
-
]);
|
|
39
|
-
const remainingTime = useRemainingTime(targetDateTime);
|
|
40
27
|
if (!promo)
|
|
41
28
|
return null;
|
|
42
29
|
const classNames = isString(props.className)
|
|
@@ -61,5 +48,7 @@ export function Promo__client({ useEndOfDay = false, ...props }) {
|
|
|
61
48
|
return (_jsxs("div", { className: classNames.root, children: [_jsxs(Link, { href: props.viewAllPromosUrl ?? '/promos', className: "flex w-fit items-center gap-lg font-semibold text-button-tertiary-fg text-lg", children: [_jsx(ChevronLeftIcon, { className: "size-6" }), "Back to all Promotions"] }), promo.banner.url && (_jsx(Image, { src: promo.banner.url, alt: "", width: 1024, height: 600, priority: true, unoptimized: true, className: "mt-xl h-auto w-full rounded-xl lg:mt-6" })), claimable && (_jsx(Button, { className: "mt-xl lg:mt-6", onClick: () => {
|
|
62
49
|
globalStore.depositWithdrawal.setOpen(true);
|
|
63
50
|
globalStore.depositWithdrawal.setPromo(promo.id);
|
|
64
|
-
}, children: "Deposit Now" })), _jsx("h1", { className: "mt-xl font-semibold text-2xl lg:mt-6 lg:text-3xl", children: promo.name }), _jsxs("p", { className: "mt-xl text-text-secondary-700 lg:mt-6", children: ["Ends
|
|
51
|
+
}, children: "Deposit Now" })), _jsx("h1", { className: "mt-xl font-semibold text-2xl lg:mt-6 lg:text-3xl", children: promo.name }), _jsxs("p", { className: "mt-xl text-text-secondary-700 lg:mt-6", children: ["Ends", ' ', format(promo.activationEndDateTime, 'MM/dd/yyy hh:mm:ss', {
|
|
52
|
+
in: tz(localeInfo.timezone),
|
|
53
|
+
})] }), _jsx(Prose, { className: twMerge('mt-2xl lg:mt-6', classNames.promoDescription), dangerouslySetInnerHTML: { __html: descriptionHtml } })] }));
|
|
65
54
|
}
|
|
@@ -8,18 +8,14 @@ import { useQuestContext } from './QuestsContext.js';
|
|
|
8
8
|
export function RemainingTime({ endOfDay: useEndOfDay = false, className, }) {
|
|
9
9
|
const quest = useQuestContext();
|
|
10
10
|
const targetDateTime = useMemo(() => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const daysToClear = Number(quest.daysToClear);
|
|
12
|
+
if (Number.isInteger(daysToClear) && daysToClear > 0) {
|
|
13
|
+
const now = new Date();
|
|
14
|
+
now.setDate(now.getDate() + daysToClear);
|
|
15
|
+
return useEndOfDay ? endOfDay(now) : now;
|
|
15
16
|
}
|
|
16
|
-
return
|
|
17
|
-
}, [
|
|
18
|
-
quest.dateTimeCreated,
|
|
19
|
-
quest.daysToClear,
|
|
20
|
-
quest.endDateTime,
|
|
21
|
-
useEndOfDay,
|
|
22
|
-
]);
|
|
17
|
+
return 0;
|
|
18
|
+
}, [quest.daysToClear, useEndOfDay]);
|
|
23
19
|
const remainingTime = useRemainingTime(targetDateTime);
|
|
24
20
|
if (quest.status === 'COMPLETED') {
|
|
25
21
|
return (_jsx(Badge.Root, { size: "lg", colorScheme: "success", round: false, className: className?.completedBadgeRoot, children: _jsx(Badge.Label, { className: className?.completedBadgeLabel, children: "Completed" }) }));
|