@opexa/portal-components 0.0.1094 → 0.0.1096
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, {
|
|
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
|
|
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,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { isAfter } from 'date-fns';
|
|
3
4
|
import { isString } from 'lodash-es';
|
|
4
5
|
import dynamic from 'next/dynamic';
|
|
5
6
|
import Image, {} from 'next/image';
|
|
@@ -52,17 +53,24 @@ export function Quests__client(props) {
|
|
|
52
53
|
const questsQuery = useAvailableQuestsQuery({
|
|
53
54
|
refetchInterval: 7500,
|
|
54
55
|
});
|
|
56
|
+
const now = new Date();
|
|
55
57
|
const quests = !questsQuery.data?.length
|
|
56
58
|
? []
|
|
57
59
|
: questsQuery.data.filter((quest) => {
|
|
60
|
+
const isExpired = quest.endDateTime
|
|
61
|
+
? isAfter(now, new Date(quest.endDateTime))
|
|
62
|
+
: false;
|
|
58
63
|
if (tab === 'AVAILABLE') {
|
|
59
|
-
return quest.status === 'IN_PROGRESS' || quest.status === 'ACTIVE'
|
|
64
|
+
return ((quest.status === 'IN_PROGRESS' || quest.status === 'ACTIVE') &&
|
|
65
|
+
!isExpired);
|
|
60
66
|
}
|
|
61
67
|
else if (tab === 'COMPLETED') {
|
|
62
68
|
return quest.status === 'COMPLETED';
|
|
63
69
|
}
|
|
64
70
|
else if (tab === 'FAILED') {
|
|
65
|
-
return quest.status === 'FAILED'
|
|
71
|
+
return (quest.status === 'FAILED' ||
|
|
72
|
+
((quest.status === 'IN_PROGRESS' || quest.status === 'ACTIVE') &&
|
|
73
|
+
isExpired));
|
|
66
74
|
}
|
|
67
75
|
return false;
|
|
68
76
|
});
|
|
@@ -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 =
|
|
11
|
-
|
|
12
|
-
|
|
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" }) }));
|