@opexa/portal-components 0.0.458 → 0.0.460
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.
|
@@ -19,6 +19,18 @@ export function MultiWageringQuest() {
|
|
|
19
19
|
const quest = useQuestContext();
|
|
20
20
|
const { stages, totalStage, currentStage, progressPercentage } = useMemo(() => {
|
|
21
21
|
const currentStage = quest.stages.filter((m) => m.cleared).length;
|
|
22
|
+
const getStageItemProgress = (overallProgress, stageNumber) => {
|
|
23
|
+
const stageSize = 100 / quest.stages.length;
|
|
24
|
+
const stageStart = (stageNumber - 1) * stageSize;
|
|
25
|
+
const stageEnd = stageStart + stageSize;
|
|
26
|
+
if (overallProgress >= stageEnd) {
|
|
27
|
+
return 100;
|
|
28
|
+
}
|
|
29
|
+
else if (overallProgress > stageStart) {
|
|
30
|
+
return ((overallProgress - stageStart) / stageSize) * 100;
|
|
31
|
+
}
|
|
32
|
+
return 0;
|
|
33
|
+
};
|
|
22
34
|
if (!quest?.stages) {
|
|
23
35
|
return {
|
|
24
36
|
stages: [],
|
|
@@ -27,8 +39,12 @@ export function MultiWageringQuest() {
|
|
|
27
39
|
progressPercentage: 0,
|
|
28
40
|
};
|
|
29
41
|
}
|
|
42
|
+
const transformedStages = quest.stages.map((stage, idx) => ({
|
|
43
|
+
...stage,
|
|
44
|
+
progressValue: getStageItemProgress(parseFloat(quest.progressPercentage), idx + 1),
|
|
45
|
+
}));
|
|
30
46
|
return {
|
|
31
|
-
stages:
|
|
47
|
+
stages: transformedStages,
|
|
32
48
|
totalStage: quest.stages.length,
|
|
33
49
|
currentStage: currentStage === 0 ? 1 : currentStage,
|
|
34
50
|
progressPercentage: +quest.progressPercentage,
|
|
@@ -68,23 +84,23 @@ function Stages(props) {
|
|
|
68
84
|
const stage = props?.stages?.findLastIndex((stage) => stage.cleared) ?? 0;
|
|
69
85
|
return stage !== -1 ? stage + 1 : 1;
|
|
70
86
|
}, [props.stages]);
|
|
71
|
-
return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: open, onOpenChange: (details) => setOpen(details.open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "mx-auto mt-40 min-h-auto min-w-[23rem] max-w-[25rem] overflow-y-auto rounded-xl px-4 py-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "group flex flex-col space-y-5 text-sm text-text-quarterary-brand", children: [_jsx("h2", { className: "font-semibold text-lg text-text-primary-900", children: props.quest?.name || 'Quest' }), _jsx("div", { dangerouslySetInnerHTML: {
|
|
87
|
+
return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: open, onOpenChange: (details) => setOpen(details.open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "mx-auto mt-40 min-h-auto min-w-[23rem] max-w-[25rem] overflow-y-auto rounded-xl px-4 py-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "group flex flex-col space-y-5 text-sm text-text-quarterary-brand", children: [_jsx("h2", { className: "font-semibold text-lg text-text-primary-900", children: props.quest?.name || 'Quest' }), _jsx("div", { className: "font-normal text-[#94969C] text-sm", dangerouslySetInnerHTML: {
|
|
72
88
|
__html: props.quest?.description ||
|
|
73
89
|
'Ready for a challenge? Complete them all and get amazing rewards!',
|
|
74
90
|
} }), _jsx("div", { className: "flex w-full flex-col space-y-3", children: props.stages.map((stage, idx) => {
|
|
75
91
|
if (currentStage >= idx + 1) {
|
|
76
|
-
return (_jsx(QuestWageringStageUnlocked, { data: stage, bonus: stage.bonusAmount, stage: idx, isCompleted: stage.cleared }, idx));
|
|
92
|
+
return (_jsx(QuestWageringStageUnlocked, { data: stage, progressValue: stage.progressValue, bonus: stage.bonusAmount, stage: idx, isCompleted: stage.cleared }, idx));
|
|
77
93
|
}
|
|
78
94
|
else {
|
|
79
95
|
return _jsx(QuestWageringStageLocked, { stage: idx }, idx);
|
|
80
96
|
}
|
|
81
97
|
}) }), _jsx(Button, { size: "sm", onClick: () => setOpen(false), "aria-label": "Close", className: "w-full", children: "Close" })] })] }) })] }) }));
|
|
82
98
|
}
|
|
83
|
-
function QuestWageringStageUnlocked({ bonus, stage, data, isCompleted = false, }) {
|
|
99
|
+
function QuestWageringStageUnlocked({ bonus, stage, progressValue, data, isCompleted = false, }) {
|
|
84
100
|
const localeInfo = useLocaleInfo();
|
|
85
|
-
return (_jsxs("div", { className: "mb-4 flex flex-col justify-between rounded-xl bg-bg-secondary p-3", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("p", { className: "font-medium", children: ["Stage ", stage + 1] }), _jsx(Badge.Root, { colorScheme: isCompleted ? 'success' : 'blue', size: "md", round: true, children: _jsx(Badge.Label, { children: data.cleared ? 'Completed' : 'Ongoing' }) })] }), _jsxs("div", { className: "mt-2.5 flex items-center justify-between", children: [_jsxs("p", { children: ["Progress ",
|
|
101
|
+
return (_jsxs("div", { className: "mb-4 flex flex-col justify-between rounded-xl bg-bg-secondary p-3", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("p", { className: "font-medium", children: ["Stage ", stage + 1] }), _jsx(Badge.Root, { colorScheme: isCompleted ? 'success' : 'blue', size: "md", round: true, children: _jsx(Badge.Label, { children: data.cleared ? 'Completed' : 'Ongoing' }) })] }), _jsxs("div", { className: "mt-2.5 flex items-center justify-between", children: [_jsxs("p", { children: ["Progress ", progressValue, "%"] }), _jsx(Badge.Root, { size: "md", className: "border border-border-badge bg-bg-badge", round: false, children: _jsxs(Badge.Label, { className: "!text-text-badge", children: ["+", formatNumber(bonus, {
|
|
86
102
|
currency: localeInfo.currency.code,
|
|
87
|
-
}), ' ', "Bonus"] }) })] }), _jsx(Progress.Root, { max: 100, className: "mt-2 h-2 rounded-full bg-bg-primary", value:
|
|
103
|
+
}), ' ', "Bonus"] }) })] }), _jsx(Progress.Root, { max: 100, className: "mt-2 h-2 rounded-full bg-bg-primary", value: progressValue ?? 0, children: _jsx(Progress.Track, { children: _jsx(Progress.Range, { className: "bg-utility-brand-600" }) }) })] }));
|
|
88
104
|
}
|
|
89
105
|
function QuestWageringStageLocked({ stage }) {
|
|
90
106
|
return (_jsxs("div", { className: "mb-4 flex items-center justify-between rounded-xl bg-bg-secondary p-3", children: [_jsxs("p", { className: "font-medium", children: ["Stage ", stage + 1] }), _jsx("div", { className: "flex items-center justify-center rounded-full border border-border-lock bg-bg-lock p-1", children: _jsx(Lock01Icon, { className: "size-3 stroke-3 font-medium text-text-lock" }) })] }));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import closeChest from '../../images/close-chest.png';
|
|
4
|
+
export const NoQuests = ({ heading, description }) => {
|
|
5
|
+
return (_jsxs(_Fragment, { children: [_jsx("h2", { className: "mb-3 font-semibold text-lg capitalize", children: heading ?? 'Quests' }), _jsxs("div", { className: "mt-11 flex flex-col items-center justify-center", children: [_jsx(Image, { src: closeChest, width: 100, height: 100, alt: "No Quests Available", className: "mix-blend-luminosity" }), _jsx("div", { className: "mt-3 text-center text-sm text-text-tertiary-600", children: description ?? 'No available quests. Please check back later!' })] })] }));
|
|
6
|
+
};
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { isString } from 'lodash-es';
|
|
4
4
|
import dynamic from 'next/dynamic';
|
|
5
5
|
import Image from 'next/image';
|
|
6
|
-
import { useState, } from 'react';
|
|
6
|
+
import { Suspense, useState, } from 'react';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { useAvailableQuestsQuery } from '../../client/hooks/useAvailableQuestsQuery.js';
|
|
@@ -13,6 +13,7 @@ import closeChest from '../../images/close-chest.png';
|
|
|
13
13
|
import { SegmentGroup } from '../../ui/SegmentGroup/index.js';
|
|
14
14
|
import { DailyCheckInQuest, } from './DailyCheckInQuest.js';
|
|
15
15
|
import { JourneyQuest } from './JourneyQuest.js';
|
|
16
|
+
import { NoQuests } from './NoQuests.js';
|
|
16
17
|
import { OnboardingQuest } from './OnboardingQuest.js';
|
|
17
18
|
import { QuestContext } from './QuestsContext.js';
|
|
18
19
|
import { WageringQuest, } from './WageringQuest.js';
|
|
@@ -57,14 +58,16 @@ export function Quests__client(props) {
|
|
|
57
58
|
}
|
|
58
59
|
return (_jsxs("div", { style: style, className: twMerge(classNames?.root), children: [_jsx("h2", { className: "font-semibold text-lg", children: heading ?? 'Quests' }), _jsxs(SegmentGroup.Root, { value: tab, onValueChange: (details) => {
|
|
59
60
|
setTab(TabDefinition.catch('AVAILABLE').parse(details.value));
|
|
60
|
-
}, className: "mt-3 w-full overflow-x-auto lg:mt-4.5 lg:w-fit", children: [_jsxs(SegmentGroup.Item, { value: "AVAILABLE", className: "w-full lg:w-fit", children: [_jsx(SegmentGroup.ItemText, { children: "Available" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "COMPLETED", className: "w-full lg:w-fit", children: [_jsx(SegmentGroup.ItemText, { children: "Completed" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "FAILED", className: "w-full lg:w-fit", children: [_jsx(SegmentGroup.ItemText, { children: "Failed" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsx(SegmentGroup.Indicator, {})] }), _jsx("div", { className: "mt-3xl grid gap-3xl lg:mt-lg lg:grid-cols-3", children: quests.map((quest) => {
|
|
61
|
+
}, className: "mt-3 w-full overflow-x-auto lg:mt-4.5 lg:w-fit", children: [_jsxs(SegmentGroup.Item, { value: "AVAILABLE", className: "w-full lg:w-fit", children: [_jsx(SegmentGroup.ItemText, { children: "Available" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "COMPLETED", className: "w-full lg:w-fit", children: [_jsx(SegmentGroup.ItemText, { children: "Completed" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "FAILED", className: "w-full lg:w-fit", children: [_jsx(SegmentGroup.ItemText, { children: "Failed" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsx(SegmentGroup.Indicator, {})] }), _jsx("div", { className: "mt-3xl grid gap-3xl lg:mt-lg lg:grid-cols-3", children: quests.length > 0 ? (quests.map((quest) => {
|
|
61
62
|
const Quest = quest.stages?.length && featureFlag.enabled
|
|
62
63
|
? QUEST_COMPONENT_MAP['MULTI_WAGERING']
|
|
63
64
|
: QUEST_COMPONENT_MAP[quest.type];
|
|
64
|
-
return (_jsx(QuestContext, { value: quest, children: _jsx(Quest, { className: quest.type === 'WAGERING'
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
return (_jsx(QuestContext, { value: quest, children: _jsx(Suspense, { children: _jsx(Quest, { className: quest.type === 'WAGERING'
|
|
66
|
+
? classNames?.wageringQuest
|
|
67
|
+
: quest.type === 'DAILY_CHECKIN'
|
|
68
|
+
? classNames?.dailyCheckInQuest
|
|
69
|
+
: '', uncompletedIcon: props.uncompletedIcon, customComplete: quest.type === 'WAGERING'
|
|
70
|
+
? props.customComplete
|
|
71
|
+
: undefined, showTurnoverDecimals: props.showTurnoverDecimals }) }) }, quest.id));
|
|
72
|
+
})) : (_jsx(NoQuests, { heading: `${tab.toLowerCase()} Quests`, description: `You have no ${tab.toLowerCase()} quests yet.` })) })] }));
|
|
70
73
|
}
|