@opexa/portal-components 0.0.1094 → 0.0.1095

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,5 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { endOfDay as getEndOfDay } from 'date-fns';
3
2
  import { isString } from 'lodash-es';
4
3
  import dynamic from 'next/dynamic';
5
4
  import Link from 'next/link';
@@ -87,7 +86,7 @@ export function JourneyQuest(props) {
87
86
  disclosure.setOpen(true);
88
87
  }, [disclosure]);
89
88
  const localeInfo = useLocaleInfo();
90
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: twMerge('flex h-full w-full flex-col space-y-6 rounded-2xl border border-border-primary bg-bg-tertiary px-4 pt-5 pb-6', classNames?.root), children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-center justify-between", children: [_jsx(RemainingTime, { endOfDay: true, className: {
89
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: twMerge('flex h-full w-full flex-col space-y-6 rounded-2xl border border-border-primary bg-bg-tertiary px-4 pt-5 pb-6', classNames?.root), children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-center justify-between", children: [_jsx(RemainingTime, { className: {
91
90
  timeBadgeRoot: classNames?.timeBadgeRoot,
92
91
  timeBadgeIcon: classNames?.timeBadgeIcon,
93
92
  timeBadgeLabel: classNames?.timeBadgeLabel,
@@ -135,14 +134,7 @@ function Rules(props) {
135
134
  return milestones.every((milestone) => milestone.isCompleted);
136
135
  }, [milestones]);
137
136
  //prevent members to perform actions after the quest has expired
138
- const targetDateTime = useMemo(() => {
139
- if (!quest?.dateTimeCreated)
140
- return null;
141
- const date = new Date(quest.dateTimeCreated);
142
- date.setDate(date.getDate() + Number(quest?.daysToClear ?? 0));
143
- return getEndOfDay(date);
144
- }, [quest?.dateTimeCreated, quest?.daysToClear]);
145
- const remainingTime = useRemainingTime(targetDateTime ?? new Date());
137
+ const remainingTime = useRemainingTime(quest?.endDateTime ?? '');
146
138
  const isExpired = quest?.status === 'FAILED' || remainingTime.expired;
147
139
  const sessionQuery = useSessionQuery();
148
140
  const session = sessionQuery.data;
@@ -1,21 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { endOfDay } from 'date-fns';
3
- import { useMemo } from 'react';
4
3
  import { useRemainingTime } from '../../client/hooks/useRemainingTime.js';
5
4
  import { ClockStopWatchIcon } from '../../icons/ClockStopWatchIcon.js';
6
5
  import { Badge } from '../../ui/Badge/index.js';
7
6
  import { useQuestContext } from './QuestsContext.js';
8
7
  export function RemainingTime({ endOfDay: useEndOfDay = false, className, }) {
9
8
  const quest = useQuestContext();
10
- const targetDateTime = useMemo(() => {
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;
16
- }
17
- return 0;
18
- }, [quest.daysToClear, useEndOfDay]);
9
+ const targetDateTime = useEndOfDay
10
+ ? endOfDay(new Date(quest.endDateTime)).toISOString()
11
+ : quest.endDateTime;
19
12
  const remainingTime = useRemainingTime(targetDateTime);
20
13
  if (quest.status === 'COMPLETED') {
21
14
  return (_jsx(Badge.Root, { size: "lg", colorScheme: "success", round: false, className: className?.completedBadgeRoot, children: _jsx(Badge.Label, { className: className?.completedBadgeLabel, children: "Completed" }) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.1094",
3
+ "version": "0.0.1095",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",