@taskon/widget-react 0.0.1-beta.4 → 0.0.1-beta.6
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/README.md +13 -4
- package/dist/CommunityTaskList.css +119 -111
- package/dist/EligibilityInfo.css +114 -110
- package/dist/LeaderboardWidget.css +73 -71
- package/dist/PageBuilder.css +5 -0
- package/dist/Quest.css +259 -255
- package/dist/TaskOnProvider.css +2 -0
- package/dist/UserCenterWidget.css +6 -6
- package/dist/UserCenterWidget2.css +1626 -1601
- package/dist/{dynamic-import-helper.css → WidgetShell.css} +2 -2
- package/dist/chunks/{CommunityTaskList-C9Gv8KOF.js → CommunityTaskList-Hde2OKHH.js} +1070 -580
- package/dist/chunks/{EligibilityInfo-D-Fuy9GE.js → EligibilityInfo-BV0Z2TgY.js} +1972 -1028
- package/dist/chunks/{LeaderboardWidget-BV2D2q1N.js → LeaderboardWidget-BNGRD5Bu.js} +270 -249
- package/dist/chunks/{PageBuilder-DQoU4Mwf.js → PageBuilder-C5DSHiW9.js} +5 -5
- package/dist/chunks/{Quest-B5NyVr3o.js → Quest-DG9zfXJo.js} +723 -513
- package/dist/chunks/{TaskOnProvider-93UxARFo.js → TaskOnProvider-BhamHIyY.js} +98 -68
- package/dist/chunks/{ThemeProvider-CPI_roeh.js → ThemeProvider-mXLdLSkq.js} +107 -20
- package/dist/chunks/{UserCenterWidget-cADBSVg7.js → UserCenterWidget-D5ttw4hO.js} +1328 -1337
- package/dist/chunks/{UserCenterWidget-BRtigY_S.js → UserCenterWidget-jDO5zTN1.js} +358 -254
- package/dist/chunks/{dynamic-import-helper-DwXlQC0S.js → WidgetShell-D7yC894Y.js} +447 -457
- package/dist/chunks/communitytask-es-CBNnS4o2.js +521 -0
- package/dist/chunks/communitytask-ja-GRf9cbdx.js +521 -0
- package/dist/chunks/communitytask-ko-Bf24PQKI.js +521 -0
- package/dist/chunks/communitytask-ru-CZm2CPoV.js +521 -0
- package/dist/chunks/leaderboardwidget-es-vKjrjQaz.js +146 -0
- package/dist/chunks/leaderboardwidget-ja-Q6u0HxKG.js +146 -0
- package/dist/chunks/leaderboardwidget-ko-CG6SWgxf.js +146 -0
- package/dist/chunks/leaderboardwidget-ru-DCcHcJGz.js +146 -0
- package/dist/chunks/quest-es-Dyyy0zaw.js +863 -0
- package/dist/chunks/quest-ja-Depog33y.js +863 -0
- package/dist/chunks/quest-ko-BMu3uRQJ.js +863 -0
- package/dist/chunks/quest-ru-xne814Rw.js +863 -0
- package/dist/chunks/taskwidget-es-Do9b3Mqw.js +245 -0
- package/dist/chunks/taskwidget-ja-CqSu-yWA.js +245 -0
- package/dist/chunks/taskwidget-ko-EHgXFV4B.js +245 -0
- package/dist/chunks/taskwidget-ru-CMbLQDK4.js +245 -0
- package/dist/chunks/usercenter-es-Dz3Wp2vV.js +512 -0
- package/dist/chunks/usercenter-ja-CKE4DJC6.js +512 -0
- package/dist/chunks/usercenter-ko-Dtpkn2qb.js +512 -0
- package/dist/chunks/usercenter-ru-DnBGee45.js +512 -0
- package/dist/community-task.d.ts +0 -390
- package/dist/community-task.js +2 -7
- package/dist/core.d.ts +46 -10
- package/dist/core.js +11 -11
- package/dist/index.d.ts +46 -667
- package/dist/index.js +19 -28
- package/dist/leaderboard.d.ts +0 -498
- package/dist/leaderboard.js +2 -16
- package/dist/page-builder.js +1 -1
- package/dist/quest.d.ts +0 -289
- package/dist/quest.js +2 -5
- package/dist/user-center.d.ts +0 -1608
- package/dist/user-center.js +2 -494
- package/package.json +5 -2
- package/dist/chunks/leaderboardwidget-ja-Bj6gz6y1.js +0 -119
- package/dist/chunks/leaderboardwidget-ko-f1cLO9ic.js +0 -119
- package/dist/chunks/usercenter-ja-B2465c1O.js +0 -326
- package/dist/chunks/usercenter-ko-xAEYxqLg.js +0 -326
package/dist/user-center.js
CHANGED
|
@@ -1,496 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { L as LoadingState, E as EmptyState, P as Pagination } from "./chunks/UserCenterWidget-cADBSVg7.js";
|
|
4
|
-
import { F, T, d as d2, f as f2, t, c as c2, u as u2, a as a2, b as b2 } from "./chunks/UserCenterWidget-cADBSVg7.js";
|
|
5
|
-
import { formatLocalDate, formatTokenAmount as formatTokenAmount$1, RewardType, createUserCenterApi } from "@taskon/core";
|
|
6
|
-
import { getChainIcon, getChainName, getSocialIcon, toWei, truncateAddress } from "@taskon/core";
|
|
7
|
-
import { D as Dialog, B as Button } from "./chunks/dynamic-import-helper-DwXlQC0S.js";
|
|
8
|
-
import { useState, useMemo, useCallback, useEffect } from "react";
|
|
9
|
-
import { d as useTaskOnContext } from "./chunks/ThemeProvider-CPI_roeh.js";
|
|
10
|
-
function getTabLabel(tab, messages) {
|
|
11
|
-
switch (tab) {
|
|
12
|
-
case "MyRewards":
|
|
13
|
-
return messages.tabMyRewards;
|
|
14
|
-
case "Identity":
|
|
15
|
-
return messages.tabIdentity;
|
|
16
|
-
case "ActivityHistory":
|
|
17
|
-
return messages.tabActivityHistory;
|
|
18
|
-
default:
|
|
19
|
-
return tab;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function TabBar({
|
|
23
|
-
activeTab,
|
|
24
|
-
tabs,
|
|
25
|
-
onTabChange,
|
|
26
|
-
messages,
|
|
27
|
-
className = ""
|
|
28
|
-
}) {
|
|
29
|
-
return /* @__PURE__ */ jsx("div", { className: `taskon-user-center-tabs ${className}`, children: tabs.map((tab) => /* @__PURE__ */ jsx(
|
|
30
|
-
"button",
|
|
31
|
-
{
|
|
32
|
-
type: "button",
|
|
33
|
-
className: `taskon-user-center-tabs__tab ${activeTab === tab ? "taskon-user-center-tabs__tab--active" : ""}`,
|
|
34
|
-
onClick: () => onTabChange(tab),
|
|
35
|
-
children: getTabLabel(tab, messages)
|
|
36
|
-
},
|
|
37
|
-
tab
|
|
38
|
-
)) });
|
|
39
|
-
}
|
|
40
|
-
function formatTime(timestamp) {
|
|
41
|
-
return formatLocalDate(timestamp);
|
|
42
|
-
}
|
|
43
|
-
function formatTokenAmount(amount) {
|
|
44
|
-
return formatTokenAmount$1(amount, {
|
|
45
|
-
showCurrency: false,
|
|
46
|
-
useAbbreviation: false,
|
|
47
|
-
decimals: 4,
|
|
48
|
-
minValue: 1e-4,
|
|
49
|
-
zeroText: "0"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function getEmptyMessage(rewardType, messages) {
|
|
53
|
-
switch (rewardType) {
|
|
54
|
-
case "Token":
|
|
55
|
-
return messages.emptyToken;
|
|
56
|
-
case "Nft":
|
|
57
|
-
return messages.emptyNft;
|
|
58
|
-
default:
|
|
59
|
-
return messages.noData;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function TokenRow({ item, onClick }) {
|
|
63
|
-
const tokenValue = item.reward_value;
|
|
64
|
-
return /* @__PURE__ */ jsxs(
|
|
65
|
-
"div",
|
|
66
|
-
{
|
|
67
|
-
className: "taskon-reward-detail__row",
|
|
68
|
-
onClick,
|
|
69
|
-
role: onClick ? "button" : void 0,
|
|
70
|
-
tabIndex: onClick ? 0 : void 0,
|
|
71
|
-
children: [
|
|
72
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--icon", children: tokenValue.token_logo && /* @__PURE__ */ jsx(
|
|
73
|
-
"img",
|
|
74
|
-
{
|
|
75
|
-
src: tokenValue.token_logo,
|
|
76
|
-
alt: tokenValue.token_name,
|
|
77
|
-
className: "taskon-reward-detail__token-icon"
|
|
78
|
-
}
|
|
79
|
-
) }),
|
|
80
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--main", children: [
|
|
81
|
-
/* @__PURE__ */ jsxs("span", { className: "taskon-reward-detail__primary", children: [
|
|
82
|
-
"+",
|
|
83
|
-
formatTokenAmount(tokenValue.amount),
|
|
84
|
-
" ",
|
|
85
|
-
tokenValue.token_name
|
|
86
|
-
] }),
|
|
87
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__secondary", children: item.campaign_name })
|
|
88
|
-
] }),
|
|
89
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--time", children: formatTime(item.reward_time) })
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
function NftRow({
|
|
95
|
-
item,
|
|
96
|
-
onClick,
|
|
97
|
-
onClaim,
|
|
98
|
-
onTxClick,
|
|
99
|
-
messages
|
|
100
|
-
}) {
|
|
101
|
-
const nftValue = item.reward_value;
|
|
102
|
-
const renderNftAction = () => {
|
|
103
|
-
if (nftValue.tx_hash) {
|
|
104
|
-
return /* @__PURE__ */ jsx(
|
|
105
|
-
"button",
|
|
106
|
-
{
|
|
107
|
-
type: "button",
|
|
108
|
-
className: "taskon-reward-detail__claimed-link",
|
|
109
|
-
onClick: (e2) => {
|
|
110
|
-
e2.stopPropagation();
|
|
111
|
-
onTxClick == null ? void 0 : onTxClick();
|
|
112
|
-
},
|
|
113
|
-
title: nftValue.tx_hash,
|
|
114
|
-
children: messages.claimedTxn
|
|
115
|
-
}
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
if (nftValue.claimable) {
|
|
119
|
-
return /* @__PURE__ */ jsx(
|
|
120
|
-
"button",
|
|
121
|
-
{
|
|
122
|
-
type: "button",
|
|
123
|
-
className: "taskon-reward-detail__claim-btn",
|
|
124
|
-
onClick: (e2) => {
|
|
125
|
-
e2.stopPropagation();
|
|
126
|
-
onClaim == null ? void 0 : onClaim();
|
|
127
|
-
},
|
|
128
|
-
children: messages.claim
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
return /* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__manual-drop", children: messages.manualDrop });
|
|
133
|
-
};
|
|
134
|
-
return /* @__PURE__ */ jsxs(
|
|
135
|
-
"div",
|
|
136
|
-
{
|
|
137
|
-
className: "taskon-reward-detail__row taskon-reward-detail__row--nft",
|
|
138
|
-
onClick,
|
|
139
|
-
role: onClick ? "button" : void 0,
|
|
140
|
-
tabIndex: onClick ? 0 : void 0,
|
|
141
|
-
children: [
|
|
142
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--nft-image", children: nftValue.collection_image && /* @__PURE__ */ jsx(
|
|
143
|
-
"img",
|
|
144
|
-
{
|
|
145
|
-
src: nftValue.collection_image,
|
|
146
|
-
alt: nftValue.collection_name,
|
|
147
|
-
className: "taskon-reward-detail__nft-image"
|
|
148
|
-
}
|
|
149
|
-
) }),
|
|
150
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--main", children: [
|
|
151
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__primary", children: nftValue.collection_name }),
|
|
152
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__secondary", children: item.campaign_name })
|
|
153
|
-
] }),
|
|
154
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--time", children: formatTime(item.reward_time) }),
|
|
155
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--action", children: renderNftAction() })
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
function SimpleRow({ item, onClick }) {
|
|
161
|
-
return /* @__PURE__ */ jsxs(
|
|
162
|
-
"div",
|
|
163
|
-
{
|
|
164
|
-
className: "taskon-reward-detail__row",
|
|
165
|
-
onClick,
|
|
166
|
-
role: onClick ? "button" : void 0,
|
|
167
|
-
tabIndex: onClick ? 0 : void 0,
|
|
168
|
-
children: [
|
|
169
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--main", children: [
|
|
170
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__primary", children: item.campaign_name }),
|
|
171
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-reward-detail__secondary", children: item.campaign_type })
|
|
172
|
-
] }),
|
|
173
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__cell taskon-reward-detail__cell--time", children: formatTime(item.reward_time) })
|
|
174
|
-
]
|
|
175
|
-
}
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
function RewardDetailList({
|
|
179
|
-
rewardType,
|
|
180
|
-
data,
|
|
181
|
-
loading,
|
|
182
|
-
error,
|
|
183
|
-
pagination,
|
|
184
|
-
messages,
|
|
185
|
-
onItemClick,
|
|
186
|
-
onClaim,
|
|
187
|
-
onTxClick
|
|
188
|
-
}) {
|
|
189
|
-
if (loading && data.length === 0) {
|
|
190
|
-
return /* @__PURE__ */ jsx(LoadingState, { message: messages.loading });
|
|
191
|
-
}
|
|
192
|
-
if (error && data.length === 0) {
|
|
193
|
-
return /* @__PURE__ */ jsx("div", { className: "taskon-user-center-error", children: /* @__PURE__ */ jsx("p", { className: "taskon-user-center-error__message", children: error.message }) });
|
|
194
|
-
}
|
|
195
|
-
if (!loading && data.length === 0) {
|
|
196
|
-
return /* @__PURE__ */ jsx(EmptyState, { message: getEmptyMessage(rewardType, messages) });
|
|
197
|
-
}
|
|
198
|
-
const renderRow = (item, index) => {
|
|
199
|
-
const handleClick = onItemClick ? () => onItemClick(item) : void 0;
|
|
200
|
-
const itemKey = `${item.campaign_id}-${item.reward_time}-${index}`;
|
|
201
|
-
switch (rewardType) {
|
|
202
|
-
case RewardType.Token:
|
|
203
|
-
return /* @__PURE__ */ jsx(TokenRow, { item, onClick: handleClick }, itemKey);
|
|
204
|
-
case RewardType.Nft:
|
|
205
|
-
return /* @__PURE__ */ jsx(
|
|
206
|
-
NftRow,
|
|
207
|
-
{
|
|
208
|
-
item,
|
|
209
|
-
onClick: handleClick,
|
|
210
|
-
onClaim: onClaim ? () => onClaim(item) : void 0,
|
|
211
|
-
onTxClick: onTxClick ? () => onTxClick(item) : void 0,
|
|
212
|
-
messages
|
|
213
|
-
},
|
|
214
|
-
itemKey
|
|
215
|
-
);
|
|
216
|
-
default:
|
|
217
|
-
return /* @__PURE__ */ jsx(SimpleRow, { item, onClick: handleClick }, itemKey);
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
return /* @__PURE__ */ jsxs("div", { className: "taskon-reward-detail", children: [
|
|
221
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__list", children: data.map((item, index) => renderRow(item, index)) }),
|
|
222
|
-
pagination.totalPages > 1 && /* @__PURE__ */ jsx(
|
|
223
|
-
Pagination,
|
|
224
|
-
{
|
|
225
|
-
page: pagination.page,
|
|
226
|
-
totalPages: pagination.totalPages,
|
|
227
|
-
onPrevious: pagination.goToPrevious,
|
|
228
|
-
onNext: pagination.goToNext,
|
|
229
|
-
hasPrevious: pagination.hasPrevious,
|
|
230
|
-
hasNext: pagination.hasNext,
|
|
231
|
-
messages
|
|
232
|
-
}
|
|
233
|
-
),
|
|
234
|
-
loading && data.length > 0 && /* @__PURE__ */ jsx("div", { className: "taskon-reward-detail__loading-more", children: /* @__PURE__ */ jsx("div", { className: "taskon-user-center-loading__spinner" }) })
|
|
235
|
-
] });
|
|
236
|
-
}
|
|
237
|
-
function formatAmount(amount) {
|
|
238
|
-
const num = parseFloat(amount);
|
|
239
|
-
if (isNaN(num) || num === 0) return "0";
|
|
240
|
-
return num.toLocaleString(void 0, { maximumFractionDigits: 6 });
|
|
241
|
-
}
|
|
242
|
-
function WarningIcon() {
|
|
243
|
-
return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "48", height: "48", children: /* @__PURE__ */ jsx("path", { d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }) });
|
|
244
|
-
}
|
|
245
|
-
function SuccessIcon() {
|
|
246
|
-
return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "48", height: "48", children: /* @__PURE__ */ jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) });
|
|
247
|
-
}
|
|
248
|
-
function WithdrawModal({
|
|
249
|
-
open,
|
|
250
|
-
status,
|
|
251
|
-
tokens,
|
|
252
|
-
messages,
|
|
253
|
-
error,
|
|
254
|
-
txHash,
|
|
255
|
-
isGasInsufficient,
|
|
256
|
-
onConfirm,
|
|
257
|
-
onCancel,
|
|
258
|
-
onClose
|
|
259
|
-
}) {
|
|
260
|
-
if (!open) {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
if (status === "noEnough" || isGasInsufficient) {
|
|
264
|
-
return /* @__PURE__ */ jsxs(
|
|
265
|
-
Dialog,
|
|
266
|
-
{
|
|
267
|
-
open,
|
|
268
|
-
onOpenChange: (isOpen) => {
|
|
269
|
-
if (!isOpen) onClose();
|
|
270
|
-
},
|
|
271
|
-
title: messages.gasNotEnough,
|
|
272
|
-
showCloseButton: true,
|
|
273
|
-
contentClassName: "taskon-withdraw-modal__content",
|
|
274
|
-
maxWidth: 400,
|
|
275
|
-
children: [
|
|
276
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-withdraw-modal__body", children: [
|
|
277
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-withdraw-modal__icon taskon-withdraw-modal__icon--warning", children: /* @__PURE__ */ jsx(WarningIcon, {}) }),
|
|
278
|
-
/* @__PURE__ */ jsx("p", { className: "taskon-withdraw-modal__message", children: messages.gasNotEnough })
|
|
279
|
-
] }),
|
|
280
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-withdraw-modal__footer", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: onClose, children: messages.ok ?? "OK" }) })
|
|
281
|
-
]
|
|
282
|
-
}
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
if (status === "success") {
|
|
286
|
-
return /* @__PURE__ */ jsxs(
|
|
287
|
-
Dialog,
|
|
288
|
-
{
|
|
289
|
-
open,
|
|
290
|
-
onOpenChange: (isOpen) => {
|
|
291
|
-
if (!isOpen) onClose();
|
|
292
|
-
},
|
|
293
|
-
title: messages.withdrawSuccess,
|
|
294
|
-
showCloseButton: true,
|
|
295
|
-
contentClassName: "taskon-withdraw-modal__content",
|
|
296
|
-
maxWidth: 400,
|
|
297
|
-
children: [
|
|
298
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-withdraw-modal__body", children: [
|
|
299
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-withdraw-modal__icon taskon-withdraw-modal__icon--success", children: /* @__PURE__ */ jsx(SuccessIcon, {}) }),
|
|
300
|
-
/* @__PURE__ */ jsx("p", { className: "taskon-withdraw-modal__message", children: messages.withdrawSuccess }),
|
|
301
|
-
txHash && /* @__PURE__ */ jsxs("p", { className: "taskon-withdraw-modal__tx-hash", children: [
|
|
302
|
-
"TX: ",
|
|
303
|
-
txHash.slice(0, 10),
|
|
304
|
-
"...",
|
|
305
|
-
txHash.slice(-8)
|
|
306
|
-
] })
|
|
307
|
-
] }),
|
|
308
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-withdraw-modal__footer", children: /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: onClose, children: messages.ok ?? "OK" }) })
|
|
309
|
-
]
|
|
310
|
-
}
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
return /* @__PURE__ */ jsxs(
|
|
314
|
-
Dialog,
|
|
315
|
-
{
|
|
316
|
-
open,
|
|
317
|
-
onOpenChange: (isOpen) => {
|
|
318
|
-
if (!isOpen) onCancel();
|
|
319
|
-
},
|
|
320
|
-
title: messages.withdrawConfirm,
|
|
321
|
-
showCloseButton: true,
|
|
322
|
-
contentClassName: "taskon-withdraw-modal__content",
|
|
323
|
-
maxWidth: 400,
|
|
324
|
-
children: [
|
|
325
|
-
/* @__PURE__ */ jsx("h3", { className: "taskon-withdraw-modal__title", children: messages.withdrawConfirm }),
|
|
326
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-withdraw-modal__body", children: [
|
|
327
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-withdraw-modal__tokens", children: tokens.map((token) => /* @__PURE__ */ jsxs(
|
|
328
|
-
"div",
|
|
329
|
-
{
|
|
330
|
-
className: "taskon-withdraw-modal__token-item",
|
|
331
|
-
children: [
|
|
332
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-withdraw-modal__token-info", children: [
|
|
333
|
-
/* @__PURE__ */ jsx(
|
|
334
|
-
"img",
|
|
335
|
-
{
|
|
336
|
-
src: token.tokenIcon,
|
|
337
|
-
alt: token.tokenSymbol,
|
|
338
|
-
className: "taskon-withdraw-modal__token-icon"
|
|
339
|
-
}
|
|
340
|
-
),
|
|
341
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-withdraw-modal__token-details", children: [
|
|
342
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-withdraw-modal__token-symbol", children: token.tokenSymbol }),
|
|
343
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-withdraw-modal__token-chain", children: token.chainLabel })
|
|
344
|
-
] })
|
|
345
|
-
] }),
|
|
346
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-withdraw-modal__token-amount", children: formatAmount(token.amount) })
|
|
347
|
-
]
|
|
348
|
-
},
|
|
349
|
-
token.tokenId
|
|
350
|
-
)) }),
|
|
351
|
-
error && /* @__PURE__ */ jsx("div", { className: "taskon-withdraw-modal__error", children: error.message })
|
|
352
|
-
] }),
|
|
353
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-withdraw-modal__footer", children: [
|
|
354
|
-
/* @__PURE__ */ jsx(
|
|
355
|
-
Button,
|
|
356
|
-
{
|
|
357
|
-
variant: "secondary",
|
|
358
|
-
onClick: onCancel,
|
|
359
|
-
disabled: status === "loading",
|
|
360
|
-
children: messages.cancel
|
|
361
|
-
}
|
|
362
|
-
),
|
|
363
|
-
/* @__PURE__ */ jsx(
|
|
364
|
-
Button,
|
|
365
|
-
{
|
|
366
|
-
variant: "primary",
|
|
367
|
-
onClick: onConfirm,
|
|
368
|
-
disabled: status === "loading",
|
|
369
|
-
loading: status === "loading",
|
|
370
|
-
children: status === "loading" ? messages.loading : messages.withdraw
|
|
371
|
-
}
|
|
372
|
-
)
|
|
373
|
-
] })
|
|
374
|
-
]
|
|
375
|
-
}
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
function calculateXpLevelData(userInfo) {
|
|
379
|
-
const xpPointsInfo = userInfo.points_list[0];
|
|
380
|
-
if (!xpPointsInfo) return null;
|
|
381
|
-
const currentXp = xpPointsInfo.amount;
|
|
382
|
-
const nextLevelXp = userInfo.next_level_limit;
|
|
383
|
-
let percent = 0;
|
|
384
|
-
if (nextLevelXp > 0) {
|
|
385
|
-
if (currentXp >= nextLevelXp) {
|
|
386
|
-
percent = 100;
|
|
387
|
-
} else {
|
|
388
|
-
percent = Number((currentXp / nextLevelXp * 100).toFixed(2));
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
const xpToNextLevel = currentXp >= nextLevelXp ? 0 : nextLevelXp - currentXp;
|
|
392
|
-
return {
|
|
393
|
-
level: userInfo.level,
|
|
394
|
-
currentXp,
|
|
395
|
-
nextLevelXp,
|
|
396
|
-
totalXp: currentXp,
|
|
397
|
-
percent,
|
|
398
|
-
xpToNextLevel,
|
|
399
|
-
xpPointsId: xpPointsInfo.points_info.points_id,
|
|
400
|
-
xpPointsName: xpPointsInfo.points_info.points_name,
|
|
401
|
-
xpPointsIcon: xpPointsInfo.points_info.points_icon
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
function useXpLevel(options = {}) {
|
|
405
|
-
const { autoLoad = true } = options;
|
|
406
|
-
const { client } = useTaskOnContext();
|
|
407
|
-
const [userInfo, setUserInfo] = useState(null);
|
|
408
|
-
const [loading, setLoading] = useState(false);
|
|
409
|
-
const [error, setError] = useState(null);
|
|
410
|
-
const api = useMemo(() => {
|
|
411
|
-
if (!client) return null;
|
|
412
|
-
return createUserCenterApi(client);
|
|
413
|
-
}, [client]);
|
|
414
|
-
const xpData = useMemo(() => {
|
|
415
|
-
if (!userInfo) return null;
|
|
416
|
-
return calculateXpLevelData(userInfo);
|
|
417
|
-
}, [userInfo]);
|
|
418
|
-
const xpPointsInfo = useMemo(() => {
|
|
419
|
-
if (!userInfo || !userInfo.points_list.length) return null;
|
|
420
|
-
const firstPoints = userInfo.points_list[0];
|
|
421
|
-
return firstPoints ?? null;
|
|
422
|
-
}, [userInfo]);
|
|
423
|
-
const otherPointsList = useMemo(() => {
|
|
424
|
-
if (!userInfo || userInfo.points_list.length <= 1) return [];
|
|
425
|
-
return userInfo.points_list.slice(1);
|
|
426
|
-
}, [userInfo]);
|
|
427
|
-
const fetchData = useCallback(async () => {
|
|
428
|
-
if (!api) {
|
|
429
|
-
setError(new Error("TaskOn client not initialized"));
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
setLoading(true);
|
|
433
|
-
setError(null);
|
|
434
|
-
try {
|
|
435
|
-
const response = await api.getCUserInfo({});
|
|
436
|
-
setUserInfo(response);
|
|
437
|
-
} catch (err) {
|
|
438
|
-
setError(
|
|
439
|
-
err instanceof Error ? err : new Error("Failed to fetch user info")
|
|
440
|
-
);
|
|
441
|
-
} finally {
|
|
442
|
-
setLoading(false);
|
|
443
|
-
}
|
|
444
|
-
}, [api]);
|
|
445
|
-
const refresh = useCallback(async () => {
|
|
446
|
-
await fetchData();
|
|
447
|
-
}, [fetchData]);
|
|
448
|
-
useEffect(() => {
|
|
449
|
-
if (autoLoad) {
|
|
450
|
-
fetchData();
|
|
451
|
-
}
|
|
452
|
-
}, [autoLoad, fetchData]);
|
|
453
|
-
return {
|
|
454
|
-
userInfo,
|
|
455
|
-
xpData,
|
|
456
|
-
xpPointsInfo,
|
|
457
|
-
otherPointsList,
|
|
458
|
-
loading,
|
|
459
|
-
error,
|
|
460
|
-
refresh
|
|
461
|
-
};
|
|
462
|
-
}
|
|
1
|
+
import { U } from "./chunks/UserCenterWidget-jDO5zTN1.js";
|
|
463
2
|
export {
|
|
464
|
-
|
|
465
|
-
a as AssetCard,
|
|
466
|
-
b as AssetCarousel,
|
|
467
|
-
EmptyState,
|
|
468
|
-
F as FrozenAssetList,
|
|
469
|
-
LoadingState,
|
|
470
|
-
Pagination,
|
|
471
|
-
RewardDetailList,
|
|
472
|
-
TabBar,
|
|
473
|
-
T as TokenAssetList,
|
|
474
|
-
U as UserCenterWidget,
|
|
475
|
-
WithdrawModal,
|
|
476
|
-
d2 as buildRewardCards,
|
|
477
|
-
f2 as formatTokenAmount,
|
|
478
|
-
getChainIcon,
|
|
479
|
-
getChainName,
|
|
480
|
-
getSocialIcon,
|
|
481
|
-
toWei,
|
|
482
|
-
t as toWithdrawItem,
|
|
483
|
-
truncateAddress,
|
|
484
|
-
u as useActivityHistory,
|
|
485
|
-
g as useBindWallet,
|
|
486
|
-
h as useDisableUnlink,
|
|
487
|
-
d as useFrozenAssets,
|
|
488
|
-
e as useIdentityData,
|
|
489
|
-
c2 as usePointsHistory,
|
|
490
|
-
u2 as useRewardDetails,
|
|
491
|
-
a2 as useTokenAssets,
|
|
492
|
-
b2 as useTokenWithdraw,
|
|
493
|
-
f as useUnbindSocial,
|
|
494
|
-
c as useUserRewards,
|
|
495
|
-
useXpLevel
|
|
3
|
+
U as UserCenterWidget
|
|
496
4
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taskon/widget-react",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.6",
|
|
4
4
|
"description": "TaskOn React Widget Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -64,6 +64,8 @@
|
|
|
64
64
|
"@taskon/core": "workspace:*",
|
|
65
65
|
"@taskon/eslint-config": "workspace:*",
|
|
66
66
|
"@taskon/typescript-config": "workspace:*",
|
|
67
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
68
|
+
"@testing-library/react": "^16.3.2",
|
|
67
69
|
"@types/dompurify": "^3.2.0",
|
|
68
70
|
"@types/node": "^22.15.3",
|
|
69
71
|
"@types/qrcode": "^1.5.5",
|
|
@@ -73,12 +75,13 @@
|
|
|
73
75
|
"@vitest/coverage-v8": "^4.0.18",
|
|
74
76
|
"eslint": "^9.39.1",
|
|
75
77
|
"ethers": "^6.0.0",
|
|
78
|
+
"jsdom": "^22.1.0",
|
|
76
79
|
"postcss-custom-media": "^12.0.1",
|
|
77
80
|
"postcss-import": "^16.1.1",
|
|
78
81
|
"postcss-mixins": "^12.1.2",
|
|
79
82
|
"react": "^19.2.0",
|
|
80
83
|
"react-dom": "^19.2.0",
|
|
81
|
-
"typescript": "5.
|
|
84
|
+
"typescript": "5.8.2",
|
|
82
85
|
"vite": "^6.3.5",
|
|
83
86
|
"vite-plugin-dts": "^4.5.4",
|
|
84
87
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
const tabAllTime = "全期間";
|
|
2
|
-
const tabQuest = "クエスト";
|
|
3
|
-
const tabEvent = "イベント";
|
|
4
|
-
const tabSprint = "スプリント";
|
|
5
|
-
const columnRank = "ランク";
|
|
6
|
-
const columnPosition = "順位";
|
|
7
|
-
const columnUser = "ユーザー";
|
|
8
|
-
const columnTasks = "タスク";
|
|
9
|
-
const columnInvitedUsers = "招待ユーザー";
|
|
10
|
-
const columnCurrentTier = "現在のティア";
|
|
11
|
-
const columnPoints = "ポイント";
|
|
12
|
-
const columnRewards = "報酬";
|
|
13
|
-
const statusOngoing = "進行中";
|
|
14
|
-
const statusEnded = "終了";
|
|
15
|
-
const statusUpcoming = "開始前";
|
|
16
|
-
const participants = "参加者";
|
|
17
|
-
const prizePool = "賞金プール";
|
|
18
|
-
const totalWinners = "総受賞者数";
|
|
19
|
-
const rewardRules = "報酬ルール";
|
|
20
|
-
const rewardRulesTitle = "報酬ルール";
|
|
21
|
-
const rewardRulesDesc = "報酬はリーダーボードのランキングに基づいて付与されます。ランキングはイベント中にユーザーが獲得した{pointsName}によって決定されます。";
|
|
22
|
-
const eventPeriod = "イベント期間";
|
|
23
|
-
const rewardDetails = "報酬詳細";
|
|
24
|
-
const eachReceives = "各自が{amount}を受け取ります";
|
|
25
|
-
const randomlySplit = "{amount}をランダムに分配";
|
|
26
|
-
const emptyTitle = "ランキングがありません";
|
|
27
|
-
const emptyDesc = "最初に参加してトップを目指しましょう!";
|
|
28
|
-
const page = "ページ";
|
|
29
|
-
const of = "/";
|
|
30
|
-
const previous = "前へ";
|
|
31
|
-
const next = "次へ";
|
|
32
|
-
const loading = "読み込み中...";
|
|
33
|
-
const error = "リーダーボードの読み込みに失敗しました";
|
|
34
|
-
const retry = "再試行";
|
|
35
|
-
const you = "あなた";
|
|
36
|
-
const unranked = "ランク外";
|
|
37
|
-
const na = "N/A";
|
|
38
|
-
const noData = "-";
|
|
39
|
-
const ja = {
|
|
40
|
-
tabAllTime,
|
|
41
|
-
tabQuest,
|
|
42
|
-
tabEvent,
|
|
43
|
-
tabSprint,
|
|
44
|
-
columnRank,
|
|
45
|
-
columnPosition,
|
|
46
|
-
columnUser,
|
|
47
|
-
columnTasks,
|
|
48
|
-
columnInvitedUsers,
|
|
49
|
-
columnCurrentTier,
|
|
50
|
-
columnPoints,
|
|
51
|
-
columnRewards,
|
|
52
|
-
statusOngoing,
|
|
53
|
-
statusEnded,
|
|
54
|
-
statusUpcoming,
|
|
55
|
-
participants,
|
|
56
|
-
prizePool,
|
|
57
|
-
totalWinners,
|
|
58
|
-
rewardRules,
|
|
59
|
-
rewardRulesTitle,
|
|
60
|
-
rewardRulesDesc,
|
|
61
|
-
eventPeriod,
|
|
62
|
-
rewardDetails,
|
|
63
|
-
eachReceives,
|
|
64
|
-
randomlySplit,
|
|
65
|
-
emptyTitle,
|
|
66
|
-
emptyDesc,
|
|
67
|
-
page,
|
|
68
|
-
of,
|
|
69
|
-
previous,
|
|
70
|
-
next,
|
|
71
|
-
loading,
|
|
72
|
-
error,
|
|
73
|
-
retry,
|
|
74
|
-
you,
|
|
75
|
-
unranked,
|
|
76
|
-
na,
|
|
77
|
-
noData
|
|
78
|
-
};
|
|
79
|
-
export {
|
|
80
|
-
columnCurrentTier,
|
|
81
|
-
columnInvitedUsers,
|
|
82
|
-
columnPoints,
|
|
83
|
-
columnPosition,
|
|
84
|
-
columnRank,
|
|
85
|
-
columnRewards,
|
|
86
|
-
columnTasks,
|
|
87
|
-
columnUser,
|
|
88
|
-
ja as default,
|
|
89
|
-
eachReceives,
|
|
90
|
-
emptyDesc,
|
|
91
|
-
emptyTitle,
|
|
92
|
-
error,
|
|
93
|
-
eventPeriod,
|
|
94
|
-
loading,
|
|
95
|
-
na,
|
|
96
|
-
next,
|
|
97
|
-
noData,
|
|
98
|
-
of,
|
|
99
|
-
page,
|
|
100
|
-
participants,
|
|
101
|
-
previous,
|
|
102
|
-
prizePool,
|
|
103
|
-
randomlySplit,
|
|
104
|
-
retry,
|
|
105
|
-
rewardDetails,
|
|
106
|
-
rewardRules,
|
|
107
|
-
rewardRulesDesc,
|
|
108
|
-
rewardRulesTitle,
|
|
109
|
-
statusEnded,
|
|
110
|
-
statusOngoing,
|
|
111
|
-
statusUpcoming,
|
|
112
|
-
tabAllTime,
|
|
113
|
-
tabEvent,
|
|
114
|
-
tabQuest,
|
|
115
|
-
tabSprint,
|
|
116
|
-
totalWinners,
|
|
117
|
-
unranked,
|
|
118
|
-
you
|
|
119
|
-
};
|