@opexa/portal-components 0.0.1088 → 0.0.1089

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.
@@ -14,5 +14,6 @@ export interface PromoProps {
14
14
  flags?: string;
15
15
  }[];
16
16
  };
17
+ useEndOfDay?: boolean;
17
18
  }
18
- export declare function Promo__client(props: PromoProps): import("react/jsx-runtime").JSX.Element | null;
19
+ export declare function Promo__client({ useEndOfDay, ...props }: PromoProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,21 +1,20 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { tz } from '@date-fns/tz';
4
- import { format } from 'date-fns';
3
+ import { endOfDay } from 'date-fns';
5
4
  import { isString } from 'lodash-es';
6
5
  import Image from 'next/image';
7
6
  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';
13
12
  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
- export function Promo__client(props) {
18
- const localeInfo = useLocaleInfo();
17
+ export function Promo__client({ useEndOfDay = false, ...props }) {
19
18
  const availablePromosQuery = useAvailablePromosQuery();
20
19
  const availablePromos = availablePromosQuery.data ?? [];
21
20
  const promoQuery = usePromoQuery(props.id);
@@ -24,6 +23,20 @@ export function Promo__client(props) {
24
23
  const globalStore = useGlobalStore(useShallow((ctx) => ({
25
24
  depositWithdrawal: ctx.depositWithdrawal,
26
25
  })));
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);
27
40
  if (!promo)
28
41
  return null;
29
42
  const classNames = isString(props.className)
@@ -48,7 +61,5 @@ export function Promo__client(props) {
48
61
  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: () => {
49
62
  globalStore.depositWithdrawal.setOpen(true);
50
63
  globalStore.depositWithdrawal.setPromo(promo.id);
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.daysToClear, '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 } })] }));
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 ", remainingTime.toString()] }), _jsx(Prose, { className: twMerge('mt-2xl lg:mt-6', classNames.promoDescription), dangerouslySetInnerHTML: { __html: descriptionHtml } })] }));
54
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.1088",
3
+ "version": "0.0.1089",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",