@opexa/portal-components 0.0.1095 → 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,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
|
});
|