@opexa/portal-components 0.0.150 → 0.0.152
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.
- package/dist/client/hooks/useGlobalStore.d.ts +1 -6
- package/dist/client/hooks/useGlobalStore.js +0 -30
- package/dist/components/KYC/IdentityVerification.js +1 -1
- package/dist/components/KYC/KYC.d.ts +1 -1
- package/dist/components/KYC/KYC.js +3 -3
- package/dist/components/Messages/Message.js +8 -10
- package/dist/components/Messages/MessageContext.d.ts +1 -1
- package/dist/components/Messages/MessageContext.js +1 -1
- package/dist/components/Messages/MessagePopup.d.ts +1 -1
- package/dist/components/Messages/MessagePopup.js +7 -11
- package/dist/components/Messages/Messages.d.ts +1 -1
- package/dist/components/Messages/Messages.js +3 -3
- package/dist/components/Messages/Messages.lazy.js +53 -12
- package/dist/components/Messages/MessagesContext.d.ts +6 -0
- package/dist/components/Messages/MessagesContext.js +1 -0
- package/dist/components/Messages/MessagesPopup.d.ts +1 -0
- package/dist/components/Messages/MessagesPopup.js +33 -0
- package/dist/components/Messages/index.d.ts +0 -2
- package/dist/components/Messages/index.js +0 -2
- package/dist/components/Quests/CountdownTimer.d.ts +15 -0
- package/dist/components/Quests/CountdownTimer.js +33 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +4 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +78 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +8 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +9 -0
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +4 -0
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +4 -0
- package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +4 -0
- package/dist/components/Quests/WageringQuest/WageringQuest.js +20 -0
- package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +9 -0
- package/dist/components/Quests/WageringQuest/WageringQuestModal.js +9 -0
- package/dist/services/wallet.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
- package/dist/ui/Badge/Badge.d.ts +12 -12
- package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
- package/dist/ui/Badge/badge.recipe.d.ts +3 -3
- package/dist/ui/Carousel/Carousel.d.ts +389 -0
- package/dist/ui/Carousel/Carousel.js +15 -0
- package/dist/ui/Carousel/carousel.recipe.d.ts +43 -0
- package/dist/ui/Carousel/carousel.recipe.js +6 -0
- package/dist/ui/Carousel/index.d.ts +1 -0
- package/dist/ui/Carousel/index.js +1 -0
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/ui/Dialog/Dialog.d.ts +88 -88
- package/dist/ui/Dialog/dialog.recipe.d.ts +8 -8
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Menu/Menu.d.ts +90 -90
- package/dist/ui/Menu/menu.recipe.d.ts +5 -5
- package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
- package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
- package/dist/ui/Progress/Progress.d.ts +27 -27
- package/dist/ui/Progress/progress.recipe.d.ts +3 -3
- package/dist/ui/QrCode/QrCode.d.ts +25 -25
- package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
- package/dist/ui/Select/Select.d.ts +45 -45
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.anatomy.d.ts +1 -1
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/dist/ui/Tabs/Tabs.d.ts +15 -15
- package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
- package/dist/ui/Tooltip/Tooltip.d.ts +30 -30
- package/dist/ui/Tooltip/tooltip.recipe.d.ts +5 -5
- package/dist/utils/dataUrlToBlob.d.ts +1 -0
- package/dist/utils/dataUrlToBlob.js +11 -0
- package/dist/utils/resizeImageSize.d.ts +2 -0
- package/dist/utils/resizeImageSize.js +11 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FavoriteGame, Game, GameSession
|
|
1
|
+
import type { FavoriteGame, Game, GameSession } from '../../types';
|
|
2
2
|
interface PopupStore {
|
|
3
3
|
open: boolean;
|
|
4
4
|
setOpen: (open: boolean) => void;
|
|
@@ -35,10 +35,6 @@ interface SearchStore extends PopupStore {
|
|
|
35
35
|
}
|
|
36
36
|
type DepositWithdrawalTab = 'DEPOSIT' | 'WITHDRAWAL';
|
|
37
37
|
type MessagesTab = 'ALL' | 'UNREAD';
|
|
38
|
-
interface MessageStore extends PopupStore {
|
|
39
|
-
data: Message | null;
|
|
40
|
-
setData: (content: Message | null) => void;
|
|
41
|
-
}
|
|
42
38
|
interface MessagesStore extends PopupStore {
|
|
43
39
|
tab: MessagesTab;
|
|
44
40
|
setTab: (tab: MessagesTab) => void;
|
|
@@ -60,7 +56,6 @@ interface GlobalStore {
|
|
|
60
56
|
account: PopupStore;
|
|
61
57
|
account__mobile: PopupStore;
|
|
62
58
|
messages: MessagesStore;
|
|
63
|
-
message: MessageStore;
|
|
64
59
|
sidebar: CollapsibleStore;
|
|
65
60
|
kyc: PopupStore;
|
|
66
61
|
spotBonus: PopupStore;
|
|
@@ -126,10 +126,6 @@ export const useGlobalStore = create((set) => ({
|
|
|
126
126
|
open,
|
|
127
127
|
'~touched': true,
|
|
128
128
|
},
|
|
129
|
-
message: {
|
|
130
|
-
...prev.message,
|
|
131
|
-
'~touched': true,
|
|
132
|
-
},
|
|
133
129
|
}));
|
|
134
130
|
},
|
|
135
131
|
'~touched': false,
|
|
@@ -143,32 +139,6 @@ export const useGlobalStore = create((set) => ({
|
|
|
143
139
|
}));
|
|
144
140
|
},
|
|
145
141
|
},
|
|
146
|
-
message: {
|
|
147
|
-
open: false,
|
|
148
|
-
setOpen(open) {
|
|
149
|
-
set((prev) => ({
|
|
150
|
-
message: {
|
|
151
|
-
...prev.message,
|
|
152
|
-
open,
|
|
153
|
-
'~touched': true,
|
|
154
|
-
},
|
|
155
|
-
messages: {
|
|
156
|
-
...prev.messages,
|
|
157
|
-
'~touched': true,
|
|
158
|
-
},
|
|
159
|
-
}));
|
|
160
|
-
},
|
|
161
|
-
'~touched': false,
|
|
162
|
-
data: null,
|
|
163
|
-
setData(content) {
|
|
164
|
-
set((prev) => ({
|
|
165
|
-
message: {
|
|
166
|
-
...prev.message,
|
|
167
|
-
data: content,
|
|
168
|
-
},
|
|
169
|
-
}));
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
142
|
search: {
|
|
173
143
|
open: false,
|
|
174
144
|
setOpen(open) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import dynamic from 'next/dynamic';
|
|
4
|
+
import Script from 'next/script';
|
|
4
5
|
import { useShallow } from 'zustand/shallow';
|
|
5
6
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
6
7
|
const Component = dynamic(() => import('./KYC.lazy.js').then((m) => m.KYC), {
|
|
@@ -9,6 +10,5 @@ const Component = dynamic(() => import('./KYC.lazy.js').then((m) => m.KYC), {
|
|
|
9
10
|
});
|
|
10
11
|
export function KYC(props) {
|
|
11
12
|
const touched = useGlobalStore(useShallow((ctx) => ctx.kyc['~touched']));
|
|
12
|
-
|
|
13
|
-
return _jsx(Component, { ...props });
|
|
13
|
+
return (_jsxs(_Fragment, { children: [touched && _jsx(Component, { ...props }), _jsx(Script, { src: "https://docs.opencv.org/4.7.0/opencv.js", async: true }), _jsx(Script, { src: "https://cdn.jsdelivr.net/gh/ColonelParrot/jscanify@master/src/jscanify.min.js", strategy: "afterInteractive" })] }));
|
|
14
14
|
}
|
|
@@ -7,12 +7,8 @@ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
|
7
7
|
import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
|
|
8
8
|
import { useMarkMessageAsReadMutation } from '../../client/hooks/useMarkMessageAsReadMutation.js';
|
|
9
9
|
import { useMessageContext } from './MessageContext.js';
|
|
10
|
-
import {
|
|
11
|
-
import { useMessagesPropsContext } from './MessagesContext.js';
|
|
12
|
-
import { normalizeActionUrl } from './utils.js';
|
|
10
|
+
import { getMessageIcon } from './utils.js';
|
|
13
11
|
export function Message() {
|
|
14
|
-
const messagesProps = useMessagesPropsContext();
|
|
15
|
-
const transactionsPageUrl = messagesProps.transactionsPageUrl ?? '/transactions';
|
|
16
12
|
const message = useMessageContext();
|
|
17
13
|
const localeInfo = useLocaleInfo();
|
|
18
14
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
@@ -20,6 +16,7 @@ export function Message() {
|
|
|
20
16
|
messages: ctx.messages,
|
|
21
17
|
})));
|
|
22
18
|
const markMessageAsReadMutation = useMarkMessageAsReadMutation();
|
|
19
|
+
const Icon = getMessageIcon(message.icon);
|
|
23
20
|
const handleViewMessage = async () => {
|
|
24
21
|
globalStore.message.setData(message);
|
|
25
22
|
globalStore.message.setOpen(true);
|
|
@@ -27,11 +24,12 @@ export function Message() {
|
|
|
27
24
|
if (!message.markedAsRead)
|
|
28
25
|
markMessageAsReadMutation.mutate(message.id);
|
|
29
26
|
};
|
|
27
|
+
const handleActionClick = (e) => {
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
globalStore.messages.setOpen(false);
|
|
30
|
+
globalStore.messages.setTab('ALL');
|
|
31
|
+
};
|
|
30
32
|
return (_jsxs("div", { role: "button", tabIndex: 0, className: "border-border-secondary rounded-xs bg-bg-secondary flex h-auto flex-shrink-0 cursor-pointer flex-col border px-3.5 py-2.5", onClick: handleViewMessage, "aria-pressed": "false", children: [_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx("p", { className: "text-text-tertiary-600 text-xs font-normal", children: format(new Date(message.dateTimeCreated), 'M/d/yyyy - h:mma', {
|
|
31
33
|
in: tz(localeInfo.timezone),
|
|
32
|
-
}) }), !message.markedAsRead && (_jsx("div", { className: "bg-utility-success-500 h-2.5 w-2.5 rounded-full" }))] }), _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(
|
|
33
|
-
e.stopPropagation();
|
|
34
|
-
globalStore.messages.setOpen(false);
|
|
35
|
-
globalStore.messages.setTab('ALL');
|
|
36
|
-
}, children: action.name }, index))) }))] }));
|
|
34
|
+
}) }), !message.markedAsRead && (_jsx("div", { className: "bg-utility-success-500 h-2.5 w-2.5 rounded-full" }))] }), _jsxs("div", { className: "mb-2 flex items-center space-x-2", children: [_jsx(Icon, { className: "text-brand-400" }), _jsx("p", { className: "text-text-primary-brand text-sm font-semibold", children: message.title })] }), _jsx("p", { className: "line-clamp-3 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: message.content } }), message.actions.length > 0 && (_jsx("div", { className: "mt-2 flex flex-wrap items-center justify-end gap-2", children: message.actions.map((action, index) => (_jsx(Link, { className: "border-button-secondary-border text-button-secondary-fg rounded-md border px-3 py-2 text-sm", href: action.url, onClick: handleActionClick, children: action.name }, index))) }))] }));
|
|
37
35
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createContext } from '../../client/utils/createContext.js';
|
|
2
|
-
export const [
|
|
2
|
+
export const [MessageContext, useMessageContext] = createContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const MessagePopup: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import Image from 'next/image';
|
|
4
3
|
import Link from 'next/link';
|
|
5
4
|
import { useShallow } from 'zustand/shallow';
|
|
6
5
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
7
6
|
import { XIcon } from '../../icons/XIcon.js';
|
|
8
7
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
9
8
|
import { Portal } from '../../ui/Portal/index.js';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import { normalizeActionUrl } from './utils.js';
|
|
13
|
-
export function MessagePopup() {
|
|
14
|
-
const messagesProps = useMessagesPropsContext();
|
|
15
|
-
const transactionsPageUrl = messagesProps.transactionsPageUrl ?? '/transactions';
|
|
9
|
+
import { getMessageIcon } from './utils.js';
|
|
10
|
+
export const MessagePopup = () => {
|
|
16
11
|
const globalStore = useGlobalStore(useShallow((ctx) => ({ message: ctx.message })));
|
|
12
|
+
const Icon = getMessageIcon(globalStore.message.data?.icon ?? 'MESSAGE');
|
|
17
13
|
return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: globalStore.message.open, onOpenChange: ({ open }) => {
|
|
18
14
|
globalStore.message.setOpen(open);
|
|
19
|
-
}, 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: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl px-xl pb-0 pt-5 shadow-xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "pb-6", children: [_jsx("div", { className: "bg-bg-brand-secondary mx-auto w-fit rounded-full p-3", children: _jsx(
|
|
20
|
-
__html: globalStore.message.data
|
|
21
|
-
} })
|
|
15
|
+
}, 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: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl px-xl pb-0 pt-5 shadow-xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "pb-6", children: [_jsx("div", { className: "bg-bg-brand-secondary mx-auto w-fit rounded-full p-3", children: _jsx(Icon, { className: "text-text-brand", height: "24", width: "24" }) }), _jsx("p", { className: "text-text-primary-brand mt-lg text-center text-lg font-semibold leading-tight", children: globalStore.message.data?.title }), _jsx("div", { className: "text-shadow-text-secondary-700 mt-xs text-center text-sm font-normal leading-tight", dangerouslySetInnerHTML: {
|
|
16
|
+
__html: globalStore.message.data?.content ?? '',
|
|
17
|
+
} })] }), globalStore.message.data?.actions.length ? (_jsx("div", { className: "flex flex-col space-y-2 px-4 pb-8 pt-6 text-center", children: globalStore.message.data.actions.map((action, index) => (_jsx(Link, { className: "bg-button-primary-bg rounded-xs text-button-primary-fg w-full px-4 py-2.5 text-base font-semibold", href: action.url, onClick: () => {
|
|
22
18
|
globalStore.message.setOpen(false);
|
|
23
19
|
}, children: action.name }, index))) })) : null] }) })] }) }));
|
|
24
|
-
}
|
|
20
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MessagesProps } from './Messages.lazy';
|
|
2
|
-
export declare function Messages(props: MessagesProps): import("react/jsx-runtime").JSX.Element
|
|
2
|
+
export declare function Messages(props: MessagesProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export type { MessagesProps };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import dynamic from 'next/dynamic';
|
|
4
4
|
import { useShallow } from 'zustand/shallow';
|
|
5
5
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
6
|
+
import { MessagesPopup } from './MessagesPopup.js';
|
|
6
7
|
const Component = dynamic(() => import('./Messages.lazy.js').then((mod) => mod.Messages), {
|
|
7
8
|
ssr: false,
|
|
8
9
|
loading: () => null,
|
|
9
10
|
});
|
|
10
11
|
export function Messages(props) {
|
|
11
12
|
const touched = useGlobalStore(useShallow((ctx) => ctx.messages['~touched']));
|
|
12
|
-
|
|
13
|
-
return _jsx(Component, { ...props });
|
|
13
|
+
return (_jsxs(_Fragment, { children: [touched && _jsx(Component, { ...props }), _jsx(MessagesPopup, {})] }));
|
|
14
14
|
}
|
|
@@ -1,26 +1,34 @@
|
|
|
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';
|
|
5
|
+
import Image from 'next/image';
|
|
6
|
+
import Link from 'next/link';
|
|
3
7
|
import { twMerge } from 'tailwind-merge';
|
|
4
8
|
import { z } from 'zod';
|
|
5
9
|
import { useShallow } from 'zustand/shallow';
|
|
10
|
+
import { useDisclosure } from '../../client/hooks/useDisclosure.js';
|
|
6
11
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
12
|
+
import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
|
|
13
|
+
import { useMarkMessageAsReadMutation } from '../../client/hooks/useMarkMessageAsReadMutation.js';
|
|
7
14
|
import { useMessagesQuery } from '../../client/hooks/useMessagesQuery.js';
|
|
8
15
|
import { useUnreadMessagesCountQuery } from '../../client/hooks/useUnreadMessagesCountQuery.js';
|
|
9
16
|
import { SpinnerIcon } from '../../icons/SpinnerIcon.js';
|
|
10
17
|
import { XIcon } from '../../icons/XIcon.js';
|
|
18
|
+
import { Button } from '../../ui/Button/index.js';
|
|
19
|
+
import { Dialog } from '../../ui/Dialog/index.js';
|
|
11
20
|
import { Drawer } from '../../ui/Drawer/index.js';
|
|
12
21
|
import { Portal } from '../../ui/Portal/index.js';
|
|
13
22
|
import { Tabs } from '../../ui/Tabs/index.js';
|
|
14
23
|
import { InfiniteScroll } from '../shared/InfiniteScroll.js';
|
|
15
|
-
import {
|
|
16
|
-
import { MessageProvider } from './
|
|
17
|
-
import {
|
|
18
|
-
import { MessagesPropsProvider } from './MessagesContext.js';
|
|
24
|
+
import { MessageIcon } from './MessageIcon.js';
|
|
25
|
+
import { MessageProvider, MessagesPropsProvider, useMessageContext, useMessagesPropsContext, } from './MessagesContext.js';
|
|
26
|
+
import { normalizeActionUrl } from './utils.js';
|
|
19
27
|
const TABS = ['ALL', 'UNREAD'];
|
|
20
28
|
export function Messages(props) {
|
|
21
29
|
const globalStore = useGlobalStore(useShallow((ctx) => ({ messages: ctx.messages })));
|
|
22
30
|
const unreadMessagesCountQuery = useUnreadMessagesCountQuery({}, {
|
|
23
|
-
refetchInterval: globalStore.messages.open ?
|
|
31
|
+
refetchInterval: globalStore.messages.open ? 5_000 : 10_000,
|
|
24
32
|
});
|
|
25
33
|
const unreadMessagesCount = unreadMessagesCountQuery.data ?? 0;
|
|
26
34
|
const messagesQuery = useMessagesQuery({
|
|
@@ -34,16 +42,49 @@ export function Messages(props) {
|
|
|
34
42
|
}),
|
|
35
43
|
}, {
|
|
36
44
|
enabled: globalStore.messages.open,
|
|
37
|
-
refetchInterval:
|
|
45
|
+
refetchInterval: 5_000,
|
|
38
46
|
});
|
|
39
47
|
const messages = messagesQuery.data?.pages.flatMap((page) => page.edges.map((e) => e.node)) ?? [];
|
|
40
48
|
const [mobileOffsetTop, desktopOffsetTop] = Array.isArray(props.offsetTop)
|
|
41
49
|
? props.offsetTop
|
|
42
50
|
: [props.offsetTop ?? '0px', props.offsetTop ?? '0px'];
|
|
43
|
-
return (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
return (_jsx(MessagesPropsProvider, { value: props, children: _jsx(Drawer.Root, { open: globalStore.messages.open, onOpenChange: ({ open }) => globalStore.messages.setOpen(open), lazyMount: true, children: _jsx(Portal, { children: _jsx(Drawer.Positioner, { children: _jsx(Drawer.Content, { className: twMerge('flex', 'flex-col', 'border-border-secondary', 'top-[var(--offset-top-mobile)]', 'h-[calc(100%-var(--offset-top-mobile))]', 'lg:border-l', 'lg:top-[var(--offset-top-desktop)]', 'lg:h-[calc(100%-var(--offset-top-desktop))]'), style: {
|
|
52
|
+
['--offset-top-mobile']: mobileOffsetTop,
|
|
53
|
+
['--offset-top-desktop']: desktopOffsetTop,
|
|
54
|
+
}, children: _jsxs("div", { className: "flex h-full flex-col", children: [_jsxs("div", { className: "flex items-end justify-between p-xl", children: [_jsx("p", { className: "text-text-primary-brand text-xl font-semibold", children: "Notifications" }), _jsx(Drawer.CloseTrigger, { className: "p-2", children: _jsx(XIcon, {}) })] }), _jsxs(Tabs.Root, { value: globalStore.messages.tab, onValueChange: (details) => globalStore.messages.setTab(z.enum(TABS).parse(details.value)), lazyMount: true, unmountOnExit: true, className: "flex grow flex-col overflow-y-auto", children: [_jsx("div", { className: "p-xl pt-0", children: _jsxs(Tabs.List, { className: "w-full", children: [_jsx(Tabs.Trigger, { value: "ALL", className: "w-full", children: "All" }), _jsxs(Tabs.Trigger, { value: "UNREAD", className: "w-full", children: ["Unread", !!unreadMessagesCount && (_jsx("span", { className: "border-border-primary bg-bg-secondary ml-md rounded-full border px-2 py-0.5", children: unreadMessagesCount }))] }), _jsx(Tabs.Indicator, {})] }) }), TABS.map((tab) => (_jsxs(Tabs.Content, { value: tab, className: "scrollbar:w-2 scrollbar-track:bg-bg-primary-alt scrollbar-track:rounded-full scrollbar-thumb:bg-bg-quaternary scrollbar-thumb:rounded-full border-border-secondary grow overflow-y-auto border-t p-xl", children: [messages.length > 0 && (_jsx("div", { className: "flex flex-col space-y-3", children: messages.map((message) => (_jsx(MessageProvider, { value: message, children: _jsx(Message, {}) }, message.id))) })), _jsx(InfiniteScroll, { loader: _jsx(SpinnerIcon, { className: "mx-auto size-5" }), hasMore: !!messagesQuery.hasNextPage, loadMore: async () => {
|
|
55
|
+
await messagesQuery.fetchNextPage();
|
|
56
|
+
}, className: "mt-4" })] }, tab)))] })] }) }) }) }) }) }));
|
|
57
|
+
}
|
|
58
|
+
function Message() {
|
|
59
|
+
const messagesProps = useMessagesPropsContext();
|
|
60
|
+
const transactionsPageUrl = messagesProps.transactionsPageUrl ?? '/transactions';
|
|
61
|
+
const message = useMessageContext();
|
|
62
|
+
const localeInfo = useLocaleInfo();
|
|
63
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
64
|
+
messages: ctx.messages,
|
|
65
|
+
})));
|
|
66
|
+
const disclosure = useDisclosure({
|
|
67
|
+
onOpenChange(open) {
|
|
68
|
+
if (open) {
|
|
69
|
+
globalStore.messages.setOpen(false);
|
|
70
|
+
if (!message.markedAsRead) {
|
|
71
|
+
markMessageAsReadMutation.mutate(message.id);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
const markMessageAsReadMutation = useMarkMessageAsReadMutation();
|
|
77
|
+
return (_jsxs(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: disclosure.open, onOpenChange: (details) => {
|
|
78
|
+
disclosure.setOpen(details.open);
|
|
79
|
+
}, closeOnEscape: false, closeOnInteractOutside: false, children: [_jsxs(Dialog.Trigger, { className: "border-border-secondary rounded-xs bg-bg-secondary flex h-auto flex-shrink-0 cursor-pointer flex-col border px-3.5 py-2.5 text-left", children: [_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx("p", { className: "text-text-tertiary-600 text-xs font-normal", children: format(new Date(message.dateTimeCreated), 'M/d/yyyy - h:mma', {
|
|
80
|
+
in: tz(localeInfo.timezone),
|
|
81
|
+
}) }), !message.markedAsRead && (_jsx("span", { className: "bg-utility-success-500 block size-2.5 rounded-full" }))] }), _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(MessageIcon, { type: message.icon, className: "text-brand-400 size-5" }), _jsx("h2", { className: "text-text-primary-brand text-sm font-semibold", children: message.title })] }), message.content && (_jsx("div", { className: "mt-2 line-clamp-3 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: message.content } })), message.actions.length > 0 && (_jsx("div", { className: "mt-2 flex flex-wrap items-center justify-end gap-2", children: message.actions.map((action, index) => (_jsx(Link, { className: "border-button-secondary-border text-button-secondary-fg rounded-md border px-3 py-2 text-sm", href: normalizeActionUrl(transactionsPageUrl, action.url), onClick: (e) => {
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
globalStore.messages.setOpen(false);
|
|
84
|
+
globalStore.messages.setTab('ALL');
|
|
85
|
+
}, children: action.name }, index))) }))] }), _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: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl p-3xl lg:min-w-[25rem] lg:max-w-[25rem]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx("div", { className: "bg-bg-brand-secondary text-text-brand mx-auto flex size-12 items-center justify-center rounded-full", children: _jsx(MessageIcon, { type: message.icon, className: "size-6" }) }), _jsx(Dialog.Title, { className: "mt-lg text-center text-lg font-semibold lg:mt-xl", children: message.title }), message.content && (_jsx(Dialog.Description, { className: "text-text-secondary-700 mt-xs pb-5 text-center text-sm", dangerouslySetInnerHTML: {
|
|
86
|
+
__html: message.content,
|
|
87
|
+
} })), message.image && (_jsx("div", { className: "mt-5 pb-5", children: _jsx(Image, { src: message.image, alt: "", width: 400, height: 250, loading: "lazy", unoptimized: true, className: "h-auto w-full rounded-sm" }) })), message.actions.length ? (_jsx("div", { className: "mt-3xl flex flex-col gap-2 text-center lg:mt-4xl", children: message.actions.map((action, index) => (_jsx(Button, { asChild: true, children: _jsx(Link, { href: normalizeActionUrl(transactionsPageUrl, action.url), onClick: () => {
|
|
88
|
+
disclosure.setOpen(false);
|
|
89
|
+
}, children: action.name }) }, index))) })) : null] }) })] })] }));
|
|
49
90
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import type { Message } from '../../types';
|
|
1
2
|
import type { MessagesProps } from './Messages.lazy';
|
|
2
3
|
export declare const MessagesPropsProvider: (props: {
|
|
3
4
|
value: MessagesProps;
|
|
4
5
|
} & {
|
|
5
6
|
children?: import("react").ReactNode | undefined;
|
|
6
7
|
}) => React.ReactNode, useMessagesPropsContext: () => MessagesProps;
|
|
8
|
+
export declare const MessageProvider: (props: {
|
|
9
|
+
value: Message;
|
|
10
|
+
} & {
|
|
11
|
+
children?: import("react").ReactNode | undefined;
|
|
12
|
+
}) => React.ReactNode, useMessageContext: () => Message;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function MessagesPopup(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { useMessagesQuery } from '../../client/hooks/useMessagesQuery.js';
|
|
5
|
+
import { ChevronLeftIcon } from '../../icons/ChevronLeftIcon.js';
|
|
6
|
+
import { ChevronRightIcon } from '../../icons/ChevronRightIcon.js';
|
|
7
|
+
import { XIcon } from '../../icons/XIcon.js';
|
|
8
|
+
import { Button } from '../../ui/Button/index.js';
|
|
9
|
+
import { Carousel } from '../../ui/Carousel/index.js';
|
|
10
|
+
import { Dialog } from '../../ui/Dialog/index.js';
|
|
11
|
+
import { Portal } from '../../ui/Portal/index.js';
|
|
12
|
+
import { MessageIcon } from './MessageIcon.js';
|
|
13
|
+
import { normalizeActionUrl } from './utils.js';
|
|
14
|
+
export function MessagesPopup() {
|
|
15
|
+
const messagesQuery = useMessagesQuery({
|
|
16
|
+
first: 50,
|
|
17
|
+
// filter: {
|
|
18
|
+
// popup: {
|
|
19
|
+
// equal: true,
|
|
20
|
+
// },
|
|
21
|
+
// markedAsRead: {
|
|
22
|
+
// equal: true,
|
|
23
|
+
// },
|
|
24
|
+
// },
|
|
25
|
+
}, {
|
|
26
|
+
refetchInterval: 10_000,
|
|
27
|
+
});
|
|
28
|
+
const messages = messagesQuery.data?.pages.flatMap((page) => page.edges.map((edge) => edge.node)) ?? [];
|
|
29
|
+
console.log({ messages });
|
|
30
|
+
return (_jsx(Dialog.Root, { 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: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl p-3xl lg:min-w-[25rem] lg:max-w-[25rem]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(Carousel.Root, { slideCount: messages.length, allowMouseDrag: true, children: [_jsx(Carousel.ItemGroup, { children: messages.map((message, index) => (_jsxs(Carousel.Item, { index: index, className: "select-none", children: [_jsx("div", { className: "bg-bg-brand-secondary text-text-brand mx-auto flex size-12 items-center justify-center rounded-full", children: _jsx(MessageIcon, { type: message.icon, className: "size-6" }) }), _jsx("h2", { className: "mt-lg text-center text-lg font-semibold xl:mt-xl", children: message.title }), message.content && (_jsx("div", { dangerouslySetInnerHTML: { __html: message.content }, className: "text-text-secondary-700 mt-xs pb-5 text-center text-sm" })), message.image && (_jsx("div", { className: "mt-5 pb-5", children: _jsx(Image, { src: message.image, alt: "", width: 400, height: 250, loading: "lazy", unoptimized: true, className: "h-auto w-full rounded-sm" }) })), message.actions.length ? (_jsx("div", { className: "mt-3xl flex flex-col gap-2 text-center lg:mt-4xl", children: message.actions.map((action, index) => (_jsx(Button, { asChild: true, children: _jsx(Link, { href: normalizeActionUrl('/', action.url), onClick: () => {
|
|
31
|
+
// disclosure.setOpen(false);
|
|
32
|
+
}, children: action.name }) }, index))) })) : null] }, message.id))) }), _jsxs(Carousel.Control, { className: "mt-5 flex items-center lg:mt-3xl", children: [_jsxs(Carousel.PrevTrigger, { className: "text-text-quarterary-500 hidden items-center gap-md font-semibold disabled:invisible lg:flex", children: [_jsx(ChevronLeftIcon, { className: "size-5" }), "Back"] }), _jsx(Carousel.IndicatorGroup, { className: "flex grow justify-center gap-xs", children: messages.map((message, index) => (_jsx(Carousel.Indicator, { index: index, className: "bg-bg-quaternary ui-current:bg-brand-400 size-2.5 rounded-full transition-all duration-150 ui-current:w-5" }, message.id))) }), _jsxs(Carousel.NextTrigger, { className: "text-text-quarterary-500 hidden items-center gap-md font-semibold disabled:invisible lg:flex", children: ["Next", _jsx(ChevronRightIcon, { className: "size-5" })] })] })] })] }) })] }) }));
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
type TimeLeft = {
|
|
3
|
+
days: number;
|
|
4
|
+
hours: number;
|
|
5
|
+
minutes: number;
|
|
6
|
+
seconds: number;
|
|
7
|
+
};
|
|
8
|
+
interface CountdownTimerProps {
|
|
9
|
+
startDateTime?: string;
|
|
10
|
+
endDateTime?: string;
|
|
11
|
+
renderAction: (timeLeft: TimeLeft) => ReactNode;
|
|
12
|
+
onEnd?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export default function CountdownTimer({ startDateTime, endDateTime, renderAction, onEnd, }: CountdownTimerProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { differenceInSeconds, parseISO } from 'date-fns';
|
|
4
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
5
|
+
export default function CountdownTimer({ startDateTime, endDateTime, renderAction, onEnd, }) {
|
|
6
|
+
const calculateTimeLeft = useCallback(() => {
|
|
7
|
+
const start = startDateTime ? parseISO(startDateTime) : new Date();
|
|
8
|
+
const end = endDateTime ? parseISO(endDateTime) : new Date();
|
|
9
|
+
const totalSeconds = Math.max(differenceInSeconds(end, start), 0);
|
|
10
|
+
const days = Math.floor(totalSeconds / (60 * 60 * 24));
|
|
11
|
+
const hours = Math.floor((totalSeconds % (60 * 60 * 24)) / (60 * 60));
|
|
12
|
+
const minutes = Math.floor((totalSeconds % (60 * 60)) / 60);
|
|
13
|
+
const seconds = totalSeconds % 60;
|
|
14
|
+
return { days, hours, minutes, seconds };
|
|
15
|
+
}, [startDateTime, endDateTime]);
|
|
16
|
+
const [timeLeft, setTimeLeft] = useState(calculateTimeLeft);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const interval = setInterval(() => {
|
|
19
|
+
const newTimeLeft = calculateTimeLeft();
|
|
20
|
+
setTimeLeft(newTimeLeft);
|
|
21
|
+
const isZero = newTimeLeft.days === 0 &&
|
|
22
|
+
newTimeLeft.hours === 0 &&
|
|
23
|
+
newTimeLeft.minutes === 0 &&
|
|
24
|
+
newTimeLeft.seconds === 0;
|
|
25
|
+
if (isZero) {
|
|
26
|
+
clearInterval(interval);
|
|
27
|
+
onEnd?.();
|
|
28
|
+
}
|
|
29
|
+
}, 1000);
|
|
30
|
+
return () => clearInterval(interval);
|
|
31
|
+
}, [calculateTimeLeft, onEnd]);
|
|
32
|
+
return _jsx(_Fragment, { children: renderAction(timeLeft) });
|
|
33
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { addDays, isEqual, startOfDay } from 'date-fns';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
|
+
import { useCheckInDailyCheckInQuestMutation } from '../../../client/hooks/useCheckInDailyCheckInQuestMutation.js';
|
|
7
|
+
import { toaster } from '../../../client/utils/toaster.js';
|
|
8
|
+
import { CalendarIcon } from '../../../icons/CalendarIcon.js';
|
|
9
|
+
import { CheckIcon } from '../../../icons/CheckIcon.js';
|
|
10
|
+
import { ClockStopWatchIcon } from '../../../icons/ClockStopWatchIcon.js';
|
|
11
|
+
import { InfoCircleIcon } from '../../../icons/InfoCircleIcon.js';
|
|
12
|
+
import { Badge } from '../../../ui/Badge/index.js';
|
|
13
|
+
import { Button } from '../../../ui/Button/index.js';
|
|
14
|
+
import { getQueryClient } from '../../../utils/getQueryClient.js';
|
|
15
|
+
import { getAvailableQuestsQueryKey } from '../../../utils/queryKeys.js';
|
|
16
|
+
import CountdownTimer from '../CountdownTimer.js';
|
|
17
|
+
import { DailyCheckInQuestModal } from './DailyCheckInQuestModal.js';
|
|
18
|
+
export function DailyCheckInQuest({ quest }) {
|
|
19
|
+
const queryClient = getQueryClient();
|
|
20
|
+
const [showRules, setShowRules] = useState(false);
|
|
21
|
+
const [isExpired, setIsExpired] = useState(false);
|
|
22
|
+
const { name, description, status, lastCheckInDate, progressPercentage, checkInStreak, thirdDayBonusAmount, sixthDayBonusAmount, seventhDayBonusAmount, endDateTime, id, } = quest;
|
|
23
|
+
const today = startOfDay(new Date());
|
|
24
|
+
const hasCheckedInToday = lastCheckInDate
|
|
25
|
+
? isEqual(today, startOfDay(new Date(lastCheckInDate)))
|
|
26
|
+
: false;
|
|
27
|
+
const checkedInRewards = {
|
|
28
|
+
3: thirdDayBonusAmount,
|
|
29
|
+
6: sixthDayBonusAmount,
|
|
30
|
+
7: seventhDayBonusAmount,
|
|
31
|
+
};
|
|
32
|
+
const dailyCheckedInData = Array.from({ length: 7 }, (_, i) => {
|
|
33
|
+
const day = i + 1;
|
|
34
|
+
return {
|
|
35
|
+
day,
|
|
36
|
+
reward: checkedInRewards[day] ?? 0,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
const { mutate } = useCheckInDailyCheckInQuestMutation({
|
|
40
|
+
onSuccess() {
|
|
41
|
+
toaster.success({
|
|
42
|
+
title: 'Check-in successful 🎉',
|
|
43
|
+
description: 'You’ve successfully checked in for today! Keep it up to maintain your streak!',
|
|
44
|
+
});
|
|
45
|
+
queryClient.invalidateQueries({
|
|
46
|
+
queryKey: getAvailableQuestsQueryKey(),
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
onError(e) {
|
|
50
|
+
toaster.error({
|
|
51
|
+
title: 'Check-in successful 🎉',
|
|
52
|
+
description: e.message ?? 'Check-In Failed',
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const handleCheckIn = async () => mutate(id);
|
|
57
|
+
return (_jsxs(_Fragment, { children: [_jsx(DailyCheckInQuestModal, { modalState: {
|
|
58
|
+
isOpen: showRules,
|
|
59
|
+
setIsOpen: setShowRules,
|
|
60
|
+
} }), _jsxs("div", { className: "border-border-primary bg-bg-tertiary flex h-full w-full flex-col space-y-6 rounded-2xl border px-4 pb-6 pt-5", children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-start justify-between", children: [_jsx(CountdownTimer, { endDateTime: endDateTime, renderAction: (timeLeft) => (_jsxs(Badge.Root, { size: "lg", colorScheme: "brand", round: false, children: [_jsx(Badge.Icon, { children: _jsx(ClockStopWatchIcon, {}) }), _jsxs(Badge.Label, { children: [timeLeft.days, "d:", timeLeft.hours, "h:", timeLeft.minutes, "m:", timeLeft.seconds, "s"] })] })), onEnd: () => setIsExpired(true) }), _jsx("div", { role: "button", className: "bg-bg-primary border-border-secondary flex size-9 cursor-pointer items-center justify-center rounded-md border", onClick: () => setShowRules((prev) => !prev), children: _jsx(InfoCircleIcon, { className: "text-text-disabled size-5" }) })] }), _jsx("p", { className: "text-xl font-semibold", children: name }), _jsx("p", { className: "text-text-secondary-700 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsx("div", { className: "grid grid-cols-7", children: dailyCheckedInData.map((item) => {
|
|
61
|
+
const reward = item.reward ? `+₱${item.reward}` : '-';
|
|
62
|
+
return (_jsx("div", { className: twMerge('flex items-center justify-center', item.day <= (checkInStreak || 0)
|
|
63
|
+
? 'text-brand-400'
|
|
64
|
+
: 'text-text-secondary-700'), children: _jsx("p", { children: reward }) }, item.day));
|
|
65
|
+
}) }), _jsx("div", { className: "bg-bg-primary h-2 w-full overflow-hidden rounded-full", children: _jsx("div", { className: "bg-utility-brand-600 h-full rounded-full transition-all duration-300", style: { width: `${progressPercentage}%` } }) }), _jsx("div", { className: "grid grid-cols-7", children: dailyCheckedInData.map((item) => (_jsx("div", { className: "flex items-center justify-center", children: _jsx(CalendarWithDayNumber, { day: item.day, currentCheckedInDays: checkInStreak || 0 }, item.day) }, item.day))) })] }), _jsx(Button, { onClick: handleCheckIn, className: "disabled:bg-bg-primary disabled:text-text-disabled", disabled: isExpired ||
|
|
66
|
+
status === 'COMPLETED' ||
|
|
67
|
+
status === 'FAILED' ||
|
|
68
|
+
hasCheckedInToday, children: hasCheckedInToday && status === 'IN_PROGRESS' ? (_jsx(CountdownTimer, { endDateTime: startOfDay(addDays(new Date(), 1)).toISOString(), renderAction: (timeLeft) => (_jsxs("div", { className: "flex items-center space-x-0.5", children: [_jsx(CheckIcon, {}), _jsxs("p", { children: [timeLeft.hours, "h:", timeLeft.minutes, "m:", timeLeft.seconds, "s"] })] })), onEnd: () => {
|
|
69
|
+
queryClient.invalidateQueries({
|
|
70
|
+
queryKey: getAvailableQuestsQueryKey(),
|
|
71
|
+
});
|
|
72
|
+
} })) : ('Check-In') })] })] }));
|
|
73
|
+
}
|
|
74
|
+
function CalendarWithDayNumber({ day, currentCheckedInDays, }) {
|
|
75
|
+
return (_jsxs("div", { className: twMerge('group relative h-fit w-fit', day <= currentCheckedInDays
|
|
76
|
+
? 'text-brand-400'
|
|
77
|
+
: 'text-text-secondary-700'), children: [_jsx(CalendarIcon, {}), _jsx("div", { className: "absolute inset-0 mt-1 flex items-center justify-center text-2xs lg:mt-[2px]", children: _jsx("p", { className: "text-center", children: day }) })] }));
|
|
78
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { XIcon } from '../../../icons/XIcon.js';
|
|
4
|
+
import { Button } from '../../../ui/Button/index.js';
|
|
5
|
+
import { Dialog } from '../../../ui/Dialog/index.js';
|
|
6
|
+
import { Portal } from '../../../ui/Portal/index.js';
|
|
7
|
+
export function DailyCheckInQuestModal(props) {
|
|
8
|
+
return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: props.modalState.isOpen, onOpenChange: ({ open }) => props.modalState.setIsOpen(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: "min-h-auto mx-auto max-w-[343px] rounded-xl px-4 pb-0 pt-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "flex flex-col space-y-5", children: [_jsx("p", { className: "text-text-primary-900 text-lg font-semibold", children: "Daily Check-In Rules" }), _jsxs("ul", { className: "text-text-tertiary-600 group list-disc text-wrap pl-4 text-sm font-normal", children: [_jsx("li", { children: "Earn rewards just for checking in each day!" }), _jsx("li", { children: "Stay consistent to unlock special rewards on the 3rd, 5th, and 7th day." }), _jsx("li", { children: "Missing a day will reset your streak, starting again from Day 1." }), _jsx("li", { children: "Each check-in unlocks the next one on the following day." }), _jsx("li", { children: "Successfully check in for 7 consecutive days to complete the quest and reset the cycle." })] })] }), _jsx("div", { className: "pb-4 pt-6", children: _jsx(Button, { onClick: () => props.modalState.setIsOpen(false), children: "Ok" }) })] }) })] }) }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { ClockStopWatchIcon } from '../../../icons/ClockStopWatchIcon.js';
|
|
6
|
+
import { InfoCircleIcon } from '../../../icons/InfoCircleIcon.js';
|
|
7
|
+
import { Badge } from '../../../ui/Badge/index.js';
|
|
8
|
+
import CountdownTimer from '../CountdownTimer.js';
|
|
9
|
+
import { WageringQuestModal } from './WageringQuestModal.js';
|
|
10
|
+
export function WageringQuest({ quest }) {
|
|
11
|
+
const [showRules, setShowRules] = useState(false);
|
|
12
|
+
const [isExpired, setIsExpired] = useState(false);
|
|
13
|
+
const { progressPercentage, turnover, targetTurnover, name, description, endDateTime, bonus, status, } = quest;
|
|
14
|
+
return (_jsxs(_Fragment, { children: [_jsx(WageringQuestModal, { questName: name, modalState: {
|
|
15
|
+
isOpen: showRules,
|
|
16
|
+
setIsOpen: setShowRules,
|
|
17
|
+
} }), _jsxs("div", { className: "border-border-primary bg-bg-tertiary flex h-full w-full flex-col space-y-6 rounded-2xl border px-4 pb-6 pt-5", children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-start justify-between", children: [_jsx(CountdownTimer, { endDateTime: endDateTime, renderAction: (timeLeft) => (_jsxs(Badge.Root, { size: "lg", colorScheme: "brand", round: false, children: [_jsx(Badge.Icon, { children: _jsx(ClockStopWatchIcon, {}) }), _jsxs(Badge.Label, { children: [timeLeft.days, "d:", timeLeft.hours, "h:", timeLeft.minutes, "m:", timeLeft.seconds, "s"] })] })), onEnd: () => setIsExpired(true) }), _jsx("div", { role: "button", className: "bg-bg-primary border-border-secondary flex size-9 cursor-pointer items-center justify-center rounded-md border", onClick: () => setShowRules((prev) => !prev), children: _jsx(InfoCircleIcon, { className: "text-text-disabled size-5" }) })] }), _jsx("p", { className: "text-xl font-semibold", children: name }), _jsx("p", { className: "text-text-secondary-700 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsxs("div", { className: "text-text-primary-brand group flex items-center justify-between", children: [_jsxs("p", { children: ["Progress ", parseInt(progressPercentage).toFixed(2), "%"] }), _jsxs("p", { children: [turnover, _jsxs("span", { className: "text-text-quarterary-brand", children: ["/", targetTurnover, " PHP"] })] })] }), _jsx("div", { className: "bg-bg-primary h-2 w-full overflow-hidden rounded-full", children: _jsx("div", { className: "bg-utility-brand-600 h-full rounded-full transition-all duration-300", style: { width: `${progressPercentage}%` } }) })] }), _jsx("div", { className: "flex h-full items-end", children: _jsx("div", { className: "bg-button-secondary-bg border-bg-primary-hover w-full rounded-md border px-3.5 py-2.5 text-center text-white", children: _jsxs("p", { className: twMerge(isExpired || status === 'COMPLETED' || status === 'FAILED'
|
|
18
|
+
? ['opacity-50 grayscale']
|
|
19
|
+
: ''), children: ["Complete to get ", _jsxs("span", { className: "text-brand-400", children: ["\u20B1", bonus] }), ' ', "bonus!"] }) }) })] })] }));
|
|
20
|
+
}
|