@orderly.network/affiliate 2.8.14 → 2.9.0-alpha.0
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/index.d.mts +33 -2
- package/dist/index.d.ts +33 -2
- package/dist/index.js +3088 -223
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3090 -227
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { createContext, useState, useEffect, useRef, useContext, useMemo } from 'react';
|
|
5
|
-
import { subDays, format, toDate } from 'date-fns';
|
|
6
|
-
import { useMutation, cleanStringStyle, useAccount, usePrivateQuery, noCacheConfig, useDaily, useMemoizedFn, useMediaQuery, useLocalStorage, useReferralRebateSummary, useRefereeRebateSummary, useRefereeInfo, useCheckReferralCode } from '@orderly.network/hooks';
|
|
1
|
+
import { createContext, useState, useEffect, useRef, useMemo, useContext, useCallback, Fragment as Fragment$1 } from 'react';
|
|
2
|
+
import { useMutation, cleanStringStyle, useAccount, usePrivateQuery, noCacheConfig, useDaily, useMemoizedFn, useMediaQuery, useReferralRebateSummary, useLocalStorage, useRefereeRebateSummary, useRefereeInfo, useCheckReferralCode } from '@orderly.network/hooks';
|
|
7
3
|
import { useAppContext } from '@orderly.network/react-app';
|
|
8
4
|
import { AccountStatusEnum, EMPTY_LIST } from '@orderly.network/types';
|
|
5
|
+
import { registerSimpleDialog, registerSimpleSheet, modal, useModal, SimpleDialog, TextField, inputFormatter, Flex, Text, cn, toast, Dialog, DialogContent, DialogTitle, Divider, Input as Input$1, Button, formatAddress, Box, Slider, WarningIcon, Grid, Spinner, Collapsible, CollapsibleContent, Select, Tabs, TabPanel, usePagination, DatePicker, TabsBase, TabsList, TabsTrigger, TabsContent, parseNumber, ListView, CopyIcon, DataTable, useScreen, Statistic, Tooltip, DialogTrigger, DialogHeader, DialogBody } from '@orderly.network/ui';
|
|
6
|
+
import { subDays, format, toDate } from 'date-fns';
|
|
9
7
|
import { Decimal, commify, commifyOptional } from '@orderly.network/utils';
|
|
8
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
import { useTranslation, Trans, i18n } from '@orderly.network/i18n';
|
|
10
|
+
import { AuthGuard, AuthGuardDataTable, useAuthStatus, AuthStatusEnum } from '@orderly.network/ui-connector';
|
|
11
|
+
import { Scaffold, SideBar, useScaffoldContext } from '@orderly.network/ui-scaffold';
|
|
10
12
|
import { VolBarChart } from '@orderly.network/chart';
|
|
11
|
-
import { AuthGuardDataTable, useAuthStatus, AuthStatusEnum, AuthGuard } from '@orderly.network/ui-connector';
|
|
12
|
-
import { Scaffold, SideBar } from '@orderly.network/ui-scaffold';
|
|
13
13
|
|
|
14
14
|
var __defProp = Object.defineProperty;
|
|
15
15
|
var __export = (target, all) => {
|
|
@@ -25,67 +25,6 @@ __export(dashboard_exports, {
|
|
|
25
25
|
HomePage: () => HomePage,
|
|
26
26
|
TraderPage: () => TraderPage
|
|
27
27
|
});
|
|
28
|
-
var AffiliateIcon = (props) => {
|
|
29
|
-
const { size = 16, className, ...rest } = props;
|
|
30
|
-
return /* @__PURE__ */ jsxs(
|
|
31
|
-
"svg",
|
|
32
|
-
{
|
|
33
|
-
width: size,
|
|
34
|
-
height: size,
|
|
35
|
-
viewBox: "0 0 16 16",
|
|
36
|
-
fill: "#fff",
|
|
37
|
-
fillOpacity: ".98",
|
|
38
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
39
|
-
className: props.className,
|
|
40
|
-
...rest,
|
|
41
|
-
children: [
|
|
42
|
-
/* @__PURE__ */ jsx("path", { d: "M8 1.302c-3.683 0-6.655 2.985-6.667 6.667-.013 3.676 2.987 6.68 6.666 6.687s6.674-3.037 6.667-6.687c-.007-3.682-2.985-6.667-6.667-6.667m0 1.333a5.333 5.333 0 0 1 5.333 5.334c0 1.5-.625 2.852-1.622 3.821-.49-1.062-1.545-1.821-2.753-1.821H7.04c-1.207 0-2.259.75-2.75 1.812A5.3 5.3 0 0 1 2.666 7.97a5.333 5.333 0 0 1 5.333-5.334M8 3.97a2.667 2.667 0 1 0 0 5.333A2.667 2.667 0 0 0 8 3.97" }),
|
|
43
|
-
/* @__PURE__ */ jsx(
|
|
44
|
-
"path",
|
|
45
|
-
{
|
|
46
|
-
d: "M16 12.667a3.333 3.333 0 1 1-6.667 0 3.333 3.333 0 0 1 6.667 0",
|
|
47
|
-
fill: "#1828C3"
|
|
48
|
-
}
|
|
49
|
-
),
|
|
50
|
-
/* @__PURE__ */ jsx("path", { d: "M11.917 11.433a.917.917 0 0 0-.917.917c0 .53.302 1.031.802 1.49a4.6 4.6 0 0 0 .713.53l.068.043c.05.027.117.027.167 0l.068-.042q.08-.05.177-.115c.182-.123.366-.26.536-.416.5-.459.802-.96.802-1.49a.917.917 0 0 0-.917-.917.97.97 0 0 0-.744.386.95.95 0 0 0-.756-.386" })
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
var TraderIcon = (props) => {
|
|
56
|
-
const { size = 16, className, ...rest } = props;
|
|
57
|
-
return /* @__PURE__ */ jsxs(
|
|
58
|
-
"svg",
|
|
59
|
-
{
|
|
60
|
-
width: size,
|
|
61
|
-
height: size,
|
|
62
|
-
viewBox: "0 0 16 16",
|
|
63
|
-
fill: "white",
|
|
64
|
-
fillOpacity: "0.36",
|
|
65
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
66
|
-
className: props.className,
|
|
67
|
-
...rest,
|
|
68
|
-
children: [
|
|
69
|
-
/* @__PURE__ */ jsx("path", { d: "M7.99929 1.30212C4.31735 1.30212 1.34509 4.28679 1.33262 7.96878C1.32015 11.6454 4.32042 14.6488 7.99929 14.6561C11.6782 14.6634 14.6726 11.6194 14.666 7.96878C14.6593 4.28679 11.6812 1.30212 7.99929 1.30212ZM7.99929 2.63546C10.9448 2.63546 13.3326 5.02345 13.3326 7.96878C13.3326 9.46878 12.7078 10.8208 11.7112 11.7901C11.2202 10.7281 10.1656 9.96878 8.95762 9.96878C8.71802 9.96878 7.28042 9.96878 7.04095 9.96878C5.83369 9.96878 4.78215 10.7188 4.29095 11.7814C3.29429 10.8121 2.66595 9.46878 2.66595 7.96878C2.66595 5.02345 5.05375 2.63546 7.99929 2.63546ZM7.99929 3.96879C6.52649 3.96879 5.33255 5.16279 5.33262 6.63545C5.33262 8.10812 6.52649 9.30212 7.99929 9.30212C9.47202 9.30212 10.666 8.10812 10.666 6.63545C10.666 5.16279 9.47202 3.96879 7.99929 3.96879Z" }),
|
|
70
|
-
/* @__PURE__ */ jsx(
|
|
71
|
-
"path",
|
|
72
|
-
{
|
|
73
|
-
d: "M16 12.6667C16 14.5076 14.5076 16 12.6666 16C10.8257 16 9.33331 14.5076 9.33331 12.6667C9.33331 10.8257 10.8257 9.33333 12.6666 9.33333C14.5076 9.33333 16 10.8257 16 12.6667Z",
|
|
74
|
-
fill: "#005A4F"
|
|
75
|
-
}
|
|
76
|
-
),
|
|
77
|
-
/* @__PURE__ */ jsx(
|
|
78
|
-
"path",
|
|
79
|
-
{
|
|
80
|
-
d: "M14.3325 13.3345C14.3325 13.2918 14.3182 13.2473 14.2857 13.2147L13.6658 12.6002L13.4315 12.8345L13.7595 13.1678H11.3325C11.2405 13.1678 11.1658 13.2425 11.1658 13.3345C11.1658 13.4265 11.2405 13.5012 11.3325 13.5012H13.7595L13.4315 13.8345L13.6658 14.0688L14.2857 13.4543C14.3182 13.4217 14.3325 13.3772 14.3325 13.3345ZM14.1658 12.0012C14.1658 11.9092 14.0912 11.8345 13.9992 11.8345H11.572L11.9002 11.5012L11.6658 11.2668L11.046 11.8813C10.981 11.9465 10.981 12.0558 11.046 12.121L11.6658 12.7355L11.9002 12.5012L11.572 12.1678H13.9992C14.0912 12.1678 14.1658 12.0932 14.1658 12.0012Z",
|
|
81
|
-
fill: "white",
|
|
82
|
-
fillOpacity: "0.98"
|
|
83
|
-
}
|
|
84
|
-
)
|
|
85
|
-
]
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
28
|
var TabTypes = /* @__PURE__ */ ((TabTypes2) => {
|
|
90
29
|
TabTypes2["affiliate"] = "affiliate";
|
|
91
30
|
TabTypes2["trader"] = "trader";
|
|
@@ -97,6 +36,76 @@ var ReferralContext = createContext(
|
|
|
97
36
|
var useReferralContext = () => {
|
|
98
37
|
return useContext(ReferralContext);
|
|
99
38
|
};
|
|
39
|
+
var useVolumePrerequisite = () => {
|
|
40
|
+
return usePrivateQuery(
|
|
41
|
+
"/v1/referral/multi_level/volume_prerequisite",
|
|
42
|
+
{
|
|
43
|
+
revalidateOnFocus: false
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
var useMaxRebateRate = () => {
|
|
48
|
+
return usePrivateQuery(
|
|
49
|
+
"/v1/referral/multi_level/max_rebate_rate",
|
|
50
|
+
{
|
|
51
|
+
revalidateOnFocus: false
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
var useMultiLevelRebateInfo = () => {
|
|
56
|
+
return usePrivateQuery(
|
|
57
|
+
"/v1/referral/multi_level/rebate_info",
|
|
58
|
+
{
|
|
59
|
+
errorRetryCount: 0,
|
|
60
|
+
revalidateOnFocus: false
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
var useMultiLevelStatistics = (time_range) => {
|
|
65
|
+
return usePrivateQuery(
|
|
66
|
+
`/v1/referral/multi_level/statistics?time_range=${time_range}`,
|
|
67
|
+
{
|
|
68
|
+
revalidateOnFocus: false
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/hooks/useMultiLevelReferralData.ts
|
|
74
|
+
var useMultiLevelReferralData = () => {
|
|
75
|
+
const { data: volumePrerequisite, isLoading: volumePrerequisiteLoading } = useVolumePrerequisite();
|
|
76
|
+
const { data: maxRebateRateRes, isLoading: maxRebateRateLoading } = useMaxRebateRate();
|
|
77
|
+
const {
|
|
78
|
+
data: multiLevelRebateInfoRes,
|
|
79
|
+
mutate: multiLevelRebateInfoMutate,
|
|
80
|
+
isLoading: multiLevelRebateInfoLoading
|
|
81
|
+
} = useMultiLevelRebateInfo();
|
|
82
|
+
const isMultiLevelReferralUnlocked = volumePrerequisite && volumePrerequisite.current_volume >= volumePrerequisite.required_volume;
|
|
83
|
+
const isMultiLevelEnabled = !!maxRebateRateRes;
|
|
84
|
+
const maxRebateRate = maxRebateRateRes?.max_rebate_rate;
|
|
85
|
+
const multiLevelRebateInfo = useMemo(() => {
|
|
86
|
+
if (!multiLevelRebateInfoRes) return;
|
|
87
|
+
const {
|
|
88
|
+
default_referee_rebate_rate: referee_rebate_rate,
|
|
89
|
+
max_rebate_rate
|
|
90
|
+
} = multiLevelRebateInfoRes;
|
|
91
|
+
const referrer_rebate_rate = new Decimal(max_rebate_rate || 0).sub(referee_rebate_rate || 0).toNumber();
|
|
92
|
+
return {
|
|
93
|
+
...multiLevelRebateInfoRes,
|
|
94
|
+
referee_rebate_rate,
|
|
95
|
+
referrer_rebate_rate
|
|
96
|
+
};
|
|
97
|
+
}, [multiLevelRebateInfoRes, maxRebateRate]);
|
|
98
|
+
const isLoading = volumePrerequisiteLoading || maxRebateRateLoading || multiLevelRebateInfoLoading;
|
|
99
|
+
return {
|
|
100
|
+
volumePrerequisite,
|
|
101
|
+
maxRebateRate,
|
|
102
|
+
multiLevelRebateInfo,
|
|
103
|
+
isMultiLevelEnabled,
|
|
104
|
+
isMultiLevelReferralUnlocked,
|
|
105
|
+
multiLevelRebateInfoMutate,
|
|
106
|
+
isLoading
|
|
107
|
+
};
|
|
108
|
+
};
|
|
100
109
|
var ReferralProvider = (props) => {
|
|
101
110
|
const {
|
|
102
111
|
becomeAnAffiliateUrl = "https://orderly.network/",
|
|
@@ -117,15 +126,15 @@ var ReferralProvider = (props) => {
|
|
|
117
126
|
mutate: referralInfoMutate,
|
|
118
127
|
isLoading
|
|
119
128
|
} = usePrivateQuery("/v1/referral/info", {
|
|
120
|
-
revalidateOnFocus:
|
|
129
|
+
revalidateOnFocus: false,
|
|
121
130
|
errorRetryCount: 3,
|
|
122
131
|
...noCacheConfig
|
|
123
132
|
});
|
|
124
133
|
const { data: generateCode, mutate: generateCodeMutate } = usePrivateQuery(
|
|
125
134
|
"/v1/referral/auto_referral/progress",
|
|
126
135
|
{
|
|
127
|
-
revalidateOnFocus:
|
|
128
|
-
errorRetryCount:
|
|
136
|
+
revalidateOnFocus: false,
|
|
137
|
+
errorRetryCount: 0,
|
|
129
138
|
formatter: (data2) => {
|
|
130
139
|
return {
|
|
131
140
|
code: data2.auto_referral_code,
|
|
@@ -135,6 +144,15 @@ var ReferralProvider = (props) => {
|
|
|
135
144
|
}
|
|
136
145
|
}
|
|
137
146
|
);
|
|
147
|
+
const {
|
|
148
|
+
volumePrerequisite,
|
|
149
|
+
multiLevelRebateInfo,
|
|
150
|
+
isMultiLevelEnabled,
|
|
151
|
+
isMultiLevelReferralUnlocked,
|
|
152
|
+
multiLevelRebateInfoMutate,
|
|
153
|
+
maxRebateRate,
|
|
154
|
+
isLoading: isMultiLevelLoading
|
|
155
|
+
} = useMultiLevelReferralData();
|
|
138
156
|
const [showHome, setShowHome] = useState(isLoading);
|
|
139
157
|
useEffect(() => {
|
|
140
158
|
setShowHome(true);
|
|
@@ -144,7 +162,7 @@ var ReferralProvider = (props) => {
|
|
|
144
162
|
endDate: subDays(/* @__PURE__ */ new Date(), 90)
|
|
145
163
|
});
|
|
146
164
|
const { data: volumeStatistics, mutate: volumeStatisticsMutate } = usePrivateQuery("/v1/volume/user/stats", {
|
|
147
|
-
revalidateOnFocus:
|
|
165
|
+
revalidateOnFocus: false
|
|
148
166
|
});
|
|
149
167
|
const isAffiliate = useMemo(() => {
|
|
150
168
|
return (data?.referrer_info?.referral_codes?.length || 0) > 0;
|
|
@@ -205,64 +223,2932 @@ var ReferralProvider = (props) => {
|
|
|
205
223
|
memoMutate();
|
|
206
224
|
}, 1e3);
|
|
207
225
|
}
|
|
208
|
-
return () => {
|
|
209
|
-
if (timerRef.current) {
|
|
210
|
-
clearTimeout(timerRef.current);
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
}, [memoMutate, state.status]);
|
|
214
|
-
const memoizedValue = useMemo(() => {
|
|
226
|
+
return () => {
|
|
227
|
+
if (timerRef.current) {
|
|
228
|
+
clearTimeout(timerRef.current);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}, [memoMutate, state.status]);
|
|
232
|
+
const memoizedValue = useMemo(() => {
|
|
233
|
+
return {
|
|
234
|
+
generateCode,
|
|
235
|
+
showHome,
|
|
236
|
+
referralInfo: data,
|
|
237
|
+
isAffiliate,
|
|
238
|
+
isTrader,
|
|
239
|
+
tab,
|
|
240
|
+
becomeAnAffiliateUrl,
|
|
241
|
+
learnAffiliateUrl,
|
|
242
|
+
referralLinkUrl,
|
|
243
|
+
userVolume,
|
|
244
|
+
dailyVolume,
|
|
245
|
+
chartConfig,
|
|
246
|
+
overwrite,
|
|
247
|
+
isLoading: isLoading || isMultiLevelLoading,
|
|
248
|
+
wrongNetwork,
|
|
249
|
+
disabledConnect,
|
|
250
|
+
setShowHome,
|
|
251
|
+
setTab,
|
|
252
|
+
mutate: memoMutate,
|
|
253
|
+
onBecomeAnAffiliate,
|
|
254
|
+
bindReferralCodeState,
|
|
255
|
+
onLearnAffiliate,
|
|
256
|
+
showReferralPage,
|
|
257
|
+
splashPage,
|
|
258
|
+
volumePrerequisite,
|
|
259
|
+
multiLevelRebateInfo,
|
|
260
|
+
isMultiLevelEnabled,
|
|
261
|
+
isMultiLevelReferralUnlocked,
|
|
262
|
+
multiLevelRebateInfoMutate,
|
|
263
|
+
maxRebateRate
|
|
264
|
+
};
|
|
265
|
+
}, [
|
|
266
|
+
becomeAnAffiliateUrl,
|
|
267
|
+
chartConfig,
|
|
268
|
+
dailyVolume,
|
|
269
|
+
data,
|
|
270
|
+
disabledConnect,
|
|
271
|
+
generateCode,
|
|
272
|
+
isAffiliate,
|
|
273
|
+
isLoading,
|
|
274
|
+
isTrader,
|
|
275
|
+
learnAffiliateUrl,
|
|
276
|
+
overwrite,
|
|
277
|
+
referralLinkUrl,
|
|
278
|
+
showHome,
|
|
279
|
+
tab,
|
|
280
|
+
userVolume,
|
|
281
|
+
wrongNetwork,
|
|
282
|
+
onBecomeAnAffiliate,
|
|
283
|
+
bindReferralCodeState,
|
|
284
|
+
onLearnAffiliate,
|
|
285
|
+
showReferralPage,
|
|
286
|
+
splashPage,
|
|
287
|
+
memoMutate,
|
|
288
|
+
volumePrerequisite,
|
|
289
|
+
multiLevelRebateInfo,
|
|
290
|
+
isMultiLevelEnabled,
|
|
291
|
+
isMultiLevelReferralUnlocked,
|
|
292
|
+
multiLevelRebateInfoMutate,
|
|
293
|
+
maxRebateRate,
|
|
294
|
+
isMultiLevelLoading
|
|
295
|
+
]);
|
|
296
|
+
return /* @__PURE__ */ jsx(ReferralContext.Provider, { value: memoizedValue, children });
|
|
297
|
+
};
|
|
298
|
+
var Faq = () => {
|
|
299
|
+
const { t } = useTranslation();
|
|
300
|
+
const faqItemsData = useMemo(() => {
|
|
301
|
+
return [
|
|
302
|
+
{
|
|
303
|
+
id: "faq-1",
|
|
304
|
+
question: t("affiliate.faq.question1"),
|
|
305
|
+
answer: t("affiliate.faq.answer1")
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: "faq-2",
|
|
309
|
+
question: t("affiliate.faq.question2"),
|
|
310
|
+
answer: t("affiliate.faq.answer2")
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
id: "faq-3",
|
|
314
|
+
question: t("affiliate.faq.question3"),
|
|
315
|
+
answer: t("affiliate.faq.answer3")
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
id: "faq-4",
|
|
319
|
+
question: t("affiliate.faq.question4"),
|
|
320
|
+
answer: t("affiliate.faq.answer4")
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
id: "faq-5",
|
|
324
|
+
question: t("affiliate.faq.question5"),
|
|
325
|
+
answer: t("affiliate.faq.answer5")
|
|
326
|
+
}
|
|
327
|
+
];
|
|
328
|
+
}, [t]);
|
|
329
|
+
const [expandedItems, setExpandedItems] = useState(/* @__PURE__ */ new Set());
|
|
330
|
+
const toggleItem = useCallback((id) => {
|
|
331
|
+
setExpandedItems((prev) => {
|
|
332
|
+
const newSet = new Set(prev);
|
|
333
|
+
if (newSet.has(id)) {
|
|
334
|
+
newSet.delete(id);
|
|
335
|
+
} else {
|
|
336
|
+
newSet.add(id);
|
|
337
|
+
}
|
|
338
|
+
return newSet;
|
|
339
|
+
});
|
|
340
|
+
}, []);
|
|
341
|
+
const faqItems = useMemo(() => {
|
|
342
|
+
return faqItemsData.map((item) => ({
|
|
343
|
+
...item,
|
|
344
|
+
expanded: expandedItems.has(item.id)
|
|
345
|
+
}));
|
|
346
|
+
}, [faqItemsData, expandedItems]);
|
|
347
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
348
|
+
/* @__PURE__ */ jsx(Text, { className: "oui-text-[32px]", children: t("affiliate.faq.title") }),
|
|
349
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", itemAlign: "stretch", gap: 0, children: faqItems.map((item, index) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
350
|
+
/* @__PURE__ */ jsx(
|
|
351
|
+
Collapsible,
|
|
352
|
+
{
|
|
353
|
+
open: item.expanded,
|
|
354
|
+
onOpenChange: () => toggleItem(item.id),
|
|
355
|
+
children: /* @__PURE__ */ jsxs(
|
|
356
|
+
Flex,
|
|
357
|
+
{
|
|
358
|
+
direction: "column",
|
|
359
|
+
className: "oui-cursor-pointer oui-py-4",
|
|
360
|
+
itemAlign: "stretch",
|
|
361
|
+
onClick: () => toggleItem(item.id),
|
|
362
|
+
children: [
|
|
363
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "between", itemAlign: "center", gap: 4, children: [
|
|
364
|
+
/* @__PURE__ */ jsx(Flex, { gap: 2, itemAlign: "center", className: "oui-flex-1", children: /* @__PURE__ */ jsx(Text, { size: "2xl", weight: "semibold", children: `${index + 1}. ${item.question}` }) }),
|
|
365
|
+
/* @__PURE__ */ jsx(ChevronIcon, { expanded: item.expanded })
|
|
366
|
+
] }),
|
|
367
|
+
/* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx(
|
|
368
|
+
Box,
|
|
369
|
+
{
|
|
370
|
+
className: "oui-pt-3 oui-text-base-contrast-54",
|
|
371
|
+
dangerouslySetInnerHTML: { __html: item.answer }
|
|
372
|
+
}
|
|
373
|
+
) })
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
}
|
|
378
|
+
),
|
|
379
|
+
index < faqItems.length - 1 && /* @__PURE__ */ jsx("div", { className: "oui-my-4 oui-h-px oui-bg-line-6" })
|
|
380
|
+
] }, item.id)) })
|
|
381
|
+
] });
|
|
382
|
+
};
|
|
383
|
+
var ChevronIcon = ({ expanded }) => /* @__PURE__ */ jsx(
|
|
384
|
+
"svg",
|
|
385
|
+
{
|
|
386
|
+
width: "24",
|
|
387
|
+
height: "24",
|
|
388
|
+
viewBox: "0 0 16 16",
|
|
389
|
+
fill: "none",
|
|
390
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
391
|
+
className: `oui-transition-transform oui-duration-200 ${expanded ? "oui-rotate-180" : ""}`,
|
|
392
|
+
children: /* @__PURE__ */ jsx(
|
|
393
|
+
"path",
|
|
394
|
+
{
|
|
395
|
+
d: "M4 6L8 10L12 6",
|
|
396
|
+
stroke: "currentColor",
|
|
397
|
+
strokeWidth: "2",
|
|
398
|
+
strokeLinecap: "round",
|
|
399
|
+
strokeLinejoin: "round",
|
|
400
|
+
className: "oui-text-base-contrast-54"
|
|
401
|
+
}
|
|
402
|
+
)
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
var useReferralCode = () => {
|
|
406
|
+
const [doCreateReferralCode, { isMutating: isCreateMutating }] = useMutation(
|
|
407
|
+
"/v1/referral/multi_level/claim_code"
|
|
408
|
+
);
|
|
409
|
+
const [doEditReferralCode, { isMutating: isEditMutating }] = useMutation(
|
|
410
|
+
"/v1/referral/edit_referral_code"
|
|
411
|
+
);
|
|
412
|
+
const [doUpdateRebateRate, { isMutating: isUpdateRebateRateMutating }] = useMutation("/v1/referral/multi_level/rebate_rate/update");
|
|
413
|
+
const [doResetRebateRate, { isMutating: isResetRebateRateMutating }] = useMutation("/v1/referral/multi_level/rebate_rate/set_default");
|
|
414
|
+
const createReferralCode = async (params) => {
|
|
415
|
+
return doCreateReferralCode(params);
|
|
416
|
+
};
|
|
417
|
+
const editReferralCode = async (params) => {
|
|
418
|
+
return doEditReferralCode(params);
|
|
419
|
+
};
|
|
420
|
+
const updateRebateRate = async (params) => {
|
|
421
|
+
return doUpdateRebateRate(params);
|
|
422
|
+
};
|
|
423
|
+
const resetRebateRate = async (params) => {
|
|
424
|
+
return doResetRebateRate(params);
|
|
425
|
+
};
|
|
426
|
+
const isMutating = isCreateMutating || isEditMutating || isUpdateRebateRateMutating || isResetRebateRateMutating;
|
|
427
|
+
return {
|
|
428
|
+
createReferralCode,
|
|
429
|
+
editReferralCode,
|
|
430
|
+
updateRebateRate,
|
|
431
|
+
resetRebateRate,
|
|
432
|
+
isMutating
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
// src/pages/multiLevel/affiliate/referralCodeForm/referralCodeForm.script.ts
|
|
437
|
+
var useReferralCodeFormScript = (options) => {
|
|
438
|
+
const { type, referralCode, maxRebateRate, referrerRebateRate, accountId } = options;
|
|
439
|
+
const { t } = useTranslation();
|
|
440
|
+
const [newCode, setNewCode] = useState(referralCode || "");
|
|
441
|
+
const [isReview, setIsReview] = useState(false);
|
|
442
|
+
const maxRebatePercentage = useMemo(() => {
|
|
443
|
+
return new Decimal(maxRebateRate).mul(100).toNumber();
|
|
444
|
+
}, [maxRebateRate]);
|
|
445
|
+
const [referrerRebatePercentage, setReferrerRebatePercentage] = useState(
|
|
446
|
+
() => {
|
|
447
|
+
if (type === "create" /* Create */) {
|
|
448
|
+
return Math.ceil(maxRebatePercentage / 2);
|
|
449
|
+
}
|
|
450
|
+
if (referrerRebateRate) {
|
|
451
|
+
return new Decimal(referrerRebateRate).mul(100).toNumber();
|
|
452
|
+
}
|
|
453
|
+
return 0;
|
|
454
|
+
}
|
|
455
|
+
);
|
|
456
|
+
const {
|
|
457
|
+
createReferralCode,
|
|
458
|
+
editReferralCode,
|
|
459
|
+
updateRebateRate,
|
|
460
|
+
resetRebateRate,
|
|
461
|
+
isMutating
|
|
462
|
+
} = useReferralCode();
|
|
463
|
+
const refereeRebatePercentage = useMemo(() => {
|
|
464
|
+
return Math.max(
|
|
465
|
+
0,
|
|
466
|
+
new Decimal(maxRebatePercentage).sub(referrerRebatePercentage).toNumber()
|
|
467
|
+
);
|
|
468
|
+
}, [referrerRebatePercentage]);
|
|
469
|
+
const codeChanged = useMemo(() => {
|
|
470
|
+
return newCode !== referralCode;
|
|
471
|
+
}, [newCode, referralCode]);
|
|
472
|
+
const rateChanged = useMemo(() => {
|
|
473
|
+
return new Decimal(referrerRebatePercentage).toNumber() !== new Decimal(referrerRebateRate || 0).mul(100).toNumber();
|
|
474
|
+
}, [referrerRebatePercentage, referrerRebateRate, newCode]);
|
|
475
|
+
const handleError = (err) => {
|
|
476
|
+
toast.error(err?.message || t("common.somethingWentWrong"));
|
|
477
|
+
};
|
|
478
|
+
const handleResult = (res) => {
|
|
479
|
+
if (res.success) {
|
|
480
|
+
options.onSuccess?.();
|
|
481
|
+
toast.success(t("affiliate.confirmChanges.success"));
|
|
482
|
+
options.close?.();
|
|
483
|
+
} else {
|
|
484
|
+
toast.error(res.message);
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
const onEdit = async () => {
|
|
488
|
+
const editReferralCodeParams = {
|
|
489
|
+
current_referral_code: referralCode,
|
|
490
|
+
new_referral_code: newCode
|
|
491
|
+
};
|
|
492
|
+
const updateRebateRateParams = {
|
|
493
|
+
referee_rebate_rate: new Decimal(refereeRebatePercentage).div(100).toNumber(),
|
|
494
|
+
account_ids: accountId ? [accountId] : void 0
|
|
495
|
+
};
|
|
496
|
+
try {
|
|
497
|
+
if (codeChanged && rateChanged) {
|
|
498
|
+
const codeRes = await editReferralCode(editReferralCodeParams);
|
|
499
|
+
if (!codeRes.success) {
|
|
500
|
+
toast.error(codeRes.message);
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const rateRes = await updateRebateRate(updateRebateRateParams);
|
|
504
|
+
handleResult(rateRes);
|
|
505
|
+
} else if (codeChanged) {
|
|
506
|
+
const res = await editReferralCode(editReferralCodeParams);
|
|
507
|
+
handleResult(res);
|
|
508
|
+
} else if (rateChanged) {
|
|
509
|
+
const res = await updateRebateRate(updateRebateRateParams);
|
|
510
|
+
handleResult(res);
|
|
511
|
+
}
|
|
512
|
+
} catch (err) {
|
|
513
|
+
handleError(err);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
const onCreate = async () => {
|
|
517
|
+
try {
|
|
518
|
+
const referee_rebate_rate = new Decimal(refereeRebatePercentage).div(100).toNumber();
|
|
519
|
+
const res = await createReferralCode({ referee_rebate_rate });
|
|
520
|
+
if (res.success) {
|
|
521
|
+
toast.success(t("affiliate.referralCode.create.success"));
|
|
522
|
+
options.onSuccess?.();
|
|
523
|
+
options.close?.();
|
|
524
|
+
} else {
|
|
525
|
+
toast.error(res.message);
|
|
526
|
+
}
|
|
527
|
+
} catch (err) {
|
|
528
|
+
handleError(err);
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
const onReset = async () => {
|
|
532
|
+
try {
|
|
533
|
+
const res = await resetRebateRate({ account_ids: [accountId] });
|
|
534
|
+
handleResult(res);
|
|
535
|
+
} catch (err) {
|
|
536
|
+
handleError(err);
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
const onClick = () => {
|
|
540
|
+
switch (type) {
|
|
541
|
+
case "create" /* Create */:
|
|
542
|
+
onCreate();
|
|
543
|
+
break;
|
|
544
|
+
case "edit" /* Edit */:
|
|
545
|
+
if (isReview) {
|
|
546
|
+
onEdit();
|
|
547
|
+
} else {
|
|
548
|
+
setIsReview(true);
|
|
549
|
+
}
|
|
550
|
+
break;
|
|
551
|
+
case "reset" /* Reset */:
|
|
552
|
+
onReset();
|
|
553
|
+
break;
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
const buttonDisabled = type === "edit" /* Edit */ && !codeChanged && !rateChanged;
|
|
557
|
+
return {
|
|
558
|
+
onClick,
|
|
559
|
+
maxRebatePercentage,
|
|
560
|
+
referrerRebatePercentage,
|
|
561
|
+
setReferrerRebatePercentage,
|
|
562
|
+
refereeRebatePercentage,
|
|
563
|
+
isMutating,
|
|
564
|
+
newCode,
|
|
565
|
+
setNewCode,
|
|
566
|
+
isReview,
|
|
567
|
+
buttonDisabled,
|
|
568
|
+
onReset
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
var GiftIcon = (props) => {
|
|
572
|
+
const { size = 16, className, ...rest } = props;
|
|
573
|
+
return /* @__PURE__ */ jsx(
|
|
574
|
+
"svg",
|
|
575
|
+
{
|
|
576
|
+
width: size,
|
|
577
|
+
height: size,
|
|
578
|
+
viewBox: "0 0 16 16",
|
|
579
|
+
fill: "none",
|
|
580
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
581
|
+
className,
|
|
582
|
+
...rest,
|
|
583
|
+
children: /* @__PURE__ */ jsx(
|
|
584
|
+
"path",
|
|
585
|
+
{
|
|
586
|
+
d: "M5.99902 1.99377C4.52636 1.99377 3.33236 3.18777 3.33236 4.66044H2.66569C2.29769 4.66044 1.99902 4.9591 1.99902 5.3271C1.99902 5.66044 1.99902 7.66043 1.99902 7.99377C1.99902 8.36177 2.29769 8.66043 2.66569 8.66043V11.3271C2.66569 12.7998 3.85969 13.9938 5.33236 13.9938H10.6657C12.1384 13.9938 13.3324 12.7998 13.3324 11.3271V8.66043C13.7004 8.66043 13.999 8.36177 13.999 7.99377V5.3271C13.999 4.9591 13.7004 4.66044 13.3324 4.66044H12.6657C12.6657 3.18777 11.4717 1.99377 9.99902 1.99377C9.19169 1.99377 8.48836 2.36444 7.99902 2.93111C7.50969 2.36444 6.80636 1.99377 5.99902 1.99377ZM5.99902 3.32711C6.73569 3.32711 7.33236 3.92377 7.33236 4.66044H4.66569C4.66569 3.92377 5.26236 3.32711 5.99902 3.32711ZM9.99902 3.32711C10.7357 3.32711 11.3324 3.92377 11.3324 4.66044H8.66569C8.66569 3.92377 9.26236 3.32711 9.99902 3.32711ZM3.33236 5.99377H12.6657V7.3271H3.33236C3.33236 6.84777 3.33236 6.4731 3.33236 5.99377ZM3.99902 8.66043H7.33236V12.6604H5.33236C4.59569 12.6604 3.99902 12.0638 3.99902 11.3271V8.66043ZM8.66569 8.66043H11.999V11.3271C11.999 12.0638 11.4024 12.6604 10.6657 12.6604H8.66569V8.66043Z",
|
|
587
|
+
fill: "currentColor"
|
|
588
|
+
}
|
|
589
|
+
)
|
|
590
|
+
}
|
|
591
|
+
);
|
|
592
|
+
};
|
|
593
|
+
var ReferralCodeForm = (props) => {
|
|
594
|
+
const { type, isReview } = props;
|
|
595
|
+
const { t } = useTranslation();
|
|
596
|
+
const isReset = type === "reset" /* Reset */;
|
|
597
|
+
const hasBoundReferee = !!props.directInvites && props.directInvites > 0;
|
|
598
|
+
const isEditingRefereeRebateRate = !!props.accountId;
|
|
599
|
+
const noCommissionAvailable = props.maxRebateRate === 0;
|
|
600
|
+
const { title, description, buttonText } = useMemo(() => {
|
|
601
|
+
switch (type) {
|
|
602
|
+
case "create" /* Create */:
|
|
603
|
+
return {
|
|
604
|
+
title: t("affiliate.referralCode.create.modal.title"),
|
|
605
|
+
description: t("affiliate.referralCode.create.warning"),
|
|
606
|
+
buttonText: t("affiliate.confirmAndGenerate")
|
|
607
|
+
};
|
|
608
|
+
case "edit" /* Edit */:
|
|
609
|
+
return {
|
|
610
|
+
title: isEditingRefereeRebateRate ? t("affiliate.refereeRebateRate.modal.title", {
|
|
611
|
+
accountId: formatAddress(props.accountId)
|
|
612
|
+
}) : t("affiliate.referralCode.edit.modal.title"),
|
|
613
|
+
description: isEditingRefereeRebateRate ? isReview ? t("affiliate.refereeRebateRate.review.warning") : t("affiliate.refereeRebateRate.edit.warning") : isReview ? t("affiliate.rebateRate.review.warning") : t("affiliate.rebateRate.edit.warning"),
|
|
614
|
+
buttonText: isReview ? t("affiliate.confirmChanges") : t("affiliate.review")
|
|
615
|
+
};
|
|
616
|
+
case "reset" /* Reset */:
|
|
617
|
+
return {
|
|
618
|
+
title: t("affiliate.resetRebateRate.modal.title"),
|
|
619
|
+
description: /* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, children: t("affiliate.resetRebateRate.modal.description", {
|
|
620
|
+
accountId: formatAddress(props.accountId)
|
|
621
|
+
}) }),
|
|
622
|
+
buttonText: t("common.reset")
|
|
623
|
+
};
|
|
624
|
+
default:
|
|
625
|
+
return {
|
|
626
|
+
title: "",
|
|
627
|
+
description: "",
|
|
628
|
+
buttonText: ""
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
}, [t, type, isEditingRefereeRebateRate, isReview, props.accountId]);
|
|
632
|
+
const titleView = /* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 3, children: [
|
|
633
|
+
/* @__PURE__ */ jsx(Text, { size: "base", intensity: 98, children: title }),
|
|
634
|
+
/* @__PURE__ */ jsx(Divider, { intensity: 8, className: "oui-w-full" })
|
|
635
|
+
] });
|
|
636
|
+
const descriptionView = /* @__PURE__ */ jsx(WarningBox, { children: description });
|
|
637
|
+
const referralCodeInput = /* @__PURE__ */ jsx(
|
|
638
|
+
ReferralCodeInput,
|
|
639
|
+
{
|
|
640
|
+
value: props.newCode,
|
|
641
|
+
onChange: props.setNewCode,
|
|
642
|
+
autoFocus: props.focusField === "referralCode" /* ReferralCode */,
|
|
643
|
+
disabled: isReview || hasBoundReferee
|
|
644
|
+
}
|
|
645
|
+
);
|
|
646
|
+
const commissionConfiguration = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
647
|
+
/* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, children: t("affiliate.commissionConfiguration") }),
|
|
648
|
+
!isReview && /* @__PURE__ */ jsxs(Text, { size: "2xs", intensity: 54, children: [
|
|
649
|
+
t("affiliate.totalCommissionAvailable"),
|
|
650
|
+
":",
|
|
651
|
+
" ",
|
|
652
|
+
/* @__PURE__ */ jsxs(Text, { className: "oui-text-warning", children: [
|
|
653
|
+
props.maxRebatePercentage,
|
|
654
|
+
"%"
|
|
655
|
+
] })
|
|
656
|
+
] })
|
|
657
|
+
] });
|
|
658
|
+
const rebateRateSlider = /* @__PURE__ */ jsx(
|
|
659
|
+
RebateRateSlider,
|
|
660
|
+
{
|
|
661
|
+
value: props.referrerRebatePercentage,
|
|
662
|
+
restValue: props.refereeRebatePercentage,
|
|
663
|
+
onChange: props.setReferrerRebatePercentage,
|
|
664
|
+
max: props.maxRebatePercentage,
|
|
665
|
+
disabled: noCommissionAvailable || isReview || isReset,
|
|
666
|
+
disabledIncrease: hasBoundReferee,
|
|
667
|
+
directBonusRebateRate: props.directBonusRebateRate,
|
|
668
|
+
noCommissionAvailable
|
|
669
|
+
}
|
|
670
|
+
);
|
|
671
|
+
const refereeInfo = /* @__PURE__ */ jsxs(Flex, { width: "100%", justify: "between", gap: 2, children: [
|
|
672
|
+
/* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, children: t("affiliate.referees") }),
|
|
673
|
+
/* @__PURE__ */ jsx(Text.formatted, { rule: "address", size: "2xs", intensity: 98, children: props.accountId })
|
|
674
|
+
] });
|
|
675
|
+
const noCommissionAvailableWarning = noCommissionAvailable && /* @__PURE__ */ jsx(Text, { size: "2xs", className: "oui-text-warning", children: isEditingRefereeRebateRate ? t("affiliate.rebateRate.noCommissionRate") : t("affiliate.rebateRate.noCommissionAvailable") });
|
|
676
|
+
const resetRebateRateLabel = /* @__PURE__ */ jsxs(Text, { size: "2xs", intensity: 98, className: "oui-text-start", children: [
|
|
677
|
+
t("affiliate.resetRebateRate.rateAfterReset"),
|
|
678
|
+
":"
|
|
679
|
+
] });
|
|
680
|
+
const buttons = /* @__PURE__ */ jsxs(Flex, { direction: "row", gap: 2, width: "100%", mt: 0, pt: 5, children: [
|
|
681
|
+
/* @__PURE__ */ jsx(
|
|
682
|
+
Button,
|
|
683
|
+
{
|
|
684
|
+
variant: "contained",
|
|
685
|
+
color: "gray",
|
|
686
|
+
fullWidth: true,
|
|
687
|
+
onClick: props.close,
|
|
688
|
+
size: "md",
|
|
689
|
+
children: t("common.cancel")
|
|
690
|
+
}
|
|
691
|
+
),
|
|
692
|
+
/* @__PURE__ */ jsx(
|
|
693
|
+
Button,
|
|
694
|
+
{
|
|
695
|
+
fullWidth: true,
|
|
696
|
+
onClick: props.onClick,
|
|
697
|
+
disabled: props.buttonDisabled || props.isMutating,
|
|
698
|
+
loading: props.isMutating,
|
|
699
|
+
size: "md",
|
|
700
|
+
children: buttonText
|
|
701
|
+
}
|
|
702
|
+
)
|
|
703
|
+
] });
|
|
704
|
+
const renderContent = () => {
|
|
705
|
+
switch (type) {
|
|
706
|
+
case "create" /* Create */:
|
|
707
|
+
return /* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 2, children: [
|
|
708
|
+
commissionConfiguration,
|
|
709
|
+
rebateRateSlider,
|
|
710
|
+
noCommissionAvailableWarning,
|
|
711
|
+
buttons
|
|
712
|
+
] });
|
|
713
|
+
case "edit" /* Edit */:
|
|
714
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
715
|
+
isEditingRefereeRebateRate ? refereeInfo : referralCodeInput,
|
|
716
|
+
/* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 2, children: [
|
|
717
|
+
commissionConfiguration,
|
|
718
|
+
rebateRateSlider,
|
|
719
|
+
noCommissionAvailableWarning,
|
|
720
|
+
buttons
|
|
721
|
+
] })
|
|
722
|
+
] });
|
|
723
|
+
case "reset" /* Reset */:
|
|
724
|
+
return /* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 2, children: [
|
|
725
|
+
resetRebateRateLabel,
|
|
726
|
+
rebateRateSlider,
|
|
727
|
+
buttons
|
|
728
|
+
] });
|
|
729
|
+
default:
|
|
730
|
+
return null;
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
return /* @__PURE__ */ jsxs(
|
|
734
|
+
Flex,
|
|
735
|
+
{
|
|
736
|
+
direction: "column",
|
|
737
|
+
itemAlign: "start",
|
|
738
|
+
gap: 6,
|
|
739
|
+
className: "oui-font-semibold",
|
|
740
|
+
children: [
|
|
741
|
+
titleView,
|
|
742
|
+
descriptionView,
|
|
743
|
+
renderContent()
|
|
744
|
+
]
|
|
745
|
+
}
|
|
746
|
+
);
|
|
747
|
+
};
|
|
748
|
+
var NoCommissionCard = (props) => {
|
|
749
|
+
const { t } = useTranslation();
|
|
750
|
+
const amount = props.directBonusRebateRate;
|
|
751
|
+
return /* @__PURE__ */ jsxs(
|
|
752
|
+
Flex,
|
|
753
|
+
{
|
|
754
|
+
direction: "column",
|
|
755
|
+
gap: 2,
|
|
756
|
+
mt: 2,
|
|
757
|
+
width: "100%",
|
|
758
|
+
p: 4,
|
|
759
|
+
r: "lg",
|
|
760
|
+
className: "oui-border oui-border-base-contrast/[0.08] oui-tracking-[0.03em]",
|
|
761
|
+
children: [
|
|
762
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "between", width: "100%", itemAlign: "center", children: [
|
|
763
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
764
|
+
/* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, children: t("affiliate.noCommissionCard.title") }),
|
|
765
|
+
/* @__PURE__ */ jsxs(Text, { size: "lg", className: "oui-text-primary-light oui-font-semibold", children: [
|
|
766
|
+
"+ ",
|
|
767
|
+
amount,
|
|
768
|
+
"%"
|
|
769
|
+
] })
|
|
770
|
+
] }),
|
|
771
|
+
/* @__PURE__ */ jsx(GiftIcon, { size: 24, className: "oui-shrink-0 oui-text-primary-light" })
|
|
772
|
+
] }),
|
|
773
|
+
/* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 98, className: "oui-leading-[15px]", children: t("affiliate.noCommissionCard.content", { amount }) })
|
|
774
|
+
]
|
|
775
|
+
}
|
|
776
|
+
);
|
|
777
|
+
};
|
|
778
|
+
var RebateRateSlider = (props) => {
|
|
779
|
+
const { t } = useTranslation();
|
|
780
|
+
const [maxValue] = useState(props.value);
|
|
781
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
782
|
+
!props.disabled && /* @__PURE__ */ jsx(Box, { width: "100%", my: 2, children: /* @__PURE__ */ jsx(
|
|
783
|
+
Slider,
|
|
784
|
+
{
|
|
785
|
+
min: 0,
|
|
786
|
+
max: props.max,
|
|
787
|
+
step: 1,
|
|
788
|
+
value: [props.value],
|
|
789
|
+
onValueChange: (value) => {
|
|
790
|
+
const newValue = value[0];
|
|
791
|
+
props.onChange(
|
|
792
|
+
props.disabledIncrease ? Math.min(newValue, maxValue) : newValue
|
|
793
|
+
);
|
|
794
|
+
},
|
|
795
|
+
classNames: {
|
|
796
|
+
range: "oui-bg-success-darken oui-h-2 oui-top-[0px]",
|
|
797
|
+
trackInner: "oui-bg-success-darken/30 oui-h-2 oui-top-[0px]",
|
|
798
|
+
thumb: "oui-border-[#d9d9d9] oui-bg-[#d9d9d9] oui-size-4"
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
) }),
|
|
802
|
+
/* @__PURE__ */ jsxs("div", { className: "oui-w-full", children: [
|
|
803
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "between", width: "100%", children: [
|
|
804
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", intensity: 54, children: t("affiliate.youKeep") }),
|
|
805
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", intensity: 54, children: t("affiliate.refereesGet") })
|
|
806
|
+
] }),
|
|
807
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "between", width: "100%", children: [
|
|
808
|
+
/* @__PURE__ */ jsxs(Text.formatted, { size: "lg", className: "oui-text-success-darken", children: [
|
|
809
|
+
props.value,
|
|
810
|
+
"%"
|
|
811
|
+
] }),
|
|
812
|
+
/* @__PURE__ */ jsxs(Text.formatted, { size: "lg", className: "oui-text-success-darken/50", children: [
|
|
813
|
+
props.restValue,
|
|
814
|
+
"%"
|
|
815
|
+
] })
|
|
816
|
+
] }),
|
|
817
|
+
props.noCommissionAvailable ? /* @__PURE__ */ jsx(
|
|
818
|
+
NoCommissionCard,
|
|
819
|
+
{
|
|
820
|
+
directBonusRebateRate: props.directBonusRebateRate
|
|
821
|
+
}
|
|
822
|
+
) : props.directBonusRebateRate != null && props.directBonusRebateRate > 0 && /* @__PURE__ */ jsxs(Flex, { gap: 2, mt: 2, width: "100%", children: [
|
|
823
|
+
/* @__PURE__ */ jsx(
|
|
824
|
+
GiftIcon,
|
|
825
|
+
{
|
|
826
|
+
size: 16,
|
|
827
|
+
className: "oui-text-base-contrast oui-mt-[1px]"
|
|
828
|
+
}
|
|
829
|
+
),
|
|
830
|
+
/* @__PURE__ */ jsx(
|
|
831
|
+
Text,
|
|
832
|
+
{
|
|
833
|
+
size: "base",
|
|
834
|
+
intensity: 54,
|
|
835
|
+
as: "span",
|
|
836
|
+
className: "oui-inline-flex oui-items-center oui-gap-1 oui-tracking-[0.03em]",
|
|
837
|
+
children: /* @__PURE__ */ jsx(
|
|
838
|
+
Trans,
|
|
839
|
+
{
|
|
840
|
+
i18nKey: "affiliate.extraBonusOnDirectReferrals",
|
|
841
|
+
values: { amount: props.directBonusRebateRate },
|
|
842
|
+
components: [/* @__PURE__ */ jsx(Text, { as: "span", color: "primaryLight" }, "0")]
|
|
843
|
+
}
|
|
844
|
+
)
|
|
845
|
+
}
|
|
846
|
+
)
|
|
847
|
+
] })
|
|
848
|
+
] })
|
|
849
|
+
] });
|
|
850
|
+
};
|
|
851
|
+
var ReferralCodeInput = (props) => {
|
|
852
|
+
const { t } = useTranslation();
|
|
853
|
+
const hasSetCursorToEnd = useRef(false);
|
|
854
|
+
return /* @__PURE__ */ jsx(
|
|
855
|
+
TextField,
|
|
856
|
+
{
|
|
857
|
+
type: "text",
|
|
858
|
+
fullWidth: true,
|
|
859
|
+
label: t("affiliate.referralCode.editCodeModal.label"),
|
|
860
|
+
value: props.value,
|
|
861
|
+
onChange: (e) => {
|
|
862
|
+
props.onChange(e.target.value);
|
|
863
|
+
},
|
|
864
|
+
onFocus: (e) => {
|
|
865
|
+
if (props.autoFocus && !hasSetCursorToEnd.current) {
|
|
866
|
+
hasSetCursorToEnd.current = true;
|
|
867
|
+
const input = e.target;
|
|
868
|
+
const len = input.value.length;
|
|
869
|
+
requestAnimationFrame(() => {
|
|
870
|
+
input.setSelectionRange(len, len);
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
formatters: [
|
|
875
|
+
inputFormatter.createRegexInputFormatter((value) => {
|
|
876
|
+
return String(value).replace(
|
|
877
|
+
/[a-z]/g,
|
|
878
|
+
(char) => char.toUpperCase()
|
|
879
|
+
);
|
|
880
|
+
}),
|
|
881
|
+
inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)
|
|
882
|
+
],
|
|
883
|
+
className: "oui-w-full",
|
|
884
|
+
classNames: {
|
|
885
|
+
label: "oui-text-base-contrast-54 oui-text-xs",
|
|
886
|
+
input: "placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"
|
|
887
|
+
},
|
|
888
|
+
maxLength: 10,
|
|
889
|
+
minLength: 4,
|
|
890
|
+
autoComplete: "off",
|
|
891
|
+
disabled: props.disabled,
|
|
892
|
+
autoFocus: props.autoFocus
|
|
893
|
+
}
|
|
894
|
+
);
|
|
895
|
+
};
|
|
896
|
+
var WarningBox = (props) => {
|
|
897
|
+
const { children } = props;
|
|
898
|
+
if (typeof children === "string") {
|
|
899
|
+
return /* @__PURE__ */ jsxs(
|
|
900
|
+
Flex,
|
|
901
|
+
{
|
|
902
|
+
className: "oui-bg-warning/10",
|
|
903
|
+
justify: "start",
|
|
904
|
+
itemAlign: "start",
|
|
905
|
+
gap: 1,
|
|
906
|
+
r: "lg",
|
|
907
|
+
p: 3,
|
|
908
|
+
children: [
|
|
909
|
+
/* @__PURE__ */ jsx(WarningIcon, { className: "oui-shrink-0 oui-text-warning" }),
|
|
910
|
+
/* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, className: "oui-text-warning", children })
|
|
911
|
+
]
|
|
912
|
+
}
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
return children;
|
|
916
|
+
};
|
|
917
|
+
var ReferralCodeFormWidget = (props) => {
|
|
918
|
+
const state = useReferralCodeFormScript(props);
|
|
919
|
+
return /* @__PURE__ */ jsx(ReferralCodeForm, { ...state, ...props });
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
// src/pages/multiLevel/affiliate/referralCodeForm/modal.ts
|
|
923
|
+
var ReferralCodeFormDialogId = "ReferralCodeFormDialogId";
|
|
924
|
+
var ReferralCodeFormSheetId = "ReferralCodeFormSheetId";
|
|
925
|
+
registerSimpleDialog(ReferralCodeFormDialogId, ReferralCodeFormWidget, {
|
|
926
|
+
size: "sm",
|
|
927
|
+
classNames: {
|
|
928
|
+
content: "oui-border oui-border-line-6",
|
|
929
|
+
body: "!oui-pt-3"
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
registerSimpleSheet(ReferralCodeFormSheetId, ReferralCodeFormWidget);
|
|
933
|
+
var TradingVolumeProgress = (props) => {
|
|
934
|
+
const { t } = useTranslation();
|
|
935
|
+
const { classNames } = props;
|
|
936
|
+
const { volumePrerequisite } = useReferralContext();
|
|
937
|
+
const { routerAdapter } = useScaffoldContext();
|
|
938
|
+
const { current_volume = 0, required_volume = 0 } = volumePrerequisite || {};
|
|
939
|
+
const progressPercentage = useMemo(() => {
|
|
940
|
+
if (required_volume === 0) return 0;
|
|
941
|
+
const percentage = new Decimal(current_volume).div(required_volume).mul(100).toNumber();
|
|
942
|
+
return Math.min(percentage, 100);
|
|
943
|
+
}, [current_volume, required_volume]);
|
|
944
|
+
const formatRequiredVolume = useMemo(() => {
|
|
945
|
+
return parseNumber(required_volume, {
|
|
946
|
+
rule: "price",
|
|
947
|
+
dp: 0
|
|
948
|
+
});
|
|
949
|
+
}, [required_volume]);
|
|
950
|
+
const gotoTrade = () => {
|
|
951
|
+
routerAdapter?.onRouteChange?.({
|
|
952
|
+
href: "/perp",
|
|
953
|
+
name: "Perp"
|
|
954
|
+
});
|
|
955
|
+
};
|
|
956
|
+
return /* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", gap: 4, className: classNames?.root, children: [
|
|
957
|
+
/* @__PURE__ */ jsx(
|
|
958
|
+
Text,
|
|
959
|
+
{
|
|
960
|
+
size: "sm",
|
|
961
|
+
intensity: 54,
|
|
962
|
+
className: cn("oui-text-center", classNames?.description),
|
|
963
|
+
children: t("affiliate.newReferralProgram.tradeUnlock.description", {
|
|
964
|
+
volume: formatRequiredVolume
|
|
965
|
+
})
|
|
966
|
+
}
|
|
967
|
+
),
|
|
968
|
+
/* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", gap: 2, children: [
|
|
969
|
+
/* @__PURE__ */ jsxs(
|
|
970
|
+
Flex,
|
|
971
|
+
{
|
|
972
|
+
width: "100%",
|
|
973
|
+
justify: "between",
|
|
974
|
+
className: "oui-text-2xs oui-text-base-contrast",
|
|
975
|
+
children: [
|
|
976
|
+
/* @__PURE__ */ jsx(Text, { children: t("common.current") }),
|
|
977
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
|
|
978
|
+
/* @__PURE__ */ jsx(Text.numeral, { rule: "price", dp: 0, children: current_volume }),
|
|
979
|
+
/* @__PURE__ */ jsx(
|
|
980
|
+
Text.numeral,
|
|
981
|
+
{
|
|
982
|
+
intensity: 54,
|
|
983
|
+
rule: "price",
|
|
984
|
+
dp: 0,
|
|
985
|
+
prefix: "/ ",
|
|
986
|
+
suffix: " USDC",
|
|
987
|
+
children: required_volume
|
|
988
|
+
}
|
|
989
|
+
)
|
|
990
|
+
] })
|
|
991
|
+
]
|
|
992
|
+
}
|
|
993
|
+
),
|
|
994
|
+
/* @__PURE__ */ jsx("div", { className: "oui-h-[8px] oui-w-full oui-rounded-full oui-bg-base-contrast-4", children: /* @__PURE__ */ jsx(
|
|
995
|
+
"div",
|
|
996
|
+
{
|
|
997
|
+
style: {
|
|
998
|
+
width: `${progressPercentage}%`
|
|
999
|
+
},
|
|
1000
|
+
className: cn(
|
|
1001
|
+
"oui-h-full oui-rounded-l-full oui-bg-primary-light",
|
|
1002
|
+
progressPercentage === 100 && "oui-rounded-r-full"
|
|
1003
|
+
)
|
|
1004
|
+
}
|
|
1005
|
+
) })
|
|
1006
|
+
] }),
|
|
1007
|
+
/* @__PURE__ */ jsx(Button, { size: "md", onClick: gotoTrade, ...props.buttonProps, children: t("affiliate.newReferralProgram.tradeUnlock") })
|
|
1008
|
+
] });
|
|
1009
|
+
};
|
|
1010
|
+
var Hero = () => {
|
|
1011
|
+
const { t } = useTranslation();
|
|
1012
|
+
const { state } = useAccount();
|
|
1013
|
+
const { wrongNetwork } = useAppContext();
|
|
1014
|
+
const status = state.status;
|
|
1015
|
+
const {
|
|
1016
|
+
isMultiLevelReferralUnlocked,
|
|
1017
|
+
isMultiLevelEnabled,
|
|
1018
|
+
multiLevelRebateInfo,
|
|
1019
|
+
multiLevelRebateInfoMutate,
|
|
1020
|
+
maxRebateRate
|
|
1021
|
+
} = useReferralContext();
|
|
1022
|
+
const onCreateReferralCode = () => {
|
|
1023
|
+
modal.show(ReferralCodeFormDialogId, {
|
|
1024
|
+
type: "create" /* Create */,
|
|
1025
|
+
maxRebateRate,
|
|
1026
|
+
directBonusRebateRate: 10,
|
|
1027
|
+
// Hardcoded value before API is ready
|
|
1028
|
+
onSuccess: () => {
|
|
1029
|
+
multiLevelRebateInfoMutate();
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
};
|
|
1033
|
+
const description = useMemo(() => {
|
|
1034
|
+
if (wrongNetwork) {
|
|
1035
|
+
return t("affiliate.wrongNetwork.description");
|
|
1036
|
+
}
|
|
1037
|
+
if (status === AccountStatusEnum.NotConnected) {
|
|
1038
|
+
return t("affiliate.newReferralProgram.description");
|
|
1039
|
+
}
|
|
1040
|
+
if (status > AccountStatusEnum.Connected && status < AccountStatusEnum.EnableTrading) {
|
|
1041
|
+
return t("affiliate.setUpAccount.description");
|
|
1042
|
+
}
|
|
1043
|
+
if (!isMultiLevelReferralUnlocked) {
|
|
1044
|
+
return "";
|
|
1045
|
+
}
|
|
1046
|
+
return t("affiliate.newReferralProgram.description");
|
|
1047
|
+
}, [t, wrongNetwork, status]);
|
|
1048
|
+
const renderContent = () => {
|
|
1049
|
+
if (!isMultiLevelReferralUnlocked) {
|
|
1050
|
+
return /* @__PURE__ */ jsx(
|
|
1051
|
+
TradingVolumeProgress,
|
|
1052
|
+
{
|
|
1053
|
+
classNames: {
|
|
1054
|
+
root: "oui-items-start",
|
|
1055
|
+
description: "!oui-text-start"
|
|
1056
|
+
},
|
|
1057
|
+
buttonProps: {
|
|
1058
|
+
size: "xl"
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
if (isMultiLevelEnabled && !multiLevelRebateInfo?.referral_code) {
|
|
1064
|
+
return /* @__PURE__ */ jsx(Button, { size: "lg", className: "oui-px-4", onClick: onCreateReferralCode, children: t("affiliate.referralCode.create") });
|
|
1065
|
+
}
|
|
1066
|
+
return "";
|
|
1067
|
+
};
|
|
1068
|
+
return /* @__PURE__ */ jsxs(
|
|
1069
|
+
Flex,
|
|
1070
|
+
{
|
|
1071
|
+
gap: 8,
|
|
1072
|
+
className: "oui-flex-col-reverse md:oui-flex-row",
|
|
1073
|
+
id: "oui-affiliate-landing-hero",
|
|
1074
|
+
itemAlign: "center",
|
|
1075
|
+
children: [
|
|
1076
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 6, className: "oui-flex-1", children: [
|
|
1077
|
+
/* @__PURE__ */ jsx(
|
|
1078
|
+
Flex,
|
|
1079
|
+
{
|
|
1080
|
+
direction: "column",
|
|
1081
|
+
gap: 3,
|
|
1082
|
+
itemAlign: "start",
|
|
1083
|
+
id: "oui-affiliate-landing-hero-title",
|
|
1084
|
+
children: /* @__PURE__ */ jsx(
|
|
1085
|
+
Text,
|
|
1086
|
+
{
|
|
1087
|
+
weight: "semibold",
|
|
1088
|
+
className: "oui-text-[32px] oui-leading-tight md:oui-text-[48px]",
|
|
1089
|
+
children: t("affiliate.landing.title")
|
|
1090
|
+
}
|
|
1091
|
+
)
|
|
1092
|
+
}
|
|
1093
|
+
),
|
|
1094
|
+
description && /* @__PURE__ */ jsx(Text, { size: "sm", intensity: 54, children: description }),
|
|
1095
|
+
/* @__PURE__ */ jsx(
|
|
1096
|
+
AuthGuard,
|
|
1097
|
+
{
|
|
1098
|
+
labels: {
|
|
1099
|
+
connectWallet: t("affiliate.connectWallet"),
|
|
1100
|
+
signin: t("affiliate.setUpAccount"),
|
|
1101
|
+
enableTrading: t("affiliate.setUpAccount")
|
|
1102
|
+
},
|
|
1103
|
+
children: renderContent()
|
|
1104
|
+
}
|
|
1105
|
+
)
|
|
1106
|
+
] }),
|
|
1107
|
+
/* @__PURE__ */ jsx(
|
|
1108
|
+
"img",
|
|
1109
|
+
{
|
|
1110
|
+
src: "https://oss.orderly.network/static/sdk/referral/network-diagram.png",
|
|
1111
|
+
alt: "Network diagram",
|
|
1112
|
+
className: "oui-size-[335px] oui-object-cover md:oui-size-[480px]",
|
|
1113
|
+
id: "oui-affiliate-landing-network-diagram"
|
|
1114
|
+
}
|
|
1115
|
+
)
|
|
1116
|
+
]
|
|
1117
|
+
}
|
|
1118
|
+
);
|
|
1119
|
+
};
|
|
1120
|
+
var StepCard = (props) => {
|
|
1121
|
+
const { step, icon, title, description } = props;
|
|
1122
|
+
return /* @__PURE__ */ jsxs(
|
|
1123
|
+
Flex,
|
|
1124
|
+
{
|
|
1125
|
+
direction: "column",
|
|
1126
|
+
gap: 3,
|
|
1127
|
+
r: "2xl",
|
|
1128
|
+
p: 5,
|
|
1129
|
+
itemAlign: "start",
|
|
1130
|
+
className: "oui-bg-base-9",
|
|
1131
|
+
children: [
|
|
1132
|
+
/* @__PURE__ */ jsx(
|
|
1133
|
+
Flex,
|
|
1134
|
+
{
|
|
1135
|
+
justify: "center",
|
|
1136
|
+
className: "oui-rounded-full oui-bg-base-7 lg:oui-justify-start",
|
|
1137
|
+
p: 3,
|
|
1138
|
+
width: 48,
|
|
1139
|
+
height: 48,
|
|
1140
|
+
itemAlign: "center",
|
|
1141
|
+
children: renderIcon(icon)
|
|
1142
|
+
}
|
|
1143
|
+
),
|
|
1144
|
+
/* @__PURE__ */ jsx(Text, { size: "xl", weight: "semibold", children: `${step}. ${title}` }),
|
|
1145
|
+
/* @__PURE__ */ jsx(Text, { intensity: 54, size: "sm", children: description })
|
|
1146
|
+
]
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1149
|
+
};
|
|
1150
|
+
var renderIcon = (iconType) => {
|
|
1151
|
+
switch (iconType) {
|
|
1152
|
+
case "wallet":
|
|
1153
|
+
return /* @__PURE__ */ jsx(WalletIcon, {});
|
|
1154
|
+
case "settings":
|
|
1155
|
+
return /* @__PURE__ */ jsx(SettingsIcon, {});
|
|
1156
|
+
case "rocket":
|
|
1157
|
+
return /* @__PURE__ */ jsx(RocketIcon, {});
|
|
1158
|
+
default:
|
|
1159
|
+
return null;
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
var WalletIcon = () => /* @__PURE__ */ jsx(
|
|
1163
|
+
"svg",
|
|
1164
|
+
{
|
|
1165
|
+
width: "24",
|
|
1166
|
+
height: "24",
|
|
1167
|
+
viewBox: "0 0 24 24",
|
|
1168
|
+
fill: "none",
|
|
1169
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1170
|
+
children: /* @__PURE__ */ jsx(
|
|
1171
|
+
"path",
|
|
1172
|
+
{
|
|
1173
|
+
d: "M7.006 2.93a4 4 0 0 0-4 4v10a4 4 0 0 0 4 4h10c1.552 0 3-1.448 3-3l-.004-1.163a3.025 3.025 0 0 0 2.004-2.837v-4c0-1.268-.822-2.428-1.994-2.815l-.006-1.185c0-1.553-1.448-3-3-3zm0 2h10c.448 0 1 .552 1 1v1h-3a3 3 0 0 0-3 3v4a3 3 0 0 0 3 3h3v1c0 .447-.552 1-1 1h-10a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2m8 4h4a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1m2 2a1 1 0 1 0 0 2 1 1 0 0 0 0-2",
|
|
1174
|
+
fill: "#fff",
|
|
1175
|
+
fillOpacity: ".54"
|
|
1176
|
+
}
|
|
1177
|
+
)
|
|
1178
|
+
}
|
|
1179
|
+
);
|
|
1180
|
+
var SettingsIcon = () => /* @__PURE__ */ jsx(
|
|
1181
|
+
"svg",
|
|
1182
|
+
{
|
|
1183
|
+
width: "24",
|
|
1184
|
+
height: "24",
|
|
1185
|
+
viewBox: "0 0 24 24",
|
|
1186
|
+
fill: "none",
|
|
1187
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1188
|
+
children: /* @__PURE__ */ jsx(
|
|
1189
|
+
"path",
|
|
1190
|
+
{
|
|
1191
|
+
d: "M14.99 2.93c-1.267 0-2.45.832-2.818 2.002L3.99 4.93a1 1 0 0 0 0 2l8.18-.001c.449 1.225 1.552 2 2.82 2s2.382-.777 2.838-2.008l2.162.009a1 1 0 0 0 0-2h-2.17c-.482-1.22-1.562-2-2.83-2m0 2a1 1 0 1 1 0 2 1 1 0 0 1 0-2m-6 4c-1.317 0-2.42.82-2.823 2.002-.14.009-2.176-.002-2.176-.002a1 1 0 0 0 0 2s2.052-.021 2.18-.008a2.95 2.95 0 0 0 2.82 2.008c1.268 0 2.354-.777 2.83-1.997l8.17-.003a1 1 0 0 0 0-2l-8.176-.01A3.01 3.01 0 0 0 8.99 8.93m0 2a1 1 0 1 1 0 2 1 1 0 0 1 0-2m6 4c-1.267 0-2.427.835-2.819 1.99l-8.18.01a1 1 0 0 0 0 2h8.165a3.02 3.02 0 0 0 2.835 2c1.268 0 2.36-.793 2.842-2h2.158a1 1 0 0 0 0-2l-2.167-.006a3.03 3.03 0 0 0-2.833-1.994m0 2a1 1 0 1 1 0 2 1 1 0 0 1 0-2",
|
|
1192
|
+
fill: "#fff",
|
|
1193
|
+
fillOpacity: ".54"
|
|
1194
|
+
}
|
|
1195
|
+
)
|
|
1196
|
+
}
|
|
1197
|
+
);
|
|
1198
|
+
var RocketIcon = () => /* @__PURE__ */ jsx(
|
|
1199
|
+
"svg",
|
|
1200
|
+
{
|
|
1201
|
+
width: "24",
|
|
1202
|
+
height: "24",
|
|
1203
|
+
viewBox: "0 0 24 24",
|
|
1204
|
+
fill: "none",
|
|
1205
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1206
|
+
children: /* @__PURE__ */ jsx(
|
|
1207
|
+
"path",
|
|
1208
|
+
{
|
|
1209
|
+
d: "M18.527 13.88c-.423.424-.884.808-1.345 1.154a.63.63 0 0 0-.269.423 9.2 9.2 0 0 1-2.459 4.346 10 10 0 0 1-1.883 1.462c-.576.346-1.268-.231-1.037-.885.384-1 .538-2.076.538-3.192-.077 0-.192.039-.27.039a39 39 0 0 1-2.612-2.423 51 51 0 0 1-2.42-2.615c0-.077.038-.193.038-.27-1.115 0-2.19.193-3.19.539-.614.23-1.23-.462-.883-1.039a10 10 0 0 1 1.46-1.884 9.2 9.2 0 0 1 4.342-2.461c.153-.039.307-.154.422-.27.346-.5.73-.923 1.153-1.346 2.997-3 7.185-4.038 11.066-3.153a.76.76 0 0 1 .538.538c.845 3.846-.192 8.038-3.189 11.038m-1.69-6.73a2.41 2.41 0 0 0-3.382 0 2.416 2.416 0 0 0 0 3.385 2.41 2.41 0 0 0 3.381 0c.96-.962.96-2.462 0-3.385M8.266 18.92c-.73.73-5.225 3.807-6.109 2.923-.884-.885 2.19-5.385 2.92-6.115s2.037-.616 2.92.269c.884.885 1 2.192.27 2.923",
|
|
1210
|
+
fill: "#fff",
|
|
1211
|
+
fillOpacity: ".54"
|
|
1212
|
+
}
|
|
1213
|
+
)
|
|
1214
|
+
}
|
|
1215
|
+
);
|
|
1216
|
+
var HowItWorks = () => {
|
|
1217
|
+
const { t } = useTranslation();
|
|
1218
|
+
const steps = useMemo(() => {
|
|
1219
|
+
return [
|
|
1220
|
+
{
|
|
1221
|
+
step: 1,
|
|
1222
|
+
icon: "wallet",
|
|
1223
|
+
title: t("affiliate.howItWorks.step1.title"),
|
|
1224
|
+
description: t("affiliate.howItWorks.step1.description")
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
step: 2,
|
|
1228
|
+
icon: "settings",
|
|
1229
|
+
title: t("affiliate.howItWorks.step2.title"),
|
|
1230
|
+
description: t("affiliate.howItWorks.step2.description")
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
step: 3,
|
|
1234
|
+
icon: "rocket",
|
|
1235
|
+
title: t("affiliate.howItWorks.step3.title"),
|
|
1236
|
+
description: t("affiliate.howItWorks.step3.description")
|
|
1237
|
+
}
|
|
1238
|
+
];
|
|
1239
|
+
}, [t]);
|
|
1240
|
+
return /* @__PURE__ */ jsxs(Box, { id: "oui-affiliate-landing-how-it-works", children: [
|
|
1241
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", children: [
|
|
1242
|
+
/* @__PURE__ */ jsx(Text, { weight: "semibold", className: "oui-text-[32px]", children: t("affiliate.howItWorks.title") }),
|
|
1243
|
+
/* @__PURE__ */ jsx(Box, { py: 4, children: /* @__PURE__ */ jsx(Text, { intensity: 54, children: t("affiliate.howItWorks.description") }) })
|
|
1244
|
+
] }),
|
|
1245
|
+
/* @__PURE__ */ jsx(Grid, { className: "oui-grid-cols-1 md:oui-grid-cols-3", gap: 6, children: steps.map((step) => /* @__PURE__ */ jsx(
|
|
1246
|
+
StepCard,
|
|
1247
|
+
{
|
|
1248
|
+
step: step.step,
|
|
1249
|
+
icon: step.icon,
|
|
1250
|
+
title: step.title,
|
|
1251
|
+
description: step.description
|
|
1252
|
+
},
|
|
1253
|
+
step.step
|
|
1254
|
+
)) })
|
|
1255
|
+
] });
|
|
1256
|
+
};
|
|
1257
|
+
var LandingPage = () => {
|
|
1258
|
+
return /* @__PURE__ */ jsxs(
|
|
1259
|
+
Flex,
|
|
1260
|
+
{
|
|
1261
|
+
id: "oui-affiliate-landing-page",
|
|
1262
|
+
direction: "column",
|
|
1263
|
+
gap: 10,
|
|
1264
|
+
itemAlign: "stretch",
|
|
1265
|
+
className: "oui-mx-auto oui-w-full oui-p-5 md:oui-w-[1040px] md:oui-py-12",
|
|
1266
|
+
children: [
|
|
1267
|
+
/* @__PURE__ */ jsx(Hero, {}),
|
|
1268
|
+
/* @__PURE__ */ jsx(HowItWorks, {}),
|
|
1269
|
+
/* @__PURE__ */ jsx(Faq, {})
|
|
1270
|
+
]
|
|
1271
|
+
}
|
|
1272
|
+
);
|
|
1273
|
+
};
|
|
1274
|
+
var CommissionChart = (props) => {
|
|
1275
|
+
const { t } = useTranslation();
|
|
1276
|
+
return /* @__PURE__ */ jsxs(
|
|
1277
|
+
Flex,
|
|
1278
|
+
{
|
|
1279
|
+
id: "oui-affiliate-affiliate-titleStatistic",
|
|
1280
|
+
r: "2xl",
|
|
1281
|
+
p: 6,
|
|
1282
|
+
width: "100%",
|
|
1283
|
+
gap: 4,
|
|
1284
|
+
direction: "column",
|
|
1285
|
+
className: "oui-border oui-border-line-6 oui-bg-base-9",
|
|
1286
|
+
children: [
|
|
1287
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "between", width: "100%", children: [
|
|
1288
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", children: `${t("affiliate.commission")} (USDC)` }),
|
|
1289
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
1290
|
+
Select.options,
|
|
1291
|
+
{
|
|
1292
|
+
size: "xs",
|
|
1293
|
+
value: props.period,
|
|
1294
|
+
onValueChange: props.onPeriodChange,
|
|
1295
|
+
options: props.periodTypes
|
|
1296
|
+
}
|
|
1297
|
+
) })
|
|
1298
|
+
] }),
|
|
1299
|
+
/* @__PURE__ */ jsx(Flex, { className: "oui-flex oui-h-[170px] oui-w-full oui-flex-row oui-items-stretch 2xl:oui-h-[196px]", children: /* @__PURE__ */ jsx(
|
|
1300
|
+
VolBarChart,
|
|
1301
|
+
{
|
|
1302
|
+
data: props.dataSource,
|
|
1303
|
+
colors: { fill: "rgba(0, 180, 158, 1)" },
|
|
1304
|
+
className: "oui-w-full oui-flex-1",
|
|
1305
|
+
tooltip: {
|
|
1306
|
+
rm: Decimal.ROUND_DOWN,
|
|
1307
|
+
dp: 2
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
) })
|
|
1311
|
+
]
|
|
1312
|
+
}
|
|
1313
|
+
);
|
|
1314
|
+
};
|
|
1315
|
+
function fillData(days, origin) {
|
|
1316
|
+
const now = Date();
|
|
1317
|
+
const result = new Array(days).fill(0).map((_, index) => {
|
|
1318
|
+
return {
|
|
1319
|
+
date: format(subDays(now, index + 1), "yyyy-MM-dd"),
|
|
1320
|
+
volume: 0,
|
|
1321
|
+
opacity: 0
|
|
1322
|
+
};
|
|
1323
|
+
}).reverse();
|
|
1324
|
+
const dataObject = origin?.reduce(
|
|
1325
|
+
(acc, curr) => {
|
|
1326
|
+
acc[curr.date] = curr;
|
|
1327
|
+
return acc;
|
|
1328
|
+
},
|
|
1329
|
+
{}
|
|
1330
|
+
);
|
|
1331
|
+
for (let index = 0; index < result.length; index++) {
|
|
1332
|
+
const element = result[index];
|
|
1333
|
+
const originData = dataObject?.[element.date];
|
|
1334
|
+
if (originData) {
|
|
1335
|
+
result[index] = { ...originData, opacity: originData.volume > 0 ? 1 : 0 };
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
return result;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// src/pages/multiLevel/affiliate/commissionChart/commissionChart.script.tsx
|
|
1342
|
+
var useCommissionChartScript = () => {
|
|
1343
|
+
const { t } = useTranslation();
|
|
1344
|
+
const [period, setPeriod] = useState("90");
|
|
1345
|
+
const periodTypes = useMemo(() => {
|
|
1346
|
+
return [
|
|
1347
|
+
{ label: t("common.select.7d"), value: "7" },
|
|
1348
|
+
{ label: t("common.select.30d"), value: "30" },
|
|
1349
|
+
{ label: t("common.select.90d"), value: "90" }
|
|
1350
|
+
];
|
|
1351
|
+
}, [t]);
|
|
1352
|
+
const onPeriodChange = (item) => {
|
|
1353
|
+
setPeriod(item);
|
|
1354
|
+
};
|
|
1355
|
+
const dateRange = useMemo(() => {
|
|
1356
|
+
const days = Number(period) || 7;
|
|
1357
|
+
const now = /* @__PURE__ */ new Date();
|
|
1358
|
+
return {
|
|
1359
|
+
startDate: subDays(now, days),
|
|
1360
|
+
endDate: subDays(now, 1)
|
|
1361
|
+
};
|
|
1362
|
+
}, [period]);
|
|
1363
|
+
const [rebateSummary] = useReferralRebateSummary({
|
|
1364
|
+
startDate: format(dateRange.startDate, "yyyy-MM-dd"),
|
|
1365
|
+
endDate: format(dateRange.endDate, "yyyy-MM-dd"),
|
|
1366
|
+
size: Number(period)
|
|
1367
|
+
});
|
|
1368
|
+
const dataSource = useMemo(() => {
|
|
1369
|
+
const data = (rebateSummary || [])?.map(
|
|
1370
|
+
(item) => ({
|
|
1371
|
+
date: item.date,
|
|
1372
|
+
volume: item.direct_rebate + item.indirect_rebate + item.direct_bonus_rebate
|
|
1373
|
+
})
|
|
1374
|
+
) || [];
|
|
1375
|
+
data.reverse();
|
|
1376
|
+
return fillData(Number(period), data);
|
|
1377
|
+
}, [rebateSummary, period]);
|
|
1378
|
+
return {
|
|
1379
|
+
period,
|
|
1380
|
+
periodTypes,
|
|
1381
|
+
onPeriodChange,
|
|
1382
|
+
dataSource
|
|
1383
|
+
};
|
|
1384
|
+
};
|
|
1385
|
+
var CommissionChartWidget = () => {
|
|
1386
|
+
const state = useCommissionChartScript();
|
|
1387
|
+
return /* @__PURE__ */ jsx(CommissionChart, { ...state });
|
|
1388
|
+
};
|
|
1389
|
+
var MultiLevelReferral = (props) => {
|
|
1390
|
+
const { isMultiLevelReferralUnlocked } = props;
|
|
1391
|
+
const { t } = useTranslation();
|
|
1392
|
+
return /* @__PURE__ */ jsxs(
|
|
1393
|
+
Flex,
|
|
1394
|
+
{
|
|
1395
|
+
r: "2xl",
|
|
1396
|
+
width: "100%",
|
|
1397
|
+
height: "100%",
|
|
1398
|
+
gap: 4,
|
|
1399
|
+
p: 5,
|
|
1400
|
+
direction: "column",
|
|
1401
|
+
intensity: 900,
|
|
1402
|
+
className: "oui-border oui-border-line-6",
|
|
1403
|
+
children: [
|
|
1404
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", className: "oui-w-full oui-text-start", children: t("affiliate.referral") }),
|
|
1405
|
+
/* @__PURE__ */ jsxs(
|
|
1406
|
+
Flex,
|
|
1407
|
+
{
|
|
1408
|
+
width: "100%",
|
|
1409
|
+
height: "100%",
|
|
1410
|
+
direction: "column",
|
|
1411
|
+
itemAlign: "center",
|
|
1412
|
+
justify: "center",
|
|
1413
|
+
gap: 4,
|
|
1414
|
+
children: [
|
|
1415
|
+
/* @__PURE__ */ jsx(MultiLevelReferralIcon, { className: "oui-text-primary-light" }),
|
|
1416
|
+
/* @__PURE__ */ jsx(Text, { size: "base", intensity: 98, children: t("affiliate.newReferralProgram.title") }),
|
|
1417
|
+
isMultiLevelReferralUnlocked ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1418
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", intensity: 54, className: "oui-text-center", children: t("affiliate.newReferralProgram.description") }),
|
|
1419
|
+
/* @__PURE__ */ jsx(
|
|
1420
|
+
Button,
|
|
1421
|
+
{
|
|
1422
|
+
size: "md",
|
|
1423
|
+
className: "oui-px-16",
|
|
1424
|
+
onClick: props.createReferralCode,
|
|
1425
|
+
children: t("affiliate.referralCode.create")
|
|
1426
|
+
}
|
|
1427
|
+
)
|
|
1428
|
+
] }) : /* @__PURE__ */ jsx(
|
|
1429
|
+
TradingVolumeProgress,
|
|
1430
|
+
{
|
|
1431
|
+
buttonProps: {
|
|
1432
|
+
className: "oui-px-16"
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
)
|
|
1436
|
+
]
|
|
1437
|
+
}
|
|
1438
|
+
)
|
|
1439
|
+
]
|
|
1440
|
+
}
|
|
1441
|
+
);
|
|
1442
|
+
};
|
|
1443
|
+
var MultiLevelReferralIcon = (props) => /* @__PURE__ */ jsxs(
|
|
1444
|
+
"svg",
|
|
1445
|
+
{
|
|
1446
|
+
width: 64,
|
|
1447
|
+
height: 64,
|
|
1448
|
+
viewBox: "0 0 64 64",
|
|
1449
|
+
fill: "currentColor",
|
|
1450
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1451
|
+
...props,
|
|
1452
|
+
children: [
|
|
1453
|
+
/* @__PURE__ */ jsx("rect", { width: 64, height: 64, rx: 32, fill: "rgb(var(--oui-color-base-8))" }),
|
|
1454
|
+
/* @__PURE__ */ jsx(
|
|
1455
|
+
"path",
|
|
1456
|
+
{
|
|
1457
|
+
fillRule: "evenodd",
|
|
1458
|
+
clipRule: "evenodd",
|
|
1459
|
+
d: "M28.822 23.24a.86.86 0 0 1 .607-.24h5.142c.228 0 .446.086.607.24a.8.8 0 0 1 .25.579v3.28a.8.8 0 0 1-.25.578.88.88 0 0 1-.607.24h-1.719v3.259h7.714c.228 0 .446.086.606.24a.8.8 0 0 1 .251.578v4.094h1.72c.227 0 .445.086.606.24a.8.8 0 0 1 .251.578v3.275a.8.8 0 0 1-.251.58.88.88 0 0 1-.606.239H38a.88.88 0 0 1-.606-.24.8.8 0 0 1-.251-.579v-3.274a.8.8 0 0 1 .25-.58.88.88 0 0 1 .607-.24h1.71v-3.274h-6.858v3.275h1.72c.227 0 .445.086.605.24a.8.8 0 0 1 .252.578v3.275a.8.8 0 0 1-.252.58.88.88 0 0 1-.606.239H29.43a.88.88 0 0 1-.606-.24.8.8 0 0 1-.252-.579v-3.274a.8.8 0 0 1 .252-.58.88.88 0 0 1 .606-.24h1.709v-3.274H24.28v3.275H26c.227 0 .445.086.606.24a.8.8 0 0 1 .251.578v3.275a.8.8 0 0 1-.25.58A.88.88 0 0 1 26 41h-5.143a.88.88 0 0 1-.606-.24.8.8 0 0 1-.251-.579v-3.274a.8.8 0 0 1 .251-.58.88.88 0 0 1 .606-.24h1.71v-4.093a.8.8 0 0 1 .25-.579.88.88 0 0 1 .606-.24h7.715v-3.258h-1.71a.88.88 0 0 1-.605-.24.8.8 0 0 1-.252-.579V23.82q0-.163.065-.313a.8.8 0 0 1 .186-.268"
|
|
1460
|
+
}
|
|
1461
|
+
)
|
|
1462
|
+
]
|
|
1463
|
+
}
|
|
1464
|
+
);
|
|
1465
|
+
var useMultiLevelReferralScript = () => {
|
|
1466
|
+
const {
|
|
1467
|
+
isMultiLevelReferralUnlocked,
|
|
1468
|
+
maxRebateRate,
|
|
1469
|
+
multiLevelRebateInfoMutate
|
|
1470
|
+
} = useReferralContext();
|
|
1471
|
+
const createReferralCode = () => {
|
|
1472
|
+
modal.show(ReferralCodeFormDialogId, {
|
|
1473
|
+
type: "create" /* Create */,
|
|
1474
|
+
maxRebateRate,
|
|
1475
|
+
directBonusRebateRate: 10,
|
|
1476
|
+
// Hardcoded value before API is ready
|
|
1477
|
+
onSuccess: () => {
|
|
1478
|
+
multiLevelRebateInfoMutate();
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1481
|
+
};
|
|
1482
|
+
return {
|
|
1483
|
+
isMultiLevelReferralUnlocked,
|
|
1484
|
+
createReferralCode
|
|
1485
|
+
};
|
|
1486
|
+
};
|
|
1487
|
+
var MultiLevelReferralWidget = () => {
|
|
1488
|
+
const state = useMultiLevelReferralScript();
|
|
1489
|
+
return /* @__PURE__ */ jsx(MultiLevelReferral, { ...state });
|
|
1490
|
+
};
|
|
1491
|
+
var ReferralInfo = (props) => {
|
|
1492
|
+
const { t } = useTranslation();
|
|
1493
|
+
return /* @__PURE__ */ jsxs(
|
|
1494
|
+
Flex,
|
|
1495
|
+
{
|
|
1496
|
+
id: "oui-affiliate-affiliate-referralLink",
|
|
1497
|
+
r: "2xl",
|
|
1498
|
+
width: "100%",
|
|
1499
|
+
height: "100%",
|
|
1500
|
+
gap: 4,
|
|
1501
|
+
p: 5,
|
|
1502
|
+
direction: "column",
|
|
1503
|
+
intensity: 900,
|
|
1504
|
+
className: "oui-border oui-border-line-6",
|
|
1505
|
+
children: [
|
|
1506
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
1507
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", children: t("affiliate.referral") }),
|
|
1508
|
+
/* @__PURE__ */ jsx(
|
|
1509
|
+
Button,
|
|
1510
|
+
{
|
|
1511
|
+
size: "xs",
|
|
1512
|
+
color: "secondary",
|
|
1513
|
+
onClick: () => props.onEdit("referralCode" /* ReferralCode */),
|
|
1514
|
+
children: t("affiliate.configure")
|
|
1515
|
+
}
|
|
1516
|
+
)
|
|
1517
|
+
] }),
|
|
1518
|
+
/* @__PURE__ */ jsxs(Container, { className: "oui-flex-col oui-items-start oui-gap-4 oui-p-5", children: [
|
|
1519
|
+
/* @__PURE__ */ jsx(
|
|
1520
|
+
Flex,
|
|
1521
|
+
{
|
|
1522
|
+
r: "full",
|
|
1523
|
+
px: 2,
|
|
1524
|
+
height: 20,
|
|
1525
|
+
justify: "center",
|
|
1526
|
+
itemAlign: "center",
|
|
1527
|
+
className: "oui-border oui-border-primary-light",
|
|
1528
|
+
children: /* @__PURE__ */ jsx(Text, { intensity: 98, className: "oui-text-[10px] oui-leading-[10px]", children: t("affiliate.multiLevel") })
|
|
1529
|
+
}
|
|
1530
|
+
),
|
|
1531
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
1532
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", color: "primaryLight", children: props.referralCode }),
|
|
1533
|
+
/* @__PURE__ */ jsx(CopyButton, { value: props.referralCode })
|
|
1534
|
+
] })
|
|
1535
|
+
] }),
|
|
1536
|
+
/* @__PURE__ */ jsxs(Container, { className: "oui-p-5", children: [
|
|
1537
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", color: "primaryLight", children: props.referralLink }),
|
|
1538
|
+
/* @__PURE__ */ jsx(CopyButton, { value: props.referralLink })
|
|
1539
|
+
] }),
|
|
1540
|
+
/* @__PURE__ */ jsxs(
|
|
1541
|
+
Box,
|
|
1542
|
+
{
|
|
1543
|
+
width: "100%",
|
|
1544
|
+
r: "2xl",
|
|
1545
|
+
className: "oui-bg-base-contrast-4 oui-p-5 md:oui-py-7",
|
|
1546
|
+
children: [
|
|
1547
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
1548
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: t("affiliate.revenueSplitStrategy") }),
|
|
1549
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", color: "secondary", onClick: () => props.onEdit(), children: t("common.edit") })
|
|
1550
|
+
] }),
|
|
1551
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "between", width: "100%", mt: 4, children: [
|
|
1552
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", intensity: 54, children: t("affiliate.youKeep") }),
|
|
1553
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", intensity: 54, children: t("affiliate.refereesGet") })
|
|
1554
|
+
] }),
|
|
1555
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "between", width: "100%", mt: 2, children: [
|
|
1556
|
+
/* @__PURE__ */ jsxs(Text.formatted, { size: "3xl", intensity: 80, children: [
|
|
1557
|
+
props.referrerRebateRate,
|
|
1558
|
+
"%"
|
|
1559
|
+
] }),
|
|
1560
|
+
/* @__PURE__ */ jsxs(Text.formatted, { size: "3xl", intensity: 36, children: [
|
|
1561
|
+
props.refereeRebateRate,
|
|
1562
|
+
"%"
|
|
1563
|
+
] })
|
|
1564
|
+
] }),
|
|
1565
|
+
props.directBonusRebateRate > 0 && /* @__PURE__ */ jsxs(Flex, { gap: 2, mt: 4, width: "100%", className: "oui-items-center", children: [
|
|
1566
|
+
/* @__PURE__ */ jsx(
|
|
1567
|
+
GiftIcon,
|
|
1568
|
+
{
|
|
1569
|
+
size: 16,
|
|
1570
|
+
className: "oui-shrink-0 oui-text-base-contrast oui-mt-[1px]"
|
|
1571
|
+
}
|
|
1572
|
+
),
|
|
1573
|
+
/* @__PURE__ */ jsx(
|
|
1574
|
+
Text,
|
|
1575
|
+
{
|
|
1576
|
+
intensity: 54,
|
|
1577
|
+
as: "span",
|
|
1578
|
+
className: "oui-flex-1 oui-min-w-0 oui-tracking-[0.03em]",
|
|
1579
|
+
children: /* @__PURE__ */ jsx(
|
|
1580
|
+
Trans,
|
|
1581
|
+
{
|
|
1582
|
+
i18nKey: "affiliate.extraBonusOnDirectReferrals",
|
|
1583
|
+
values: { amount: props.directBonusRebateRate },
|
|
1584
|
+
components: [/* @__PURE__ */ jsx(Text, { as: "span", color: "primaryLight" }, "0")]
|
|
1585
|
+
}
|
|
1586
|
+
)
|
|
1587
|
+
}
|
|
1588
|
+
)
|
|
1589
|
+
] })
|
|
1590
|
+
]
|
|
1591
|
+
}
|
|
1592
|
+
)
|
|
1593
|
+
]
|
|
1594
|
+
}
|
|
1595
|
+
);
|
|
1596
|
+
};
|
|
1597
|
+
var Container = (props) => {
|
|
1598
|
+
return /* @__PURE__ */ jsx(
|
|
1599
|
+
Flex,
|
|
1600
|
+
{
|
|
1601
|
+
width: "100%",
|
|
1602
|
+
justify: "between",
|
|
1603
|
+
px: 5,
|
|
1604
|
+
r: "2xl",
|
|
1605
|
+
className: cn("oui-bg-base-contrast-4", props.className),
|
|
1606
|
+
children: props.children
|
|
1607
|
+
}
|
|
1608
|
+
);
|
|
1609
|
+
};
|
|
1610
|
+
var CopyButton = (props) => {
|
|
1611
|
+
const { t } = useTranslation();
|
|
1612
|
+
const onCopy = () => {
|
|
1613
|
+
if (!props.value) return;
|
|
1614
|
+
navigator.clipboard.writeText(props.value);
|
|
1615
|
+
toast.success(t("common.copy.copied"));
|
|
1616
|
+
};
|
|
1617
|
+
return /* @__PURE__ */ jsx(Button, { size: "xs", color: "secondary", onClick: onCopy, children: t("common.copy") });
|
|
1618
|
+
};
|
|
1619
|
+
function generateReferralLink(referralLinkUrl, code) {
|
|
1620
|
+
return `${referralLinkUrl || window?.location?.origin}?ref=${code}`;
|
|
1621
|
+
}
|
|
1622
|
+
async function copyText(content) {
|
|
1623
|
+
try {
|
|
1624
|
+
await navigator.clipboard.writeText(content);
|
|
1625
|
+
toast.success(i18n.t("common.copy.copied"));
|
|
1626
|
+
} catch (error) {
|
|
1627
|
+
toast.success(i18n.t("common.copy.failed"));
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
function formatDateTimeToUTC(input) {
|
|
1631
|
+
if (input === void 0) {
|
|
1632
|
+
return "";
|
|
1633
|
+
}
|
|
1634
|
+
const date = toDate(input);
|
|
1635
|
+
const utcDate = toUTCDate(date);
|
|
1636
|
+
return format(utcDate, "yyyy-MM-dd HH:mm:ss 'UTC'");
|
|
1637
|
+
}
|
|
1638
|
+
function formatYMDTime(time) {
|
|
1639
|
+
if (time === void 0) {
|
|
1640
|
+
return void 0;
|
|
1641
|
+
}
|
|
1642
|
+
const date = toDate(time);
|
|
1643
|
+
const utcDate = toUTCDate(date);
|
|
1644
|
+
return format(utcDate, "yyyy-MM-dd");
|
|
1645
|
+
}
|
|
1646
|
+
function compareDate(d1, d2) {
|
|
1647
|
+
const isEqual = d1 && d2 && d1.toISOString().substring(0, 10) === d2.toISOString().substring(0, 10);
|
|
1648
|
+
return isEqual;
|
|
1649
|
+
}
|
|
1650
|
+
function toUTCDate(date) {
|
|
1651
|
+
return new Date(date.toUTCString());
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
// src/pages/multiLevel/affiliate/referralInfo/referralInfo.script.tsx
|
|
1655
|
+
var useReferralInfoScript = () => {
|
|
1656
|
+
const {
|
|
1657
|
+
referralLinkUrl,
|
|
1658
|
+
multiLevelRebateInfo,
|
|
1659
|
+
multiLevelRebateInfoMutate,
|
|
1660
|
+
maxRebateRate
|
|
1661
|
+
} = useReferralContext();
|
|
1662
|
+
const referralCode = multiLevelRebateInfo?.referral_code;
|
|
1663
|
+
const referralLink = useMemo(() => {
|
|
1664
|
+
if (!referralCode) return "";
|
|
1665
|
+
return generateReferralLink(referralLinkUrl, referralCode);
|
|
1666
|
+
}, [referralCode]);
|
|
1667
|
+
const referrerRebateRate = useMemo(() => {
|
|
1668
|
+
return new Decimal(multiLevelRebateInfo?.referrer_rebate_rate || 0).mul(100).toNumber();
|
|
1669
|
+
}, [multiLevelRebateInfo]);
|
|
1670
|
+
const refereeRebateRate = useMemo(() => {
|
|
1671
|
+
return new Decimal(multiLevelRebateInfo?.referee_rebate_rate || 0).mul(100).toNumber();
|
|
1672
|
+
}, [multiLevelRebateInfo]);
|
|
1673
|
+
const directBonusRebateRate = useMemo(() => {
|
|
1674
|
+
return new Decimal(multiLevelRebateInfo?.direct_bonus_rebate_rate ?? 0).mul(100).toNumber();
|
|
1675
|
+
}, [multiLevelRebateInfo]);
|
|
1676
|
+
const onEdit = (focusField) => {
|
|
1677
|
+
modal.show(ReferralCodeFormDialogId, {
|
|
1678
|
+
type: "edit" /* Edit */,
|
|
1679
|
+
focusField,
|
|
1680
|
+
referralCode: multiLevelRebateInfo?.referral_code,
|
|
1681
|
+
maxRebateRate,
|
|
1682
|
+
referrerRebateRate: multiLevelRebateInfo?.referrer_rebate_rate,
|
|
1683
|
+
directInvites: multiLevelRebateInfo?.direct_invites,
|
|
1684
|
+
directBonusRebateRate,
|
|
1685
|
+
onSuccess: () => {
|
|
1686
|
+
multiLevelRebateInfoMutate();
|
|
1687
|
+
}
|
|
1688
|
+
});
|
|
1689
|
+
};
|
|
1690
|
+
return {
|
|
1691
|
+
onEdit,
|
|
1692
|
+
referralCode,
|
|
1693
|
+
referralLink,
|
|
1694
|
+
multiLevelRebateInfo,
|
|
1695
|
+
referrerRebateRate,
|
|
1696
|
+
refereeRebateRate,
|
|
1697
|
+
directBonusRebateRate
|
|
1698
|
+
};
|
|
1699
|
+
};
|
|
1700
|
+
var ReferralInfoWidget = () => {
|
|
1701
|
+
const state = useReferralInfoScript();
|
|
1702
|
+
return /* @__PURE__ */ jsx(ReferralInfo, { ...state });
|
|
1703
|
+
};
|
|
1704
|
+
var useReferrerTableScript = () => {
|
|
1705
|
+
const [activeTab, _setActiveTab] = useState("commission");
|
|
1706
|
+
const setActiveTab = (tab) => _setActiveTab(tab);
|
|
1707
|
+
return {
|
|
1708
|
+
activeTab,
|
|
1709
|
+
setActiveTab
|
|
1710
|
+
};
|
|
1711
|
+
};
|
|
1712
|
+
var useReferralHistory = (params) => {
|
|
1713
|
+
const { size, startDate, endDate, page, fetchAll, enabled = true } = params;
|
|
1714
|
+
const query = useMemo(() => {
|
|
1715
|
+
if (!enabled) return null;
|
|
1716
|
+
const search = new URLSearchParams({
|
|
1717
|
+
...startDate ? { start_date: startDate } : {},
|
|
1718
|
+
...endDate ? { end_date: endDate } : {},
|
|
1719
|
+
...!fetchAll && page !== void 0 ? { page: String(page) } : {},
|
|
1720
|
+
...!fetchAll && size !== void 0 ? { size: String(size) } : {}
|
|
1721
|
+
});
|
|
1722
|
+
const qs = search.toString();
|
|
1723
|
+
return qs ? `/v1/referral/referral_history?${qs}` : "/v1/referral/referral_history";
|
|
1724
|
+
}, [enabled, endDate, fetchAll, page, size, startDate]);
|
|
1725
|
+
const response = usePrivateQuery(query, {
|
|
1726
|
+
formatter: (data) => data,
|
|
1727
|
+
revalidateOnFocus: false
|
|
1728
|
+
});
|
|
1729
|
+
const loadMore = () => {
|
|
1730
|
+
};
|
|
1731
|
+
const meta = useMemo(() => {
|
|
1732
|
+
const payload = response.data?.data ?? response.data;
|
|
1733
|
+
if (payload?.meta) return payload.meta;
|
|
1734
|
+
if (!payload?.rows) return void 0;
|
|
1735
|
+
return {
|
|
1736
|
+
total: payload.rows.length,
|
|
1737
|
+
records_per_page: payload.rows.length,
|
|
1738
|
+
current_page: 1
|
|
1739
|
+
};
|
|
1740
|
+
}, [response.data]);
|
|
1741
|
+
const total = useMemo(() => {
|
|
1742
|
+
if (typeof meta?.total === "number") return meta.total;
|
|
1743
|
+
return 0;
|
|
1744
|
+
}, [meta]);
|
|
1745
|
+
const flattenRows = useMemo(() => {
|
|
1746
|
+
if (!response.data) return null;
|
|
1747
|
+
const payload = response.data?.data ?? response.data;
|
|
1748
|
+
return payload?.rows ?? null;
|
|
1749
|
+
}, [response.data]);
|
|
1750
|
+
return [
|
|
1751
|
+
flattenRows,
|
|
1752
|
+
{
|
|
1753
|
+
total,
|
|
1754
|
+
isLoading: response.isLoading,
|
|
1755
|
+
refresh: response.mutate,
|
|
1756
|
+
loadMore,
|
|
1757
|
+
meta
|
|
1758
|
+
}
|
|
1759
|
+
];
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1762
|
+
// src/pages/multiLevel/affiliate/referrerTable/commissionTable/commissionTable.script.tsx
|
|
1763
|
+
var useCommissionTableScript = (props = {}) => {
|
|
1764
|
+
const { enabled = true } = props;
|
|
1765
|
+
const { isMobile } = useScreen();
|
|
1766
|
+
const { state } = useAccount();
|
|
1767
|
+
const [dateRange, setDateRange] = useState({
|
|
1768
|
+
from: subDays(/* @__PURE__ */ new Date(), 30),
|
|
1769
|
+
to: /* @__PURE__ */ new Date()
|
|
1770
|
+
});
|
|
1771
|
+
const { page, pageSize, parsePagination } = usePagination();
|
|
1772
|
+
const [sort, setSort] = useState(null);
|
|
1773
|
+
const [data, { meta, isLoading: isDataLoading }] = useReferralHistory({
|
|
1774
|
+
enabled: enabled && state.status >= AccountStatusEnum.EnableTrading,
|
|
1775
|
+
startDate: dateRange.from ? format(dateRange.from, "yyyy-MM-dd") : void 0,
|
|
1776
|
+
endDate: dateRange.to ? format(dateRange.to, "yyyy-MM-dd") : void 0,
|
|
1777
|
+
page: isMobile ? void 0 : page,
|
|
1778
|
+
size: isMobile ? void 0 : pageSize,
|
|
1779
|
+
fetchAll: isMobile
|
|
1780
|
+
});
|
|
1781
|
+
const pagination = useMemo(() => {
|
|
1782
|
+
return parsePagination(meta);
|
|
1783
|
+
}, [meta, parsePagination]);
|
|
1784
|
+
const commissionData = useMemo(() => {
|
|
1785
|
+
if (!data) return [];
|
|
1786
|
+
const rows = data.map((row) => ({
|
|
1787
|
+
date: row.date,
|
|
1788
|
+
code: row.referral_code,
|
|
1789
|
+
volume: row.volume,
|
|
1790
|
+
commission: row.referral_rebate,
|
|
1791
|
+
directBonusRebate: row.direct_bonus_rebate,
|
|
1792
|
+
address: row.user_address
|
|
1793
|
+
}));
|
|
1794
|
+
if (!sort) return rows;
|
|
1795
|
+
rows.sort((a, b) => {
|
|
1796
|
+
const valA = a[sort.key];
|
|
1797
|
+
const valB = b[sort.key];
|
|
1798
|
+
if (valA < valB) return sort.order === "asc" ? -1 : 1;
|
|
1799
|
+
if (valA > valB) return sort.order === "asc" ? 1 : -1;
|
|
1800
|
+
return 0;
|
|
1801
|
+
});
|
|
1802
|
+
return rows;
|
|
1803
|
+
}, [data, sort]);
|
|
1804
|
+
const onSort = (sort2) => {
|
|
1805
|
+
if (!sort2) {
|
|
1806
|
+
setSort(null);
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
const sortKey = sort2.sortKey;
|
|
1810
|
+
if (sortKey && (sortKey === "volume" || sortKey === "commission")) {
|
|
1811
|
+
setSort({
|
|
1812
|
+
key: sortKey,
|
|
1813
|
+
order: sort2.sort === "asc" ? "asc" : "desc"
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
return {
|
|
1818
|
+
commissionData,
|
|
1819
|
+
dateRange,
|
|
1820
|
+
setDateRange,
|
|
1821
|
+
pagination,
|
|
1822
|
+
onSort,
|
|
1823
|
+
isLoading: state.status < AccountStatusEnum.EnableTrading || !enabled || isDataLoading
|
|
1824
|
+
};
|
|
1825
|
+
};
|
|
1826
|
+
var dashedUnderline = "oui-cursor-pointer oui-underline oui-decoration-dashed oui-underline-offset-4 oui-decoration-base-contrast-36 oui-tracking-[0.03em]";
|
|
1827
|
+
var useMobileTooltipModal = (content, title) => {
|
|
1828
|
+
const { isMobile } = useScreen();
|
|
1829
|
+
return useCallback(
|
|
1830
|
+
(e) => {
|
|
1831
|
+
if (!isMobile) return;
|
|
1832
|
+
e.preventDefault();
|
|
1833
|
+
e.stopPropagation();
|
|
1834
|
+
modal.dialog({
|
|
1835
|
+
title,
|
|
1836
|
+
closable: true,
|
|
1837
|
+
size: "sm",
|
|
1838
|
+
content: /* @__PURE__ */ jsx("div", { className: "oui-text-sm oui-leading-5 oui-text-base-contrast", children: content })
|
|
1839
|
+
});
|
|
1840
|
+
},
|
|
1841
|
+
[isMobile, content, title]
|
|
1842
|
+
);
|
|
1843
|
+
};
|
|
1844
|
+
var AddressCell = ({ address, title }) => {
|
|
1845
|
+
const onClick = useMobileTooltipModal(address, title);
|
|
1846
|
+
const { isMobile } = useScreen();
|
|
1847
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: address, open: isMobile ? false : void 0, children: /* @__PURE__ */ jsx(Text, { className: dashedUnderline, onClick, children: formatAddress(address) }) });
|
|
1848
|
+
};
|
|
1849
|
+
var TooltipCell = ({ text, tooltip, title }) => {
|
|
1850
|
+
const onClick = useMobileTooltipModal(tooltip, title);
|
|
1851
|
+
const { isMobile } = useScreen();
|
|
1852
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: tooltip, open: isMobile ? false : void 0, children: /* @__PURE__ */ jsx(Text, { className: dashedUnderline, onClick, children: text }) });
|
|
1853
|
+
};
|
|
1854
|
+
var BreakdownCell = ({ total, direct, indirect, directBonus, prefix, fix = 0, title }) => {
|
|
1855
|
+
const { t } = useTranslation();
|
|
1856
|
+
const format9 = (val) => commifyOptional(val, {
|
|
1857
|
+
fix,
|
|
1858
|
+
fallback: "0",
|
|
1859
|
+
padEnd: true,
|
|
1860
|
+
prefix
|
|
1861
|
+
});
|
|
1862
|
+
const directLine = directBonus ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1863
|
+
"\u2022 ",
|
|
1864
|
+
t("affiliate.direct"),
|
|
1865
|
+
": ",
|
|
1866
|
+
format9(direct + directBonus),
|
|
1867
|
+
" ",
|
|
1868
|
+
/* @__PURE__ */ jsxs("span", { className: "oui-text-base-contrast-54", children: [
|
|
1869
|
+
"(",
|
|
1870
|
+
t("affiliate.directInclBonus", { amount: format9(directBonus) }),
|
|
1871
|
+
")"
|
|
1872
|
+
] })
|
|
1873
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1874
|
+
"\u2022 ",
|
|
1875
|
+
t("affiliate.direct"),
|
|
1876
|
+
": ",
|
|
1877
|
+
format9(direct)
|
|
1878
|
+
] });
|
|
1879
|
+
const tooltipContent = /* @__PURE__ */ jsxs("div", { className: "oui-flex oui-flex-col oui-gap-1", children: [
|
|
1880
|
+
/* @__PURE__ */ jsx("div", { children: directLine }),
|
|
1881
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1882
|
+
"\u2022 ",
|
|
1883
|
+
t("affiliate.indirect"),
|
|
1884
|
+
": ",
|
|
1885
|
+
format9(indirect)
|
|
1886
|
+
] })
|
|
1887
|
+
] });
|
|
1888
|
+
const onClick = useMobileTooltipModal(tooltipContent, title);
|
|
1889
|
+
const { isMobile } = useScreen();
|
|
1890
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: tooltipContent, open: isMobile ? false : void 0, children: /* @__PURE__ */ jsx(Text, { className: dashedUnderline, onClick, children: format9(total) }) });
|
|
1891
|
+
};
|
|
1892
|
+
var MobileCell = ({ label, children, align = "start", className }) => {
|
|
1893
|
+
return /* @__PURE__ */ jsxs(
|
|
1894
|
+
Flex,
|
|
1895
|
+
{
|
|
1896
|
+
direction: "column",
|
|
1897
|
+
itemAlign: align,
|
|
1898
|
+
className: cn(
|
|
1899
|
+
"oui-gap-1.5 oui-font-medium oui-tracking-[0.01em]",
|
|
1900
|
+
className
|
|
1901
|
+
),
|
|
1902
|
+
children: [
|
|
1903
|
+
/* @__PURE__ */ jsx(Text, { intensity: 36, size: "2xs", className: "oui-leading-[15px]", children: label }),
|
|
1904
|
+
/* @__PURE__ */ jsx("div", { className: "oui-text-sm oui-leading-[20px]", children })
|
|
1905
|
+
]
|
|
1906
|
+
}
|
|
1907
|
+
);
|
|
1908
|
+
};
|
|
1909
|
+
var MobileCard = ({ children, className }) => {
|
|
1910
|
+
return /* @__PURE__ */ jsx(
|
|
1911
|
+
Grid,
|
|
1912
|
+
{
|
|
1913
|
+
cols: 3,
|
|
1914
|
+
py: 3,
|
|
1915
|
+
r: "xl",
|
|
1916
|
+
width: "100%",
|
|
1917
|
+
className: cn("oui-bg-base-9 oui-gap-x-[6px] oui-gap-y-3", className),
|
|
1918
|
+
children
|
|
1919
|
+
}
|
|
1920
|
+
);
|
|
1921
|
+
};
|
|
1922
|
+
var formatCommissionAmt = (v) => commifyOptional(v, {
|
|
1923
|
+
fix: 6,
|
|
1924
|
+
fallback: "0",
|
|
1925
|
+
padEnd: true,
|
|
1926
|
+
prefix: "$"
|
|
1927
|
+
});
|
|
1928
|
+
var CommissionCell = ({ item }) => {
|
|
1929
|
+
const { t } = useTranslation();
|
|
1930
|
+
const totalCommission = item.commission + item.directBonusRebate;
|
|
1931
|
+
const tooltip = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1932
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1933
|
+
"\u2022 ",
|
|
1934
|
+
t("affiliate.base"),
|
|
1935
|
+
": ",
|
|
1936
|
+
formatCommissionAmt(item.commission)
|
|
1937
|
+
] }),
|
|
1938
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1939
|
+
"\u2022 ",
|
|
1940
|
+
t("affiliate.directBonus"),
|
|
1941
|
+
":",
|
|
1942
|
+
" ",
|
|
1943
|
+
formatCommissionAmt(item.directBonusRebate)
|
|
1944
|
+
] })
|
|
1945
|
+
] });
|
|
1946
|
+
return /* @__PURE__ */ jsx(
|
|
1947
|
+
TooltipCell,
|
|
1948
|
+
{
|
|
1949
|
+
text: formatCommissionAmt(totalCommission),
|
|
1950
|
+
tooltip,
|
|
1951
|
+
title: t("affiliate.commission")
|
|
1952
|
+
}
|
|
1953
|
+
);
|
|
1954
|
+
};
|
|
1955
|
+
var MobileCommissionItem = ({ item }) => {
|
|
1956
|
+
const { t } = useTranslation();
|
|
1957
|
+
return /* @__PURE__ */ jsxs(MobileCard, { children: [
|
|
1958
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.date"), children: /* @__PURE__ */ jsx(Text, { children: formatYMDTime(item.date) }) }),
|
|
1959
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.code"), children: /* @__PURE__ */ jsx(Text, { children: item.code }) }),
|
|
1960
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.volume"), align: "end", children: /* @__PURE__ */ jsx(Text, { children: commifyOptional(item.volume, {
|
|
1961
|
+
fix: 2,
|
|
1962
|
+
fallback: "0",
|
|
1963
|
+
padEnd: true,
|
|
1964
|
+
prefix: "$"
|
|
1965
|
+
}) }) }),
|
|
1966
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("affiliate.commission"), children: /* @__PURE__ */ jsx(CommissionCell, { item }) }),
|
|
1967
|
+
/* @__PURE__ */ jsx(
|
|
1968
|
+
MobileCell,
|
|
1969
|
+
{
|
|
1970
|
+
label: t("common.address"),
|
|
1971
|
+
align: "end",
|
|
1972
|
+
className: "oui-col-start-3",
|
|
1973
|
+
children: /* @__PURE__ */ jsx(AddressCell, { address: item.address, title: t("common.address") })
|
|
1974
|
+
}
|
|
1975
|
+
)
|
|
1976
|
+
] });
|
|
1977
|
+
};
|
|
1978
|
+
var CommissionTableUI = (props) => {
|
|
1979
|
+
const { t } = useTranslation();
|
|
1980
|
+
const { isMobile } = useScreen();
|
|
1981
|
+
const showPagination = (props.pagination?.count ?? 0) >= 10;
|
|
1982
|
+
const columns = useMemo(() => {
|
|
1983
|
+
return [
|
|
1984
|
+
{
|
|
1985
|
+
title: t("common.date"),
|
|
1986
|
+
dataIndex: "date",
|
|
1987
|
+
render: (value) => formatYMDTime(value)
|
|
1988
|
+
},
|
|
1989
|
+
{
|
|
1990
|
+
title: t("common.code"),
|
|
1991
|
+
dataIndex: "code"
|
|
1992
|
+
},
|
|
1993
|
+
{
|
|
1994
|
+
title: t("common.volume"),
|
|
1995
|
+
dataIndex: "volume",
|
|
1996
|
+
render: (value) => /* @__PURE__ */ jsx(Text, { children: commifyOptional(value, {
|
|
1997
|
+
fix: 2,
|
|
1998
|
+
fallback: "0",
|
|
1999
|
+
padEnd: true,
|
|
2000
|
+
prefix: "$"
|
|
2001
|
+
}) }),
|
|
2002
|
+
onSort: true
|
|
2003
|
+
},
|
|
2004
|
+
{
|
|
2005
|
+
title: t("affiliate.commission"),
|
|
2006
|
+
dataIndex: "commission",
|
|
2007
|
+
render: (_value, record) => /* @__PURE__ */ jsx(CommissionCell, { item: record }),
|
|
2008
|
+
onSort: true
|
|
2009
|
+
},
|
|
2010
|
+
{
|
|
2011
|
+
title: t("common.address"),
|
|
2012
|
+
dataIndex: "address",
|
|
2013
|
+
render: (value) => /* @__PURE__ */ jsx(AddressCell, { address: value, title: t("common.address") })
|
|
2014
|
+
}
|
|
2015
|
+
];
|
|
2016
|
+
}, [t]);
|
|
2017
|
+
return /* @__PURE__ */ jsxs("div", { className: "oui-flex oui-w-full oui-flex-col", children: [
|
|
2018
|
+
/* @__PURE__ */ jsx(Flex, { width: "100%", height: 49, className: "oui-border-b oui-border-line-6", children: /* @__PURE__ */ jsx("div", { className: "oui-px-3", children: /* @__PURE__ */ jsx(
|
|
2019
|
+
DatePicker.range,
|
|
2020
|
+
{
|
|
2021
|
+
size: "xs",
|
|
2022
|
+
value: props.dateRange,
|
|
2023
|
+
onChange: props.setDateRange,
|
|
2024
|
+
max: 90,
|
|
2025
|
+
disabled: { after: /* @__PURE__ */ new Date() }
|
|
2026
|
+
}
|
|
2027
|
+
) }) }),
|
|
2028
|
+
isMobile ? /* @__PURE__ */ jsx("div", { className: "oui-flex oui-flex-col oui-px-4", children: /* @__PURE__ */ jsx(
|
|
2029
|
+
ListView,
|
|
2030
|
+
{
|
|
2031
|
+
dataSource: props.commissionData,
|
|
2032
|
+
contentClassName: "!oui-space-y-0 oui-pb-3",
|
|
2033
|
+
renderItem: (item, index) => /* @__PURE__ */ jsxs("div", { children: [
|
|
2034
|
+
/* @__PURE__ */ jsx(MobileCommissionItem, { item }),
|
|
2035
|
+
/* @__PURE__ */ jsx(Divider, { intensity: 8 })
|
|
2036
|
+
] }, index)
|
|
2037
|
+
}
|
|
2038
|
+
) }) : /* @__PURE__ */ jsx("div", { className: `oui-px-3 ${showPagination ? "" : "oui-pb-3"}`, children: /* @__PURE__ */ jsx(
|
|
2039
|
+
AuthGuardDataTable,
|
|
2040
|
+
{
|
|
2041
|
+
bordered: true,
|
|
2042
|
+
columns,
|
|
2043
|
+
dataSource: props.commissionData,
|
|
2044
|
+
loading: props.isLoading,
|
|
2045
|
+
pagination: showPagination ? props.pagination : void 0,
|
|
2046
|
+
onSort: props.onSort,
|
|
2047
|
+
onRow: () => ({ className: "oui-h-12" }),
|
|
2048
|
+
className: "[&_.oui-h-10.oui-w-full]:!oui-mx-0 [&_.oui-table-pagination]:!oui-justify-end [&_th]:!oui-tracking-[0.03em] [&_th]:!oui-px-3 [&_td]:!oui-px-3"
|
|
2049
|
+
}
|
|
2050
|
+
) })
|
|
2051
|
+
] });
|
|
2052
|
+
};
|
|
2053
|
+
var CommissionTableWidget = (props) => {
|
|
2054
|
+
const state = useCommissionTableScript(props);
|
|
2055
|
+
return /* @__PURE__ */ jsx(CommissionTableUI, { ...state });
|
|
2056
|
+
};
|
|
2057
|
+
var useMultiLevelReferees = (params = {}) => {
|
|
2058
|
+
const { enabled = true, fetchAll = false, page, pageSize } = params;
|
|
2059
|
+
const { state } = useAccount();
|
|
2060
|
+
const canQuery = enabled && state.status >= AccountStatusEnum.EnableTrading;
|
|
2061
|
+
const queryKey = useMemo(() => {
|
|
2062
|
+
if (!canQuery) return null;
|
|
2063
|
+
if (fetchAll) return "/v1/referral/multi_level/referee_list";
|
|
2064
|
+
if (page !== void 0 && pageSize !== void 0) {
|
|
2065
|
+
return `/v1/referral/multi_level/referee_list?page=${page}&size=${pageSize}`;
|
|
2066
|
+
}
|
|
2067
|
+
return "/v1/referral/multi_level/referee_list";
|
|
2068
|
+
}, [canQuery, fetchAll, page, pageSize]);
|
|
2069
|
+
const response = usePrivateQuery(queryKey, {
|
|
2070
|
+
formatter: (payload) => {
|
|
2071
|
+
const rows = payload.rows ?? payload.data?.rows ?? [];
|
|
2072
|
+
const meta = payload.meta ?? payload.data?.meta;
|
|
2073
|
+
return {
|
|
2074
|
+
...payload,
|
|
2075
|
+
meta,
|
|
2076
|
+
rows: rows.map((row) => ({
|
|
2077
|
+
...row,
|
|
2078
|
+
network_size: row.direct_invites + row.indirect_invites,
|
|
2079
|
+
volume: row.direct_volume + row.indirect_volume,
|
|
2080
|
+
commission: row.direct_rebate + row.indirect_rebate + row.direct_bonus_rebate
|
|
2081
|
+
}))
|
|
2082
|
+
};
|
|
2083
|
+
},
|
|
2084
|
+
revalidateOnFocus: false
|
|
2085
|
+
});
|
|
2086
|
+
return {
|
|
2087
|
+
...response,
|
|
2088
|
+
isLoading: state.status < AccountStatusEnum.EnableTrading || !enabled || response.isLoading,
|
|
2089
|
+
rows: response.data?.rows ?? [],
|
|
2090
|
+
meta: response.data?.meta
|
|
2091
|
+
};
|
|
2092
|
+
};
|
|
2093
|
+
|
|
2094
|
+
// src/pages/multiLevel/affiliate/referrerTable/refereesTable/refereesTable.script.tsx
|
|
2095
|
+
var useRefereesTableScript = (props = {}) => {
|
|
2096
|
+
const { enabled = true } = props;
|
|
2097
|
+
const { isMobile } = useScreen();
|
|
2098
|
+
const refereesPaginationUtils = usePagination();
|
|
2099
|
+
const [refereesSort, setRefereesSort] = useState(null);
|
|
2100
|
+
const {
|
|
2101
|
+
isLoading: isRefereesLoading,
|
|
2102
|
+
mutate: refereesMutate,
|
|
2103
|
+
rows: refereesRows,
|
|
2104
|
+
meta: refereesMeta
|
|
2105
|
+
} = useMultiLevelReferees({
|
|
2106
|
+
enabled,
|
|
2107
|
+
fetchAll: isMobile,
|
|
2108
|
+
page: refereesPaginationUtils.page,
|
|
2109
|
+
pageSize: refereesPaginationUtils.pageSize
|
|
2110
|
+
});
|
|
2111
|
+
const refereesPagination = useMemo(() => {
|
|
2112
|
+
return refereesPaginationUtils.parsePagination(refereesMeta);
|
|
2113
|
+
}, [refereesMeta, refereesPaginationUtils]);
|
|
2114
|
+
const { multiLevelRebateInfo, maxRebateRate, multiLevelRebateInfoMutate } = useReferralContext();
|
|
2115
|
+
const onEditReferee = useCallback(
|
|
2116
|
+
(type, item) => {
|
|
2117
|
+
const referrerRebateRate = type === "reset" /* Reset */ ? multiLevelRebateInfo?.referrer_rebate_rate : item.referral_rebate_rate;
|
|
2118
|
+
modal.show(ReferralCodeFormDialogId, {
|
|
2119
|
+
type,
|
|
2120
|
+
referralCode: multiLevelRebateInfo?.referral_code,
|
|
2121
|
+
maxRebateRate,
|
|
2122
|
+
referrerRebateRate,
|
|
2123
|
+
onSuccess: () => {
|
|
2124
|
+
multiLevelRebateInfoMutate();
|
|
2125
|
+
refereesMutate();
|
|
2126
|
+
},
|
|
2127
|
+
accountId: item.account_id,
|
|
2128
|
+
multiLevelRebateInfo,
|
|
2129
|
+
directInvites: multiLevelRebateInfo?.direct_invites,
|
|
2130
|
+
directBonusRebateRate: new Decimal(
|
|
2131
|
+
multiLevelRebateInfo?.direct_bonus_rebate_rate ?? 0
|
|
2132
|
+
).mul(100).toNumber()
|
|
2133
|
+
});
|
|
2134
|
+
},
|
|
2135
|
+
[
|
|
2136
|
+
maxRebateRate,
|
|
2137
|
+
multiLevelRebateInfo?.referral_code,
|
|
2138
|
+
multiLevelRebateInfo?.referrer_rebate_rate,
|
|
2139
|
+
multiLevelRebateInfoMutate,
|
|
2140
|
+
refereesMutate
|
|
2141
|
+
]
|
|
2142
|
+
);
|
|
2143
|
+
const refereesData = useMemo(() => {
|
|
2144
|
+
const rows = refereesRows ?? [];
|
|
2145
|
+
if (!refereesSort) return rows;
|
|
2146
|
+
const sortableRows = rows.map((row, index) => ({
|
|
2147
|
+
row,
|
|
2148
|
+
index
|
|
2149
|
+
}));
|
|
2150
|
+
sortableRows.sort((a, b) => {
|
|
2151
|
+
const valA = Number(a.row[refereesSort.key] ?? 0);
|
|
2152
|
+
const valB = Number(b.row[refereesSort.key] ?? 0);
|
|
2153
|
+
if (valA < valB) return refereesSort.order === "asc" ? -1 : 1;
|
|
2154
|
+
if (valA > valB) return refereesSort.order === "asc" ? 1 : -1;
|
|
2155
|
+
return a.index - b.index;
|
|
2156
|
+
});
|
|
2157
|
+
return sortableRows.map((item) => item.row);
|
|
2158
|
+
}, [refereesRows, refereesSort]);
|
|
2159
|
+
const onRefereesSort = (sort) => {
|
|
2160
|
+
if (!sort) {
|
|
2161
|
+
setRefereesSort(null);
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
const sortKey = sort.sortKey;
|
|
2165
|
+
if (sortKey && (sortKey === "referee_rebate_rate" || sortKey === "network_size" || sortKey === "volume" || sortKey === "commission")) {
|
|
2166
|
+
setRefereesSort({
|
|
2167
|
+
key: sortKey,
|
|
2168
|
+
order: sort.sort === "asc" ? "asc" : "desc"
|
|
2169
|
+
});
|
|
2170
|
+
}
|
|
2171
|
+
};
|
|
2172
|
+
return {
|
|
2173
|
+
refereesData,
|
|
2174
|
+
refereesPagination,
|
|
2175
|
+
isRefereesLoading,
|
|
2176
|
+
onEditReferee,
|
|
2177
|
+
onRefereesSort
|
|
2178
|
+
};
|
|
2179
|
+
};
|
|
2180
|
+
var getRebateRateText = (rate) => {
|
|
2181
|
+
return (rate * 100).toFixed(0) + "%";
|
|
2182
|
+
};
|
|
2183
|
+
var getRefereeType = (bindType) => {
|
|
2184
|
+
const { t } = useTranslation();
|
|
2185
|
+
if (bindType === "legacy") {
|
|
2186
|
+
return {
|
|
2187
|
+
text: t("affiliate.singleLevelLegacy"),
|
|
2188
|
+
tooltip: t("affiliate.singleLevelLegacy.tooltip")
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
return {
|
|
2192
|
+
text: t("affiliate.multiLevel"),
|
|
2193
|
+
tooltip: t("affiliate.multiLevel.tooltip")
|
|
2194
|
+
};
|
|
2195
|
+
};
|
|
2196
|
+
var MobileRefereeItem = ({ item, onEditReferee }) => {
|
|
2197
|
+
const { t } = useTranslation();
|
|
2198
|
+
const typeInfo = getRefereeType(item.bind_type);
|
|
2199
|
+
return /* @__PURE__ */ jsxs(MobileCard, { children: [
|
|
2200
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.address"), children: /* @__PURE__ */ jsx(AddressCell, { address: item.address, title: t("common.address") }) }),
|
|
2201
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.type"), children: /* @__PURE__ */ jsx(
|
|
2202
|
+
TooltipCell,
|
|
2203
|
+
{
|
|
2204
|
+
text: typeInfo.text,
|
|
2205
|
+
tooltip: typeInfo.tooltip,
|
|
2206
|
+
title: t("common.type")
|
|
2207
|
+
}
|
|
2208
|
+
) }),
|
|
2209
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("affiliate.boundAt"), align: "end", children: /* @__PURE__ */ jsx(Text, { size: "sm", children: formatYMDTime(item.code_binding_time) }) }),
|
|
2210
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("affiliate.referralCodes"), children: /* @__PURE__ */ jsx(Text, { size: "sm", children: item.bind_code }) }),
|
|
2211
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("affiliate.referralCodes.column.you&Referee"), children: /* @__PURE__ */ jsxs(Text, { size: "sm", children: [
|
|
2212
|
+
getRebateRateText(item.referral_rebate_rate) + "/",
|
|
2213
|
+
/* @__PURE__ */ jsxs("span", { className: "oui-text-base-contrast-54", children: [
|
|
2214
|
+
getRebateRateText(item.referee_rebate_rate),
|
|
2215
|
+
" "
|
|
2216
|
+
] }),
|
|
2217
|
+
!item.is_default_rate && /* @__PURE__ */ jsx("span", { className: "oui-text-primary-light", children: `(${t("affiliate.customized")})` })
|
|
2218
|
+
] }) }),
|
|
2219
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("affiliate.networkSize"), align: "end", children: /* @__PURE__ */ jsx(
|
|
2220
|
+
BreakdownCell,
|
|
2221
|
+
{
|
|
2222
|
+
total: item.network_size,
|
|
2223
|
+
direct: item.direct_invites,
|
|
2224
|
+
indirect: item.indirect_invites,
|
|
2225
|
+
title: t("affiliate.networkSize")
|
|
2226
|
+
}
|
|
2227
|
+
) }),
|
|
2228
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.volume"), children: /* @__PURE__ */ jsx(
|
|
2229
|
+
BreakdownCell,
|
|
2230
|
+
{
|
|
2231
|
+
total: item.volume,
|
|
2232
|
+
direct: item.direct_volume,
|
|
2233
|
+
indirect: item.indirect_volume,
|
|
2234
|
+
prefix: "$",
|
|
2235
|
+
fix: 2,
|
|
2236
|
+
title: t("common.volume")
|
|
2237
|
+
}
|
|
2238
|
+
) }),
|
|
2239
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("affiliate.commission"), children: /* @__PURE__ */ jsx(
|
|
2240
|
+
BreakdownCell,
|
|
2241
|
+
{
|
|
2242
|
+
total: item.commission,
|
|
2243
|
+
direct: item.direct_rebate,
|
|
2244
|
+
indirect: item.indirect_rebate,
|
|
2245
|
+
directBonus: item.direct_bonus_rebate,
|
|
2246
|
+
prefix: "$",
|
|
2247
|
+
fix: 6,
|
|
2248
|
+
title: t("affiliate.commission")
|
|
2249
|
+
}
|
|
2250
|
+
) }),
|
|
2251
|
+
/* @__PURE__ */ jsx(
|
|
2252
|
+
MobileCell,
|
|
2253
|
+
{
|
|
2254
|
+
label: t("common.action"),
|
|
2255
|
+
align: "end",
|
|
2256
|
+
className: "oui-col-start-3",
|
|
2257
|
+
children: item.bind_type !== "legacy" && /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
2258
|
+
/* @__PURE__ */ jsx(
|
|
2259
|
+
Text,
|
|
2260
|
+
{
|
|
2261
|
+
className: "oui-cursor-pointer oui-text-primary-light",
|
|
2262
|
+
onClick: () => onEditReferee("edit" /* Edit */, item),
|
|
2263
|
+
children: t("common.edit")
|
|
2264
|
+
}
|
|
2265
|
+
),
|
|
2266
|
+
!item.is_default_rate && /* @__PURE__ */ jsx(
|
|
2267
|
+
Text,
|
|
2268
|
+
{
|
|
2269
|
+
className: "oui-cursor-pointer oui-text-primary-light",
|
|
2270
|
+
onClick: () => onEditReferee("reset" /* Reset */, item),
|
|
2271
|
+
children: t("common.reset")
|
|
2272
|
+
}
|
|
2273
|
+
)
|
|
2274
|
+
] })
|
|
2275
|
+
}
|
|
2276
|
+
)
|
|
2277
|
+
] });
|
|
2278
|
+
};
|
|
2279
|
+
var RefereesTableUI = (props) => {
|
|
2280
|
+
const { t } = useTranslation();
|
|
2281
|
+
const { isMobile } = useScreen();
|
|
2282
|
+
const showPagination = (props.refereesPagination?.count ?? 0) >= 10;
|
|
2283
|
+
const refereeColumns = useMemo(() => {
|
|
2284
|
+
return [
|
|
2285
|
+
{
|
|
2286
|
+
title: t("common.address"),
|
|
2287
|
+
dataIndex: "address",
|
|
2288
|
+
render: (value) => /* @__PURE__ */ jsx(AddressCell, { address: value, title: t("common.address") })
|
|
2289
|
+
},
|
|
2290
|
+
{
|
|
2291
|
+
title: t("common.type"),
|
|
2292
|
+
dataIndex: "bind_type",
|
|
2293
|
+
render: (_, record) => {
|
|
2294
|
+
const typeInfo = getRefereeType(record.bind_type);
|
|
2295
|
+
return /* @__PURE__ */ jsx(
|
|
2296
|
+
TooltipCell,
|
|
2297
|
+
{
|
|
2298
|
+
text: typeInfo.text,
|
|
2299
|
+
tooltip: typeInfo.tooltip,
|
|
2300
|
+
title: t("common.type")
|
|
2301
|
+
}
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2304
|
+
},
|
|
2305
|
+
{
|
|
2306
|
+
title: t("affiliate.boundAt"),
|
|
2307
|
+
dataIndex: "code_binding_time",
|
|
2308
|
+
render: (value) => /* @__PURE__ */ jsx(Text, { children: formatYMDTime(value) })
|
|
2309
|
+
},
|
|
2310
|
+
{
|
|
2311
|
+
title: t("affiliate.referralCodes"),
|
|
2312
|
+
dataIndex: "bind_code",
|
|
2313
|
+
render: (value) => /* @__PURE__ */ jsx(Text, { children: value })
|
|
2314
|
+
},
|
|
2315
|
+
{
|
|
2316
|
+
title: t("affiliate.referralCodes.column.you&Referee"),
|
|
2317
|
+
dataIndex: "referee_rebate_rate",
|
|
2318
|
+
render: (_, record) => /* @__PURE__ */ jsxs(Text, { children: [
|
|
2319
|
+
getRebateRateText(record.referral_rebate_rate) + "/",
|
|
2320
|
+
/* @__PURE__ */ jsxs("span", { className: "oui-text-base-contrast-54", children: [
|
|
2321
|
+
getRebateRateText(record.referee_rebate_rate),
|
|
2322
|
+
" "
|
|
2323
|
+
] }),
|
|
2324
|
+
!record.is_default_rate && /* @__PURE__ */ jsx("span", { className: "oui-text-primary-light", children: `(${t("affiliate.customized")})` })
|
|
2325
|
+
] }),
|
|
2326
|
+
onSort: true
|
|
2327
|
+
},
|
|
2328
|
+
{
|
|
2329
|
+
title: t("affiliate.networkSize"),
|
|
2330
|
+
dataIndex: "network_size",
|
|
2331
|
+
render: (_, record) => /* @__PURE__ */ jsx(
|
|
2332
|
+
BreakdownCell,
|
|
2333
|
+
{
|
|
2334
|
+
total: record.network_size,
|
|
2335
|
+
direct: record.direct_invites,
|
|
2336
|
+
indirect: record.indirect_invites,
|
|
2337
|
+
title: t("affiliate.networkSize")
|
|
2338
|
+
}
|
|
2339
|
+
),
|
|
2340
|
+
onSort: true
|
|
2341
|
+
},
|
|
2342
|
+
{
|
|
2343
|
+
title: t("common.volume"),
|
|
2344
|
+
dataIndex: "volume",
|
|
2345
|
+
render: (_, record) => /* @__PURE__ */ jsx(
|
|
2346
|
+
BreakdownCell,
|
|
2347
|
+
{
|
|
2348
|
+
total: record.volume,
|
|
2349
|
+
direct: record.direct_volume,
|
|
2350
|
+
indirect: record.indirect_volume,
|
|
2351
|
+
prefix: "$",
|
|
2352
|
+
fix: 2,
|
|
2353
|
+
title: t("common.volume")
|
|
2354
|
+
}
|
|
2355
|
+
),
|
|
2356
|
+
onSort: true
|
|
2357
|
+
},
|
|
2358
|
+
{
|
|
2359
|
+
title: t("affiliate.commission"),
|
|
2360
|
+
dataIndex: "commission",
|
|
2361
|
+
render: (_, record) => /* @__PURE__ */ jsx(
|
|
2362
|
+
BreakdownCell,
|
|
2363
|
+
{
|
|
2364
|
+
total: record.commission,
|
|
2365
|
+
direct: record.direct_rebate,
|
|
2366
|
+
indirect: record.indirect_rebate,
|
|
2367
|
+
directBonus: record.direct_bonus_rebate,
|
|
2368
|
+
prefix: "$",
|
|
2369
|
+
fix: 6,
|
|
2370
|
+
title: t("affiliate.commission")
|
|
2371
|
+
}
|
|
2372
|
+
),
|
|
2373
|
+
onSort: true
|
|
2374
|
+
},
|
|
2375
|
+
{
|
|
2376
|
+
title: t("common.action"),
|
|
2377
|
+
dataIndex: "action",
|
|
2378
|
+
render: (_, record) => record.bind_type !== "legacy" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2379
|
+
/* @__PURE__ */ jsx(
|
|
2380
|
+
Text,
|
|
2381
|
+
{
|
|
2382
|
+
className: "oui-cursor-pointer oui-text-primary-light",
|
|
2383
|
+
onClick: () => props.onEditReferee("edit" /* Edit */, record),
|
|
2384
|
+
children: t("common.edit")
|
|
2385
|
+
}
|
|
2386
|
+
),
|
|
2387
|
+
!record.is_default_rate && /* @__PURE__ */ jsx(
|
|
2388
|
+
Text,
|
|
2389
|
+
{
|
|
2390
|
+
className: "oui-ml-2 oui-cursor-pointer oui-text-primary-light",
|
|
2391
|
+
onClick: () => props.onEditReferee("reset" /* Reset */, record),
|
|
2392
|
+
children: t("common.reset")
|
|
2393
|
+
}
|
|
2394
|
+
)
|
|
2395
|
+
] }) : null
|
|
2396
|
+
}
|
|
2397
|
+
];
|
|
2398
|
+
}, [t, props.onEditReferee]);
|
|
2399
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isMobile ? /* @__PURE__ */ jsx("div", { className: "oui-flex oui-flex-col oui-px-4", children: /* @__PURE__ */ jsx(
|
|
2400
|
+
ListView,
|
|
2401
|
+
{
|
|
2402
|
+
dataSource: props.refereesData,
|
|
2403
|
+
contentClassName: "!oui-space-y-0 oui-pb-3",
|
|
2404
|
+
renderItem: (item, index) => /* @__PURE__ */ jsxs("div", { children: [
|
|
2405
|
+
/* @__PURE__ */ jsx(
|
|
2406
|
+
MobileRefereeItem,
|
|
2407
|
+
{
|
|
2408
|
+
item,
|
|
2409
|
+
onEditReferee: props.onEditReferee
|
|
2410
|
+
}
|
|
2411
|
+
),
|
|
2412
|
+
/* @__PURE__ */ jsx(Divider, { intensity: 8 })
|
|
2413
|
+
] }, index)
|
|
2414
|
+
}
|
|
2415
|
+
) }) : /* @__PURE__ */ jsx("div", { className: `oui-px-3 ${showPagination ? "" : "oui-pb-3"}`, children: /* @__PURE__ */ jsx(
|
|
2416
|
+
AuthGuardDataTable,
|
|
2417
|
+
{
|
|
2418
|
+
bordered: true,
|
|
2419
|
+
columns: refereeColumns,
|
|
2420
|
+
dataSource: props.refereesData,
|
|
2421
|
+
loading: props.isRefereesLoading,
|
|
2422
|
+
pagination: showPagination ? props.refereesPagination : void 0,
|
|
2423
|
+
onSort: props.onRefereesSort,
|
|
2424
|
+
onRow: () => ({ className: "oui-h-12" }),
|
|
2425
|
+
className: "[&_.oui-h-10.oui-w-full]:!oui-mx-0 [&_.oui-table-pagination]:!oui-justify-end [&_th]:!oui-tracking-[0.03em] [&_th]:!oui-px-3 [&_td]:!oui-px-3"
|
|
2426
|
+
}
|
|
2427
|
+
) }) });
|
|
2428
|
+
};
|
|
2429
|
+
var RefereesTableWidget = (props) => {
|
|
2430
|
+
const state = useRefereesTableScript(props);
|
|
2431
|
+
return /* @__PURE__ */ jsx(RefereesTableUI, { ...state });
|
|
2432
|
+
};
|
|
2433
|
+
var useMultiLevelReferralCodes = () => {
|
|
2434
|
+
const { referralInfo } = useReferralContext();
|
|
2435
|
+
const { data: multiLevelRebateInfo } = useMultiLevelRebateInfo();
|
|
2436
|
+
const [refereesData] = useRefereeInfo({});
|
|
2437
|
+
const copyCode = (code) => {
|
|
2438
|
+
copyText(code);
|
|
2439
|
+
};
|
|
2440
|
+
const singleLevelTotals = useMemo(() => {
|
|
2441
|
+
const totalsMap = /* @__PURE__ */ new Map();
|
|
2442
|
+
if (refereesData) {
|
|
2443
|
+
refereesData.forEach((referee) => {
|
|
2444
|
+
const code = referee?.referral_code;
|
|
2445
|
+
if (!code) return;
|
|
2446
|
+
const existing = totalsMap.get(code) || { volume: 0, commission: 0 };
|
|
2447
|
+
totalsMap.set(code, {
|
|
2448
|
+
volume: existing.volume + (referee?.volume || 0),
|
|
2449
|
+
commission: existing.commission + (referee?.referral_rebate || 0)
|
|
2450
|
+
});
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
return totalsMap;
|
|
2454
|
+
}, [refereesData]);
|
|
2455
|
+
const codes = useMemo(() => {
|
|
2456
|
+
const allCodes = [];
|
|
2457
|
+
const multiLevelReferralCode = multiLevelRebateInfo?.referral_code;
|
|
2458
|
+
if (multiLevelRebateInfo?.referral_code) {
|
|
2459
|
+
const maxRebateRate = multiLevelRebateInfo.max_rebate_rate ?? 0;
|
|
2460
|
+
const defaultRefereeRebateRate = multiLevelRebateInfo.default_referee_rebate_rate ?? 0;
|
|
2461
|
+
const referrerRebateRate = Math.max(
|
|
2462
|
+
0,
|
|
2463
|
+
maxRebateRate - defaultRefereeRebateRate
|
|
2464
|
+
);
|
|
2465
|
+
const directInvites = multiLevelRebateInfo?.direct_invites ?? 0;
|
|
2466
|
+
const indirectInvites = multiLevelRebateInfo?.indirect_invites ?? 0;
|
|
2467
|
+
const directVolume = multiLevelRebateInfo?.direct_volume ?? 0;
|
|
2468
|
+
const indirectVolume = multiLevelRebateInfo?.indirect_volume ?? 0;
|
|
2469
|
+
const directRebate = multiLevelRebateInfo?.direct_rebate ?? 0;
|
|
2470
|
+
const indirectRebate = multiLevelRebateInfo?.indirect_rebate ?? 0;
|
|
2471
|
+
const directBonusRebate = multiLevelRebateInfo?.direct_bonus_rebate ?? 0;
|
|
2472
|
+
const multiLevelCode = {
|
|
2473
|
+
code: multiLevelRebateInfo.referral_code ?? "",
|
|
2474
|
+
direct_invites: directInvites,
|
|
2475
|
+
indirect_invites: indirectInvites,
|
|
2476
|
+
direct_volume: directVolume,
|
|
2477
|
+
indirect_volume: indirectVolume,
|
|
2478
|
+
direct_rebate: directRebate,
|
|
2479
|
+
indirect_rebate: indirectRebate,
|
|
2480
|
+
direct_bonus_rebate: directBonusRebate,
|
|
2481
|
+
max_rebate_rate: maxRebateRate,
|
|
2482
|
+
referee_rebate_rate: defaultRefereeRebateRate,
|
|
2483
|
+
referrer_rebate_rate: referrerRebateRate,
|
|
2484
|
+
total_invites: directInvites + indirectInvites,
|
|
2485
|
+
total_volume: directVolume + indirectVolume,
|
|
2486
|
+
total_rebate: directRebate + indirectRebate + directBonusRebate,
|
|
2487
|
+
referral_type: "multi"
|
|
2488
|
+
};
|
|
2489
|
+
allCodes.push(multiLevelCode);
|
|
2490
|
+
}
|
|
2491
|
+
if (referralInfo?.referrer_info?.referral_codes) {
|
|
2492
|
+
allCodes.push(
|
|
2493
|
+
...referralInfo.referrer_info.referral_codes.filter(
|
|
2494
|
+
(item) => multiLevelReferralCode ? item.code !== multiLevelReferralCode : true
|
|
2495
|
+
).map((item) => {
|
|
2496
|
+
const totals = singleLevelTotals.get(item.code);
|
|
2497
|
+
const totalVolume = totals?.volume ?? item.total_volume ?? 0;
|
|
2498
|
+
const totalRebate = totals?.commission ?? item.total_rebate ?? 0;
|
|
2499
|
+
const totalInvites = item.total_invites ?? 0;
|
|
2500
|
+
const row = {
|
|
2501
|
+
code: item.code,
|
|
2502
|
+
referral_type: "single",
|
|
2503
|
+
direct_invites: totalInvites,
|
|
2504
|
+
indirect_invites: 0,
|
|
2505
|
+
direct_volume: totalVolume,
|
|
2506
|
+
indirect_volume: 0,
|
|
2507
|
+
direct_rebate: totalRebate,
|
|
2508
|
+
indirect_rebate: 0,
|
|
2509
|
+
max_rebate_rate: item.max_rebate_rate ?? 0,
|
|
2510
|
+
referee_rebate_rate: item.referee_rebate_rate ?? 0,
|
|
2511
|
+
referrer_rebate_rate: item.referrer_rebate_rate ?? 0,
|
|
2512
|
+
total_invites: totalInvites,
|
|
2513
|
+
total_volume: totalVolume,
|
|
2514
|
+
total_rebate: totalRebate
|
|
2515
|
+
};
|
|
2516
|
+
return row;
|
|
2517
|
+
})
|
|
2518
|
+
);
|
|
2519
|
+
}
|
|
2520
|
+
if (allCodes.length === 0) return void 0;
|
|
2521
|
+
return allCodes;
|
|
2522
|
+
}, [
|
|
2523
|
+
referralInfo?.referrer_info?.referral_codes,
|
|
2524
|
+
multiLevelRebateInfo,
|
|
2525
|
+
singleLevelTotals
|
|
2526
|
+
]);
|
|
2527
|
+
return {
|
|
2528
|
+
codes,
|
|
2529
|
+
copyCode
|
|
2530
|
+
};
|
|
2531
|
+
};
|
|
2532
|
+
|
|
2533
|
+
// src/pages/multiLevel/affiliate/referrerTable/referralCodesTable/referralCodesTable.script.ts
|
|
2534
|
+
var useReferralCodesTableScript = (props = {}) => {
|
|
2535
|
+
const { enabled = true } = props;
|
|
2536
|
+
const { codes, copyCode } = useMultiLevelReferralCodes();
|
|
2537
|
+
const [sort, setSort] = useState(null);
|
|
2538
|
+
const sortedCodes = useMemo(() => {
|
|
2539
|
+
if (!enabled) return void 0;
|
|
2540
|
+
if (!codes || !sort) return codes;
|
|
2541
|
+
const sortableCodes = codes.map((code, index) => ({
|
|
2542
|
+
code,
|
|
2543
|
+
index
|
|
2544
|
+
}));
|
|
2545
|
+
sortableCodes.sort((a, b) => {
|
|
2546
|
+
const valA = Number(a.code[sort.key] ?? 0);
|
|
2547
|
+
const valB = Number(b.code[sort.key] ?? 0);
|
|
2548
|
+
if (valA < valB) return sort.order === "asc" ? -1 : 1;
|
|
2549
|
+
if (valA > valB) return sort.order === "asc" ? 1 : -1;
|
|
2550
|
+
return a.index - b.index;
|
|
2551
|
+
});
|
|
2552
|
+
return sortableCodes.map((item) => item.code);
|
|
2553
|
+
}, [codes, enabled, sort]);
|
|
2554
|
+
const onSort = (sort2) => {
|
|
2555
|
+
if (!sort2) {
|
|
2556
|
+
setSort(null);
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
const sortKey = sort2.sortKey;
|
|
2560
|
+
if (sortKey && (sortKey === "total_invites" || sortKey === "total_volume" || sortKey === "total_rebate")) {
|
|
2561
|
+
setSort({
|
|
2562
|
+
key: sortKey,
|
|
2563
|
+
order: sort2.sort === "asc" ? "asc" : "desc"
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
};
|
|
2567
|
+
return {
|
|
2568
|
+
codes,
|
|
2569
|
+
sortedCodes,
|
|
2570
|
+
copyCode,
|
|
2571
|
+
onSort,
|
|
2572
|
+
isLoading: enabled && !codes
|
|
2573
|
+
};
|
|
2574
|
+
};
|
|
2575
|
+
var getReferralCodeType = (referralType) => {
|
|
2576
|
+
const { t } = useTranslation();
|
|
2577
|
+
if (referralType === "multi") {
|
|
2578
|
+
return {
|
|
2579
|
+
text: t("affiliate.multiLevel"),
|
|
2580
|
+
tooltip: t("affiliate.multiLevel.tooltip")
|
|
2581
|
+
};
|
|
2582
|
+
}
|
|
2583
|
+
return {
|
|
2584
|
+
text: t("affiliate.singleLevelLegacy"),
|
|
2585
|
+
tooltip: t("affiliate.singleLevelLegacy.tooltip")
|
|
2586
|
+
};
|
|
2587
|
+
};
|
|
2588
|
+
var MobileReferralCodeItem = ({ item, copyCode }) => {
|
|
2589
|
+
const { t } = useTranslation();
|
|
2590
|
+
const referrerRate = new Decimal(item.referrer_rebate_rate ?? 0).mul(100).toFixed(0);
|
|
2591
|
+
const refereeRate = new Decimal(item.referee_rebate_rate ?? 0).mul(100).toFixed(0);
|
|
2592
|
+
const typeInfo = getReferralCodeType(item.referral_type);
|
|
2593
|
+
return /* @__PURE__ */ jsxs(MobileCard, { children: [
|
|
2594
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("affiliate.referralCode"), children: /* @__PURE__ */ jsx(Text, { children: item.code || "" }) }),
|
|
2595
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.type"), children: /* @__PURE__ */ jsx(
|
|
2596
|
+
TooltipCell,
|
|
2597
|
+
{
|
|
2598
|
+
text: typeInfo.text,
|
|
2599
|
+
tooltip: typeInfo.tooltip,
|
|
2600
|
+
title: t("common.type")
|
|
2601
|
+
}
|
|
2602
|
+
) }),
|
|
2603
|
+
/* @__PURE__ */ jsx(
|
|
2604
|
+
MobileCell,
|
|
2605
|
+
{
|
|
2606
|
+
label: t("affiliate.referralCodes.column.you&Referee"),
|
|
2607
|
+
align: "end",
|
|
2608
|
+
children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
2609
|
+
referrerRate,
|
|
2610
|
+
"%/",
|
|
2611
|
+
/* @__PURE__ */ jsxs("span", { className: "oui-text-base-contrast-54", children: [
|
|
2612
|
+
refereeRate,
|
|
2613
|
+
"%"
|
|
2614
|
+
] })
|
|
2615
|
+
] })
|
|
2616
|
+
}
|
|
2617
|
+
),
|
|
2618
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("affiliate.networkSize"), children: /* @__PURE__ */ jsx(
|
|
2619
|
+
BreakdownCell,
|
|
2620
|
+
{
|
|
2621
|
+
total: item.total_invites ?? 0,
|
|
2622
|
+
direct: item.direct_invites ?? 0,
|
|
2623
|
+
indirect: item.indirect_invites ?? 0,
|
|
2624
|
+
title: t("affiliate.networkSize")
|
|
2625
|
+
}
|
|
2626
|
+
) }),
|
|
2627
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.volume"), children: /* @__PURE__ */ jsx(
|
|
2628
|
+
BreakdownCell,
|
|
2629
|
+
{
|
|
2630
|
+
total: item.total_volume ?? 0,
|
|
2631
|
+
direct: item.direct_volume ?? 0,
|
|
2632
|
+
indirect: item.indirect_volume ?? 0,
|
|
2633
|
+
prefix: "$",
|
|
2634
|
+
fix: 2,
|
|
2635
|
+
title: t("common.volume")
|
|
2636
|
+
}
|
|
2637
|
+
) }),
|
|
2638
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("affiliate.commission"), align: "end", children: /* @__PURE__ */ jsx(
|
|
2639
|
+
BreakdownCell,
|
|
2640
|
+
{
|
|
2641
|
+
total: item.total_rebate ?? 0,
|
|
2642
|
+
direct: item.direct_rebate ?? 0,
|
|
2643
|
+
indirect: item.indirect_rebate ?? 0,
|
|
2644
|
+
directBonus: item.direct_bonus_rebate,
|
|
2645
|
+
prefix: "$",
|
|
2646
|
+
fix: 6,
|
|
2647
|
+
title: t("affiliate.commission")
|
|
2648
|
+
}
|
|
2649
|
+
) }),
|
|
2650
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.action"), children: /* @__PURE__ */ jsx(
|
|
2651
|
+
Text,
|
|
2652
|
+
{
|
|
2653
|
+
className: "oui-cursor-pointer oui-text-primary-light",
|
|
2654
|
+
onClick: (e) => {
|
|
2655
|
+
e.stopPropagation();
|
|
2656
|
+
copyCode(item.code);
|
|
2657
|
+
},
|
|
2658
|
+
children: t("common.copy")
|
|
2659
|
+
}
|
|
2660
|
+
) })
|
|
2661
|
+
] });
|
|
2662
|
+
};
|
|
2663
|
+
var ReferralCodesTableUI = (props) => {
|
|
2664
|
+
const { t } = useTranslation();
|
|
2665
|
+
const { isMobile } = useScreen();
|
|
2666
|
+
const columns = useMemo(() => {
|
|
2667
|
+
return [
|
|
2668
|
+
{
|
|
2669
|
+
title: t("affiliate.referralCode"),
|
|
2670
|
+
dataIndex: "code",
|
|
2671
|
+
render: (value) => /* @__PURE__ */ jsx(Text, { children: value || "" })
|
|
2672
|
+
},
|
|
2673
|
+
{
|
|
2674
|
+
title: t("common.type"),
|
|
2675
|
+
dataIndex: "referral_type",
|
|
2676
|
+
render: (_, record) => {
|
|
2677
|
+
const typeInfo = getReferralCodeType(record.referral_type);
|
|
2678
|
+
return /* @__PURE__ */ jsx(
|
|
2679
|
+
TooltipCell,
|
|
2680
|
+
{
|
|
2681
|
+
text: typeInfo.text,
|
|
2682
|
+
tooltip: typeInfo.tooltip,
|
|
2683
|
+
title: t("common.type")
|
|
2684
|
+
}
|
|
2685
|
+
);
|
|
2686
|
+
}
|
|
2687
|
+
},
|
|
2688
|
+
{
|
|
2689
|
+
title: /* @__PURE__ */ jsxs(Text, { children: [
|
|
2690
|
+
t("affiliate.referralCodes.column.defaultSplit"),
|
|
2691
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
2692
|
+
"(",
|
|
2693
|
+
t("affiliate.referralCodes.column.you&Referee"),
|
|
2694
|
+
")"
|
|
2695
|
+
] }),
|
|
2696
|
+
dataIndex: "rate",
|
|
2697
|
+
render: (_, record) => {
|
|
2698
|
+
const referrerRate = new Decimal(record.referrer_rebate_rate ?? 0).mul(100).toFixed(0);
|
|
2699
|
+
const refereeRate = new Decimal(record.referee_rebate_rate ?? 0).mul(100).toFixed(0);
|
|
2700
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
2701
|
+
referrerRate,
|
|
2702
|
+
"%",
|
|
2703
|
+
/* @__PURE__ */ jsxs("span", { className: "oui-text-base-contrast-54", children: [
|
|
2704
|
+
"/",
|
|
2705
|
+
refereeRate,
|
|
2706
|
+
"%"
|
|
2707
|
+
] })
|
|
2708
|
+
] });
|
|
2709
|
+
}
|
|
2710
|
+
},
|
|
2711
|
+
{
|
|
2712
|
+
title: t("affiliate.networkSize"),
|
|
2713
|
+
dataIndex: "total_invites",
|
|
2714
|
+
render: (_, record) => {
|
|
2715
|
+
return /* @__PURE__ */ jsx(
|
|
2716
|
+
BreakdownCell,
|
|
2717
|
+
{
|
|
2718
|
+
total: record.total_invites ?? 0,
|
|
2719
|
+
direct: record.direct_invites ?? 0,
|
|
2720
|
+
indirect: record.indirect_invites ?? 0,
|
|
2721
|
+
title: t("affiliate.networkSize")
|
|
2722
|
+
}
|
|
2723
|
+
);
|
|
2724
|
+
},
|
|
2725
|
+
onSort: true
|
|
2726
|
+
},
|
|
2727
|
+
{
|
|
2728
|
+
title: t("common.volume"),
|
|
2729
|
+
dataIndex: "total_volume",
|
|
2730
|
+
render: (_, record) => {
|
|
2731
|
+
return /* @__PURE__ */ jsx(
|
|
2732
|
+
BreakdownCell,
|
|
2733
|
+
{
|
|
2734
|
+
total: record.total_volume ?? 0,
|
|
2735
|
+
direct: record.direct_volume ?? 0,
|
|
2736
|
+
indirect: record.indirect_volume ?? 0,
|
|
2737
|
+
prefix: "$",
|
|
2738
|
+
fix: 2,
|
|
2739
|
+
title: t("common.volume")
|
|
2740
|
+
}
|
|
2741
|
+
);
|
|
2742
|
+
},
|
|
2743
|
+
onSort: true
|
|
2744
|
+
},
|
|
2745
|
+
{
|
|
2746
|
+
title: t("affiliate.commission"),
|
|
2747
|
+
dataIndex: "total_rebate",
|
|
2748
|
+
render: (_, record) => {
|
|
2749
|
+
return /* @__PURE__ */ jsx(
|
|
2750
|
+
BreakdownCell,
|
|
2751
|
+
{
|
|
2752
|
+
total: record.total_rebate ?? 0,
|
|
2753
|
+
direct: record.direct_rebate ?? 0,
|
|
2754
|
+
indirect: record.indirect_rebate ?? 0,
|
|
2755
|
+
directBonus: record.direct_bonus_rebate,
|
|
2756
|
+
prefix: "$",
|
|
2757
|
+
fix: 6,
|
|
2758
|
+
title: t("affiliate.commission")
|
|
2759
|
+
}
|
|
2760
|
+
);
|
|
2761
|
+
},
|
|
2762
|
+
onSort: true
|
|
2763
|
+
},
|
|
2764
|
+
{
|
|
2765
|
+
title: t("common.action"),
|
|
2766
|
+
dataIndex: "action",
|
|
2767
|
+
render: (_, record) => /* @__PURE__ */ jsx(
|
|
2768
|
+
Text,
|
|
2769
|
+
{
|
|
2770
|
+
className: "oui-cursor-pointer oui-text-primary-light",
|
|
2771
|
+
onClick: (e) => {
|
|
2772
|
+
e.stopPropagation();
|
|
2773
|
+
props.copyCode(record.code);
|
|
2774
|
+
},
|
|
2775
|
+
children: t("common.copy")
|
|
2776
|
+
}
|
|
2777
|
+
)
|
|
2778
|
+
}
|
|
2779
|
+
];
|
|
2780
|
+
}, [t, props.copyCode]);
|
|
2781
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isMobile ? /* @__PURE__ */ jsx("div", { className: "oui-flex oui-flex-col oui-px-4", children: /* @__PURE__ */ jsx(
|
|
2782
|
+
ListView,
|
|
2783
|
+
{
|
|
2784
|
+
dataSource: props.sortedCodes,
|
|
2785
|
+
contentClassName: "!oui-space-y-0 oui-pb-3",
|
|
2786
|
+
renderItem: (item, index) => /* @__PURE__ */ jsxs("div", { children: [
|
|
2787
|
+
/* @__PURE__ */ jsx(MobileReferralCodeItem, { item, copyCode: props.copyCode }),
|
|
2788
|
+
/* @__PURE__ */ jsx(Divider, { intensity: 8 })
|
|
2789
|
+
] }, index)
|
|
2790
|
+
}
|
|
2791
|
+
) }) : /* @__PURE__ */ jsx("div", { className: "oui-px-3", children: /* @__PURE__ */ jsx(
|
|
2792
|
+
AuthGuardDataTable,
|
|
2793
|
+
{
|
|
2794
|
+
bordered: true,
|
|
2795
|
+
columns,
|
|
2796
|
+
dataSource: props.sortedCodes,
|
|
2797
|
+
loading: props.isLoading,
|
|
2798
|
+
onSort: props.onSort,
|
|
2799
|
+
onRow: () => ({ className: "oui-h-12" }),
|
|
2800
|
+
className: "oui-pb-3 [&_.oui-h-10.oui-w-full]:!oui-mx-0 [&_.oui-table-pagination]:!oui-justify-end [&_th]:!oui-tracking-[0.03em] [&_th]:!oui-px-3 [&_td]:!oui-px-3"
|
|
2801
|
+
}
|
|
2802
|
+
) }) });
|
|
2803
|
+
};
|
|
2804
|
+
var ReferralCodesTableWidget = (props) => {
|
|
2805
|
+
const state = useReferralCodesTableScript(props);
|
|
2806
|
+
return /* @__PURE__ */ jsx(ReferralCodesTableUI, { ...state });
|
|
2807
|
+
};
|
|
2808
|
+
var ReferrerTableUI = (props) => {
|
|
2809
|
+
const { t } = useTranslation();
|
|
2810
|
+
return /* @__PURE__ */ jsx(
|
|
2811
|
+
Flex,
|
|
2812
|
+
{
|
|
2813
|
+
direction: "column",
|
|
2814
|
+
className: "oui-rounded-2xl oui-bg-base-9 [&_td]:oui-font-medium [&_td]:oui-tracking-[0.03em] [&_th]:oui-font-semibold",
|
|
2815
|
+
px: 3,
|
|
2816
|
+
pt: 4,
|
|
2817
|
+
gap: 4,
|
|
2818
|
+
width: "100%",
|
|
2819
|
+
children: /* @__PURE__ */ jsxs(
|
|
2820
|
+
Tabs,
|
|
2821
|
+
{
|
|
2822
|
+
value: props.activeTab,
|
|
2823
|
+
onValueChange: (value) => props.setActiveTab(value),
|
|
2824
|
+
className: "oui-w-full oui-text-base",
|
|
2825
|
+
variant: "text",
|
|
2826
|
+
classNames: {
|
|
2827
|
+
tabsListContainer: "oui-px-3",
|
|
2828
|
+
trigger: "oui-pb-[9px] oui-tracking-[0.01em]",
|
|
2829
|
+
scrollIndicator: "[&_.oui-scroll-indicator-leading]:oui-hidden [&_.oui-scroll-indicator-tailing]:oui-hidden"
|
|
2830
|
+
},
|
|
2831
|
+
showScrollIndicator: true,
|
|
2832
|
+
children: [
|
|
2833
|
+
/* @__PURE__ */ jsx(TabPanel, { value: "commission", title: t("affiliate.commission"), children: /* @__PURE__ */ jsx(CommissionTableWidget, { enabled: props.activeTab === "commission" }) }),
|
|
2834
|
+
/* @__PURE__ */ jsx(TabPanel, { value: "referees", title: t("affiliate.referees"), children: /* @__PURE__ */ jsx(RefereesTableWidget, { enabled: props.activeTab === "referees" }) }),
|
|
2835
|
+
/* @__PURE__ */ jsx(TabPanel, { value: "codes", title: t("affiliate.referralCodes"), children: /* @__PURE__ */ jsx(ReferralCodesTableWidget, { enabled: props.activeTab === "codes" }) })
|
|
2836
|
+
]
|
|
2837
|
+
}
|
|
2838
|
+
)
|
|
2839
|
+
}
|
|
2840
|
+
);
|
|
2841
|
+
};
|
|
2842
|
+
var ReferrerTableWidget = () => {
|
|
2843
|
+
const state = useReferrerTableScript();
|
|
2844
|
+
return /* @__PURE__ */ jsx(ReferrerTableUI, { ...state });
|
|
2845
|
+
};
|
|
2846
|
+
var Summary = (props) => {
|
|
2847
|
+
const { statistics } = props;
|
|
2848
|
+
const { t } = useTranslation();
|
|
2849
|
+
return /* @__PURE__ */ jsxs(
|
|
2850
|
+
Flex,
|
|
2851
|
+
{
|
|
2852
|
+
id: "oui-affiliate-affiliate-summary",
|
|
2853
|
+
r: "2xl",
|
|
2854
|
+
p: 5,
|
|
2855
|
+
width: "100%",
|
|
2856
|
+
height: "100%",
|
|
2857
|
+
gap: 6,
|
|
2858
|
+
direction: "column",
|
|
2859
|
+
intensity: 900,
|
|
2860
|
+
className: "oui-border oui-border-line-6",
|
|
2861
|
+
children: [
|
|
2862
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
2863
|
+
/* @__PURE__ */ jsx(Text, { className: "oui-text-lg", children: t("affiliate.summary") }),
|
|
2864
|
+
/* @__PURE__ */ jsx("div", { className: "oui-min-w-14", children: /* @__PURE__ */ jsx(
|
|
2865
|
+
Select.options,
|
|
2866
|
+
{
|
|
2867
|
+
size: "xs",
|
|
2868
|
+
value: props.period,
|
|
2869
|
+
onValueChange: props.onPeriodChange,
|
|
2870
|
+
options: props.periodTypes
|
|
2871
|
+
}
|
|
2872
|
+
) })
|
|
2873
|
+
] }),
|
|
2874
|
+
/* @__PURE__ */ jsx(
|
|
2875
|
+
SummaryItem,
|
|
2876
|
+
{
|
|
2877
|
+
prefix: "$",
|
|
2878
|
+
rule: "human",
|
|
2879
|
+
label: `${t("affiliate.commission")} (USDC)`,
|
|
2880
|
+
value: statistics.total_rebate,
|
|
2881
|
+
direct: statistics.direct_rebate + statistics.direct_bonus_rebate,
|
|
2882
|
+
indirect: statistics.indirect_rebate,
|
|
2883
|
+
classNames: {
|
|
2884
|
+
root: "!oui-py-12",
|
|
2885
|
+
value: "oui-text-trade-profit",
|
|
2886
|
+
direct: "oui-text-trade-profit",
|
|
2887
|
+
indirect: "oui-text-trade-profit"
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
),
|
|
2891
|
+
/* @__PURE__ */ jsxs(Flex, { width: "100%", gap: 6, className: "oui-flex-col md:oui-flex-row", children: [
|
|
2892
|
+
/* @__PURE__ */ jsx(
|
|
2893
|
+
SummaryItem,
|
|
2894
|
+
{
|
|
2895
|
+
prefix: "$",
|
|
2896
|
+
rule: "human",
|
|
2897
|
+
label: `${t("affiliate.referralVol")} (USDC)`,
|
|
2898
|
+
value: statistics.total_volume,
|
|
2899
|
+
direct: statistics.direct_volume,
|
|
2900
|
+
indirect: statistics.indirect_volume,
|
|
2901
|
+
classNames: {
|
|
2902
|
+
root: "oui-w-full md:oui-w-1/2"
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
),
|
|
2906
|
+
/* @__PURE__ */ jsx(
|
|
2907
|
+
SummaryItem,
|
|
2908
|
+
{
|
|
2909
|
+
dp: 0,
|
|
2910
|
+
label: t("affiliate.referrals"),
|
|
2911
|
+
value: statistics.total_invites,
|
|
2912
|
+
direct: statistics.direct_invites,
|
|
2913
|
+
indirect: statistics.indirect_invites,
|
|
2914
|
+
classNames: {
|
|
2915
|
+
root: "oui-w-full md:oui-w-1/2"
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
)
|
|
2919
|
+
] })
|
|
2920
|
+
]
|
|
2921
|
+
}
|
|
2922
|
+
);
|
|
2923
|
+
};
|
|
2924
|
+
var SummaryItem = (props) => {
|
|
2925
|
+
const { t } = useTranslation();
|
|
2926
|
+
const { rule, dp = 2 } = props;
|
|
2927
|
+
return /* @__PURE__ */ jsxs(
|
|
2928
|
+
Flex,
|
|
2929
|
+
{
|
|
2930
|
+
r: "2xl",
|
|
2931
|
+
width: "100%",
|
|
2932
|
+
direction: "column",
|
|
2933
|
+
itemAlign: "start",
|
|
2934
|
+
gap: 2,
|
|
2935
|
+
className: cn(
|
|
2936
|
+
"oui-bg-base-contrast-4 oui-p-5 md:oui-py-[38px]",
|
|
2937
|
+
"oui-text-sm oui-text-base-contrast-54",
|
|
2938
|
+
props.classNames?.root
|
|
2939
|
+
),
|
|
2940
|
+
children: [
|
|
2941
|
+
/* @__PURE__ */ jsx(Text, { children: props.label }),
|
|
2942
|
+
/* @__PURE__ */ jsx(
|
|
2943
|
+
Text.numeral,
|
|
2944
|
+
{
|
|
2945
|
+
rule,
|
|
2946
|
+
dp: props.dp,
|
|
2947
|
+
size: "3xl",
|
|
2948
|
+
prefix: props.prefix,
|
|
2949
|
+
placeholder: "--",
|
|
2950
|
+
intensity: 98,
|
|
2951
|
+
className: props.classNames?.value,
|
|
2952
|
+
children: props.value
|
|
2953
|
+
}
|
|
2954
|
+
),
|
|
2955
|
+
/* @__PURE__ */ jsxs(Flex, { className: "oui-flex-wrap oui-text-base-contrast-54", children: [
|
|
2956
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
|
|
2957
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
2958
|
+
t("affiliate.direct"),
|
|
2959
|
+
":"
|
|
2960
|
+
] }),
|
|
2961
|
+
/* @__PURE__ */ jsx(
|
|
2962
|
+
Text.numeral,
|
|
2963
|
+
{
|
|
2964
|
+
rule,
|
|
2965
|
+
dp: props.dp,
|
|
2966
|
+
prefix: props.prefix,
|
|
2967
|
+
intensity: 54,
|
|
2968
|
+
className: props.classNames?.direct,
|
|
2969
|
+
children: props.direct
|
|
2970
|
+
}
|
|
2971
|
+
)
|
|
2972
|
+
] }),
|
|
2973
|
+
"/",
|
|
2974
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
|
|
2975
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
2976
|
+
t("affiliate.indirect"),
|
|
2977
|
+
":"
|
|
2978
|
+
] }),
|
|
2979
|
+
/* @__PURE__ */ jsx(
|
|
2980
|
+
Text.numeral,
|
|
2981
|
+
{
|
|
2982
|
+
rule,
|
|
2983
|
+
dp: props.dp,
|
|
2984
|
+
prefix: props.prefix,
|
|
2985
|
+
intensity: 54,
|
|
2986
|
+
className: props.classNames?.indirect,
|
|
2987
|
+
children: props.indirect
|
|
2988
|
+
}
|
|
2989
|
+
)
|
|
2990
|
+
] })
|
|
2991
|
+
] })
|
|
2992
|
+
]
|
|
2993
|
+
}
|
|
2994
|
+
);
|
|
2995
|
+
};
|
|
2996
|
+
var useSummaryScript = () => {
|
|
2997
|
+
const { t } = useTranslation();
|
|
2998
|
+
const [period, setPeriod] = useState("all_time" /* All */);
|
|
2999
|
+
const { data } = useMultiLevelStatistics(period);
|
|
3000
|
+
const periodTypes = [
|
|
3001
|
+
{ label: t("common.all"), value: "all_time" /* All */ },
|
|
3002
|
+
{ label: t("common.select.1d"), value: "1d" /* 1d */ },
|
|
3003
|
+
{ label: t("common.select.7d"), value: "7d" /* 7d */ },
|
|
3004
|
+
{ label: t("common.select.30d"), value: "30d" /* 30d */ }
|
|
3005
|
+
];
|
|
3006
|
+
const onPeriodChange = (item) => {
|
|
3007
|
+
setPeriod(item);
|
|
3008
|
+
};
|
|
3009
|
+
const statistics = useMemo(() => {
|
|
3010
|
+
const {
|
|
3011
|
+
direct_invites = 0,
|
|
3012
|
+
indirect_invites = 0,
|
|
3013
|
+
direct_traded = 0,
|
|
3014
|
+
indirect_traded = 0,
|
|
3015
|
+
direct_volume = 0,
|
|
3016
|
+
indirect_volume = 0,
|
|
3017
|
+
direct_rebate = 0,
|
|
3018
|
+
indirect_rebate = 0,
|
|
3019
|
+
direct_bonus_rebate = 0
|
|
3020
|
+
} = data || {};
|
|
215
3021
|
return {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
isLoading,
|
|
230
|
-
wrongNetwork,
|
|
231
|
-
disabledConnect,
|
|
232
|
-
setShowHome,
|
|
233
|
-
setTab,
|
|
234
|
-
mutate: memoMutate,
|
|
235
|
-
onBecomeAnAffiliate,
|
|
236
|
-
bindReferralCodeState,
|
|
237
|
-
onLearnAffiliate,
|
|
238
|
-
showReferralPage,
|
|
239
|
-
splashPage
|
|
3022
|
+
direct_invites,
|
|
3023
|
+
indirect_invites,
|
|
3024
|
+
total_invites: direct_invites + indirect_invites,
|
|
3025
|
+
direct_traded,
|
|
3026
|
+
indirect_traded,
|
|
3027
|
+
total_traded: direct_traded + indirect_traded,
|
|
3028
|
+
direct_volume,
|
|
3029
|
+
indirect_volume,
|
|
3030
|
+
total_volume: direct_volume + indirect_volume,
|
|
3031
|
+
direct_rebate,
|
|
3032
|
+
indirect_rebate,
|
|
3033
|
+
direct_bonus_rebate,
|
|
3034
|
+
total_rebate: direct_rebate + indirect_rebate + direct_bonus_rebate
|
|
240
3035
|
};
|
|
241
|
-
}, [
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
3036
|
+
}, [data]);
|
|
3037
|
+
return {
|
|
3038
|
+
period,
|
|
3039
|
+
periodTypes,
|
|
3040
|
+
onPeriodChange,
|
|
3041
|
+
statistics
|
|
3042
|
+
};
|
|
3043
|
+
};
|
|
3044
|
+
var SummaryWidget = () => {
|
|
3045
|
+
const state = useSummaryScript();
|
|
3046
|
+
return /* @__PURE__ */ jsx(Summary, { ...state });
|
|
3047
|
+
};
|
|
3048
|
+
var MultiLevelAffiliatePage = () => {
|
|
3049
|
+
const { t } = useTranslation();
|
|
3050
|
+
const { multiLevelRebateInfo } = useReferralContext();
|
|
3051
|
+
return /* @__PURE__ */ jsx(
|
|
3052
|
+
Flex,
|
|
3053
|
+
{
|
|
3054
|
+
id: "oui-affiliate-affiliate-page",
|
|
3055
|
+
className: cn("oui-h-lvw", "oui-font-semibold", "oui-pb-24 oui-pt-16"),
|
|
3056
|
+
direction: "column",
|
|
3057
|
+
gap: 4,
|
|
3058
|
+
children: /* @__PURE__ */ jsx("div", { className: "oui-w-full oui-px-5 md:oui-mx-auto md:oui-max-w-[1040px]", children: /* @__PURE__ */ jsxs(
|
|
3059
|
+
Flex,
|
|
3060
|
+
{
|
|
3061
|
+
width: "100%",
|
|
3062
|
+
direction: "column",
|
|
3063
|
+
className: "oui-gap-8 md:oui-gap-10",
|
|
3064
|
+
children: [
|
|
3065
|
+
/* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 4, children: [
|
|
3066
|
+
/* @__PURE__ */ jsx(Text, { className: "oui-text-[32px] oui-leading-[40px] md:oui-text-6xl md:oui-leading-[72px]", children: t("affiliate.earnReferralCommissions") }),
|
|
3067
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", intensity: 54, children: t("affiliate.earnReferralCommissions.description") })
|
|
3068
|
+
] }),
|
|
3069
|
+
/* @__PURE__ */ jsxs(
|
|
3070
|
+
Grid,
|
|
3071
|
+
{
|
|
3072
|
+
width: "100%",
|
|
3073
|
+
height: "100%",
|
|
3074
|
+
gap: 6,
|
|
3075
|
+
cols: 1,
|
|
3076
|
+
rows: 1,
|
|
3077
|
+
className: "md:oui-grid-cols-2",
|
|
3078
|
+
children: [
|
|
3079
|
+
/* @__PURE__ */ jsx("div", { className: "oui-order-2 md:oui-order-1", children: /* @__PURE__ */ jsx(SummaryWidget, {}) }),
|
|
3080
|
+
/* @__PURE__ */ jsx("div", { className: "oui-order-1 md:oui-order-2", children: multiLevelRebateInfo?.referral_code ? /* @__PURE__ */ jsx(ReferralInfoWidget, {}) : /* @__PURE__ */ jsx(MultiLevelReferralWidget, {}) })
|
|
3081
|
+
]
|
|
3082
|
+
}
|
|
3083
|
+
),
|
|
3084
|
+
/* @__PURE__ */ jsx(CommissionChartWidget, {}),
|
|
3085
|
+
/* @__PURE__ */ jsx(ReferrerTableWidget, {})
|
|
3086
|
+
]
|
|
3087
|
+
}
|
|
3088
|
+
) })
|
|
3089
|
+
}
|
|
3090
|
+
);
|
|
3091
|
+
};
|
|
3092
|
+
var AffiliateIcon = (props) => {
|
|
3093
|
+
const { size = 16, className, ...rest } = props;
|
|
3094
|
+
return /* @__PURE__ */ jsxs(
|
|
3095
|
+
"svg",
|
|
3096
|
+
{
|
|
3097
|
+
width: size,
|
|
3098
|
+
height: size,
|
|
3099
|
+
viewBox: "0 0 16 16",
|
|
3100
|
+
fill: "#fff",
|
|
3101
|
+
fillOpacity: ".98",
|
|
3102
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3103
|
+
className: props.className,
|
|
3104
|
+
...rest,
|
|
3105
|
+
children: [
|
|
3106
|
+
/* @__PURE__ */ jsx("path", { d: "M8 1.302c-3.683 0-6.655 2.985-6.667 6.667-.013 3.676 2.987 6.68 6.666 6.687s6.674-3.037 6.667-6.687c-.007-3.682-2.985-6.667-6.667-6.667m0 1.333a5.333 5.333 0 0 1 5.333 5.334c0 1.5-.625 2.852-1.622 3.821-.49-1.062-1.545-1.821-2.753-1.821H7.04c-1.207 0-2.259.75-2.75 1.812A5.3 5.3 0 0 1 2.666 7.97a5.333 5.333 0 0 1 5.333-5.334M8 3.97a2.667 2.667 0 1 0 0 5.333A2.667 2.667 0 0 0 8 3.97" }),
|
|
3107
|
+
/* @__PURE__ */ jsx(
|
|
3108
|
+
"path",
|
|
3109
|
+
{
|
|
3110
|
+
d: "M16 12.667a3.333 3.333 0 1 1-6.667 0 3.333 3.333 0 0 1 6.667 0",
|
|
3111
|
+
fill: "#1828C3"
|
|
3112
|
+
}
|
|
3113
|
+
),
|
|
3114
|
+
/* @__PURE__ */ jsx("path", { d: "M11.917 11.433a.917.917 0 0 0-.917.917c0 .53.302 1.031.802 1.49a4.6 4.6 0 0 0 .713.53l.068.043c.05.027.117.027.167 0l.068-.042q.08-.05.177-.115c.182-.123.366-.26.536-.416.5-.459.802-.96.802-1.49a.917.917 0 0 0-.917-.917.97.97 0 0 0-.744.386.95.95 0 0 0-.756-.386" })
|
|
3115
|
+
]
|
|
3116
|
+
}
|
|
3117
|
+
);
|
|
3118
|
+
};
|
|
3119
|
+
var TraderIcon = (props) => {
|
|
3120
|
+
const { size = 16, className, ...rest } = props;
|
|
3121
|
+
return /* @__PURE__ */ jsxs(
|
|
3122
|
+
"svg",
|
|
3123
|
+
{
|
|
3124
|
+
width: size,
|
|
3125
|
+
height: size,
|
|
3126
|
+
viewBox: "0 0 16 16",
|
|
3127
|
+
fill: "white",
|
|
3128
|
+
fillOpacity: "0.36",
|
|
3129
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3130
|
+
className: props.className,
|
|
3131
|
+
...rest,
|
|
3132
|
+
children: [
|
|
3133
|
+
/* @__PURE__ */ jsx("path", { d: "M7.99929 1.30212C4.31735 1.30212 1.34509 4.28679 1.33262 7.96878C1.32015 11.6454 4.32042 14.6488 7.99929 14.6561C11.6782 14.6634 14.6726 11.6194 14.666 7.96878C14.6593 4.28679 11.6812 1.30212 7.99929 1.30212ZM7.99929 2.63546C10.9448 2.63546 13.3326 5.02345 13.3326 7.96878C13.3326 9.46878 12.7078 10.8208 11.7112 11.7901C11.2202 10.7281 10.1656 9.96878 8.95762 9.96878C8.71802 9.96878 7.28042 9.96878 7.04095 9.96878C5.83369 9.96878 4.78215 10.7188 4.29095 11.7814C3.29429 10.8121 2.66595 9.46878 2.66595 7.96878C2.66595 5.02345 5.05375 2.63546 7.99929 2.63546ZM7.99929 3.96879C6.52649 3.96879 5.33255 5.16279 5.33262 6.63545C5.33262 8.10812 6.52649 9.30212 7.99929 9.30212C9.47202 9.30212 10.666 8.10812 10.666 6.63545C10.666 5.16279 9.47202 3.96879 7.99929 3.96879Z" }),
|
|
3134
|
+
/* @__PURE__ */ jsx(
|
|
3135
|
+
"path",
|
|
3136
|
+
{
|
|
3137
|
+
d: "M16 12.6667C16 14.5076 14.5076 16 12.6666 16C10.8257 16 9.33331 14.5076 9.33331 12.6667C9.33331 10.8257 10.8257 9.33333 12.6666 9.33333C14.5076 9.33333 16 10.8257 16 12.6667Z",
|
|
3138
|
+
fill: "#005A4F"
|
|
3139
|
+
}
|
|
3140
|
+
),
|
|
3141
|
+
/* @__PURE__ */ jsx(
|
|
3142
|
+
"path",
|
|
3143
|
+
{
|
|
3144
|
+
d: "M14.3325 13.3345C14.3325 13.2918 14.3182 13.2473 14.2857 13.2147L13.6658 12.6002L13.4315 12.8345L13.7595 13.1678H11.3325C11.2405 13.1678 11.1658 13.2425 11.1658 13.3345C11.1658 13.4265 11.2405 13.5012 11.3325 13.5012H13.7595L13.4315 13.8345L13.6658 14.0688L14.2857 13.4543C14.3182 13.4217 14.3325 13.3772 14.3325 13.3345ZM14.1658 12.0012C14.1658 11.9092 14.0912 11.8345 13.9992 11.8345H11.572L11.9002 11.5012L11.6658 11.2668L11.046 11.8813C10.981 11.9465 10.981 12.0558 11.046 12.121L11.6658 12.7355L11.9002 12.5012L11.572 12.1678H13.9992C14.0912 12.1678 14.1658 12.0932 14.1658 12.0012Z",
|
|
3145
|
+
fill: "white",
|
|
3146
|
+
fillOpacity: "0.98"
|
|
3147
|
+
}
|
|
3148
|
+
)
|
|
3149
|
+
]
|
|
3150
|
+
}
|
|
3151
|
+
);
|
|
266
3152
|
};
|
|
267
3153
|
var USDCIcon = (props) => {
|
|
268
3154
|
return /* @__PURE__ */ jsxs(
|
|
@@ -305,7 +3191,7 @@ var USDCIcon = (props) => {
|
|
|
305
3191
|
}
|
|
306
3192
|
);
|
|
307
3193
|
};
|
|
308
|
-
var
|
|
3194
|
+
var Summary2 = (props) => {
|
|
309
3195
|
const { t } = useTranslation();
|
|
310
3196
|
return /* @__PURE__ */ jsxs(
|
|
311
3197
|
Flex,
|
|
@@ -415,7 +3301,7 @@ var Row = (props) => {
|
|
|
415
3301
|
/* @__PURE__ */ jsx(Text, { className: "oui-text-xs md:oui-text-sm xl:oui-text-base", children: commifyOptional(props.value, { fix: props.dp, fallback: "0" }) })
|
|
416
3302
|
] });
|
|
417
3303
|
};
|
|
418
|
-
var
|
|
3304
|
+
var useSummaryScript2 = () => {
|
|
419
3305
|
const { t } = useTranslation();
|
|
420
3306
|
const [period, setPeriod] = useState("All");
|
|
421
3307
|
const periodTypes = [
|
|
@@ -498,9 +3384,9 @@ var useSummaryScript = () => {
|
|
|
498
3384
|
refereesTades
|
|
499
3385
|
};
|
|
500
3386
|
};
|
|
501
|
-
var
|
|
502
|
-
const state =
|
|
503
|
-
return /* @__PURE__ */ jsx(
|
|
3387
|
+
var SummaryWidget2 = () => {
|
|
3388
|
+
const state = useSummaryScript2();
|
|
3389
|
+
return /* @__PURE__ */ jsx(Summary2, { ...state });
|
|
504
3390
|
};
|
|
505
3391
|
var AutoHideText = (props) => {
|
|
506
3392
|
const { text, visibleCount } = props;
|
|
@@ -693,7 +3579,7 @@ var Subtitle = (props) => {
|
|
|
693
3579
|
value: props.share || "-",
|
|
694
3580
|
brokerName: props.brokerName
|
|
695
3581
|
},
|
|
696
|
-
components: [/* @__PURE__ */ jsx(Text.gradient, { color: "brand" })]
|
|
3582
|
+
components: [/* @__PURE__ */ jsx(Text.gradient, { color: "brand" }, "0")]
|
|
697
3583
|
}
|
|
698
3584
|
)
|
|
699
3585
|
)
|
|
@@ -770,42 +3656,6 @@ var Alert = (props) => {
|
|
|
770
3656
|
}
|
|
771
3657
|
) });
|
|
772
3658
|
};
|
|
773
|
-
function generateReferralLink(referralLinkUrl, code) {
|
|
774
|
-
return `${referralLinkUrl || window?.location?.origin}?ref=${code}`;
|
|
775
|
-
}
|
|
776
|
-
async function copyText(content) {
|
|
777
|
-
try {
|
|
778
|
-
await navigator.clipboard.writeText(content);
|
|
779
|
-
toast.success(i18n.t("common.copy.copied"));
|
|
780
|
-
} catch (error) {
|
|
781
|
-
toast.success(i18n.t("common.copy.failed"));
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
function formatDateTimeToUTC(input) {
|
|
785
|
-
if (input === void 0) {
|
|
786
|
-
return "";
|
|
787
|
-
}
|
|
788
|
-
const date = toDate(input);
|
|
789
|
-
const utcDate = toUTCDate(date);
|
|
790
|
-
return format(utcDate, "yyyy-MM-dd HH:mm:ss 'UTC'");
|
|
791
|
-
}
|
|
792
|
-
function formatYMDTime(time) {
|
|
793
|
-
if (time === void 0) {
|
|
794
|
-
return void 0;
|
|
795
|
-
}
|
|
796
|
-
const date = toDate(time);
|
|
797
|
-
const utcDate = toUTCDate(date);
|
|
798
|
-
return format(utcDate, "yyyy-MM-dd");
|
|
799
|
-
}
|
|
800
|
-
function compareDate(d1, d2) {
|
|
801
|
-
const isEqual = d1 && d2 && d1.toISOString().substring(0, 10) === d2.toISOString().substring(0, 10);
|
|
802
|
-
return isEqual;
|
|
803
|
-
}
|
|
804
|
-
function toUTCDate(date) {
|
|
805
|
-
return new Date(date.toUTCString());
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
// src/pages/affiliate/referralLink/referralLink.script.tsx
|
|
809
3659
|
var useReferralLinkScript = () => {
|
|
810
3660
|
const { t } = useTranslation();
|
|
811
3661
|
const onCopy = (value) => {
|
|
@@ -920,31 +3770,6 @@ var Title3 = (props) => {
|
|
|
920
3770
|
] })
|
|
921
3771
|
] });
|
|
922
3772
|
};
|
|
923
|
-
function fillData(days, origin) {
|
|
924
|
-
const now = Date();
|
|
925
|
-
const result = new Array(days).fill(0).map((_, index) => {
|
|
926
|
-
return {
|
|
927
|
-
date: format(subDays(now, index + 1), "yyyy-MM-dd"),
|
|
928
|
-
volume: 0,
|
|
929
|
-
opacity: 0
|
|
930
|
-
};
|
|
931
|
-
}).reverse();
|
|
932
|
-
const dataObject = origin?.reduce(
|
|
933
|
-
(acc, curr) => {
|
|
934
|
-
acc[curr.date] = curr;
|
|
935
|
-
return acc;
|
|
936
|
-
},
|
|
937
|
-
{}
|
|
938
|
-
);
|
|
939
|
-
for (let index = 0; index < result.length; index++) {
|
|
940
|
-
const element = result[index];
|
|
941
|
-
const originData = dataObject?.[element.date];
|
|
942
|
-
if (originData) {
|
|
943
|
-
result[index] = { ...originData, opacity: originData.volume > 0 ? 1 : 0 };
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
return result;
|
|
947
|
-
}
|
|
948
3773
|
var useTitleStatisticScript = () => {
|
|
949
3774
|
const { t } = useTranslation();
|
|
950
3775
|
const [period, setPeriod] = useState("7");
|
|
@@ -1136,7 +3961,7 @@ var MobileLayout = (props) => {
|
|
|
1136
3961
|
renderItem: (e, index) => {
|
|
1137
3962
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
|
|
1138
3963
|
/* @__PURE__ */ jsx(
|
|
1139
|
-
|
|
3964
|
+
MobileCell2,
|
|
1140
3965
|
{
|
|
1141
3966
|
data: e,
|
|
1142
3967
|
editRate: props.editRate,
|
|
@@ -1187,7 +4012,7 @@ var MobileCellItem = (props) => {
|
|
|
1187
4012
|
}
|
|
1188
4013
|
);
|
|
1189
4014
|
};
|
|
1190
|
-
var
|
|
4015
|
+
var MobileCell2 = (props) => {
|
|
1191
4016
|
const { data, setPinCode, copyLink, editRate, editCode } = props;
|
|
1192
4017
|
const { t } = useTranslation();
|
|
1193
4018
|
return /* @__PURE__ */ jsxs(Flex, { gap: 3, direction: "column", className: "oui-w-full", children: [
|
|
@@ -1758,25 +4583,33 @@ var useReferralCodesScript = () => {
|
|
|
1758
4583
|
setPinCodes([...pinCodes]);
|
|
1759
4584
|
};
|
|
1760
4585
|
const codes = useMemo(() => {
|
|
1761
|
-
if (
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
item.
|
|
4586
|
+
if (referralInfo?.referrer_info?.referral_codes) {
|
|
4587
|
+
const referralCodes = referralInfo.referrer_info.referral_codes.map((item) => {
|
|
4588
|
+
const code = {
|
|
4589
|
+
...item
|
|
4590
|
+
};
|
|
4591
|
+
if (generateCode && generateCode.code === item.code) {
|
|
4592
|
+
code.isAutoGenerated = true;
|
|
4593
|
+
}
|
|
4594
|
+
return code;
|
|
4595
|
+
});
|
|
4596
|
+
const pinedItems = [];
|
|
4597
|
+
const unpinedItems = [...referralCodes];
|
|
4598
|
+
for (let i = 0; i < pinCodes.length; i++) {
|
|
4599
|
+
const code = pinCodes[i];
|
|
4600
|
+
const index = unpinedItems.findIndex((item) => item.code === code);
|
|
4601
|
+
if (index !== -1) {
|
|
4602
|
+
pinedItems.push({ ...unpinedItems[index], isPined: true });
|
|
4603
|
+
unpinedItems.splice(index, 1);
|
|
4604
|
+
}
|
|
1767
4605
|
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
for (let i = 0; i < pinCodes.length; i++) {
|
|
1772
|
-
const code = pinCodes[i];
|
|
1773
|
-
const index = referralCodes.findIndex((item) => item.code === code);
|
|
1774
|
-
if (index !== -1) {
|
|
1775
|
-
pinedItems.push({ ...referralCodes[index], isPined: true });
|
|
1776
|
-
referralCodes.splice(index, 1);
|
|
4606
|
+
const allCodes = [...pinedItems, ...unpinedItems];
|
|
4607
|
+
if (allCodes.length === 0) {
|
|
4608
|
+
return void 0;
|
|
1777
4609
|
}
|
|
4610
|
+
return allCodes;
|
|
1778
4611
|
}
|
|
1779
|
-
return
|
|
4612
|
+
return void 0;
|
|
1780
4613
|
}, [referralInfo?.referrer_info?.referral_codes, pinCodes, generateCode]);
|
|
1781
4614
|
return {
|
|
1782
4615
|
copyCode,
|
|
@@ -2250,7 +5083,7 @@ var Layout = () => {
|
|
|
2250
5083
|
var Layout1024 = () => {
|
|
2251
5084
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2252
5085
|
/* @__PURE__ */ jsxs("div", { className: "oui-flex oui-flex-col xl:oui-flex-row oui-gap-4 oui-w-full", children: [
|
|
2253
|
-
/* @__PURE__ */ jsx(
|
|
5086
|
+
/* @__PURE__ */ jsx(SummaryWidget2, {}),
|
|
2254
5087
|
/* @__PURE__ */ jsx(ReferralLinkWidget, {})
|
|
2255
5088
|
] }),
|
|
2256
5089
|
/* @__PURE__ */ jsx(TitleStatisticWidget, {}),
|
|
@@ -2260,7 +5093,7 @@ var Layout1024 = () => {
|
|
|
2260
5093
|
var Layout1280 = () => {
|
|
2261
5094
|
return /* @__PURE__ */ jsxs(Flex, { direction: "row", itemAlign: "stretch", gap: 4, children: [
|
|
2262
5095
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, className: "oui-flex-1 oui-w-1/2", children: [
|
|
2263
|
-
/* @__PURE__ */ jsx("div", { className: "oui-flex-1 oui-h-full oui-w-full", children: /* @__PURE__ */ jsx(
|
|
5096
|
+
/* @__PURE__ */ jsx("div", { className: "oui-flex-1 oui-h-full oui-w-full", children: /* @__PURE__ */ jsx(SummaryWidget2, {}) }),
|
|
2264
5097
|
/* @__PURE__ */ jsx(TitleStatisticWidget, {})
|
|
2265
5098
|
] }),
|
|
2266
5099
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, className: "oui-w-1/2", children: [
|
|
@@ -2946,7 +5779,7 @@ var useAsTraderScript = () => {
|
|
|
2946
5779
|
[AuthStatusEnum.WrongNetwork]: t("connector.wrongNetwork.tooltip")
|
|
2947
5780
|
};
|
|
2948
5781
|
return message[authStatus];
|
|
2949
|
-
}, [authStatus]);
|
|
5782
|
+
}, [t, authStatus]);
|
|
2950
5783
|
return {
|
|
2951
5784
|
isTrader,
|
|
2952
5785
|
isLoading,
|
|
@@ -3215,7 +6048,7 @@ var HomePage = () => {
|
|
|
3215
6048
|
}
|
|
3216
6049
|
);
|
|
3217
6050
|
};
|
|
3218
|
-
var
|
|
6051
|
+
var Summary3 = (props) => {
|
|
3219
6052
|
const { t } = useTranslation();
|
|
3220
6053
|
return /* @__PURE__ */ jsxs(
|
|
3221
6054
|
Flex,
|
|
@@ -3344,7 +6177,7 @@ var Row2 = (props) => {
|
|
|
3344
6177
|
/* @__PURE__ */ jsx(Text, { className: "oui-text-xs md:oui-text-sm xl:oui-text-base", children: commifyOptional(props.vol, { fix: 2, fallback: "0" }) })
|
|
3345
6178
|
] });
|
|
3346
6179
|
};
|
|
3347
|
-
var
|
|
6180
|
+
var useSummaryScript3 = () => {
|
|
3348
6181
|
const { t } = useTranslation();
|
|
3349
6182
|
const [period, setPeriod] = useState("All");
|
|
3350
6183
|
const periodTypes = [
|
|
@@ -3401,9 +6234,9 @@ var useSummaryScript2 = () => {
|
|
|
3401
6234
|
code
|
|
3402
6235
|
};
|
|
3403
6236
|
};
|
|
3404
|
-
var
|
|
3405
|
-
const state =
|
|
3406
|
-
return /* @__PURE__ */ jsx(
|
|
6237
|
+
var SummaryWidget3 = () => {
|
|
6238
|
+
const state = useSummaryScript3();
|
|
6239
|
+
return /* @__PURE__ */ jsx(Summary3, { ...state });
|
|
3407
6240
|
};
|
|
3408
6241
|
var TitleStatistic2 = (props) => {
|
|
3409
6242
|
return /* @__PURE__ */ jsxs(
|
|
@@ -3766,7 +6599,7 @@ var TraderPage = () => {
|
|
|
3766
6599
|
gap: 4,
|
|
3767
6600
|
className: "oui-flex oui-flex-col xl:oui-flex-row xl:oui-items-stretch",
|
|
3768
6601
|
children: [
|
|
3769
|
-
/* @__PURE__ */ jsx(
|
|
6602
|
+
/* @__PURE__ */ jsx(SummaryWidget3, {}),
|
|
3770
6603
|
/* @__PURE__ */ jsx(TitleStatisticWidget2, {})
|
|
3771
6604
|
]
|
|
3772
6605
|
}
|
|
@@ -3959,9 +6792,39 @@ var TabWidget = (props) => {
|
|
|
3959
6792
|
return /* @__PURE__ */ jsx(Tab, { classNames: props.classNames, ...state });
|
|
3960
6793
|
};
|
|
3961
6794
|
var DashboardPage = (props) => {
|
|
3962
|
-
const {
|
|
3963
|
-
const {
|
|
3964
|
-
|
|
6795
|
+
const { root, ...rest } = props.classNames || {};
|
|
6796
|
+
const { state } = useAccount();
|
|
6797
|
+
const { wrongNetwork, disabledConnect, initialized } = useAppContext();
|
|
6798
|
+
const { isMultiLevelEnabled, multiLevelRebateInfo, isAffiliate, isLoading } = useReferralContext();
|
|
6799
|
+
const loadingView = /* @__PURE__ */ jsx(Flex, { justify: "center", itemAlign: "center", height: "100vh", children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
6800
|
+
const [delay, setDelay] = useState(!initialized);
|
|
6801
|
+
useEffect(() => {
|
|
6802
|
+
const timer = setTimeout(() => setDelay(false), 500);
|
|
6803
|
+
return () => clearTimeout(timer);
|
|
6804
|
+
}, []);
|
|
6805
|
+
if (state.validating || delay) {
|
|
6806
|
+
return loadingView;
|
|
6807
|
+
}
|
|
6808
|
+
if (wrongNetwork || disabledConnect || state.status < AccountStatusEnum.EnableTrading && state.status !== AccountStatusEnum.EnableTradingWithoutConnected) {
|
|
6809
|
+
return /* @__PURE__ */ jsx(LandingPage, {});
|
|
6810
|
+
}
|
|
6811
|
+
if (isLoading) {
|
|
6812
|
+
return loadingView;
|
|
6813
|
+
}
|
|
6814
|
+
if (isMultiLevelEnabled) {
|
|
6815
|
+
if (multiLevelRebateInfo?.referral_code || isAffiliate) {
|
|
6816
|
+
return /* @__PURE__ */ jsx(MultiLevelAffiliatePage, {});
|
|
6817
|
+
}
|
|
6818
|
+
return /* @__PURE__ */ jsx(LandingPage, {});
|
|
6819
|
+
}
|
|
6820
|
+
return /* @__PURE__ */ jsx(
|
|
6821
|
+
"div",
|
|
6822
|
+
{
|
|
6823
|
+
id: "oui-affiliate-dashboard-page",
|
|
6824
|
+
className: cn("oui-w-full oui-tracking-tight", root),
|
|
6825
|
+
children: /* @__PURE__ */ jsx(TabWidget, { classNames: rest })
|
|
6826
|
+
}
|
|
6827
|
+
);
|
|
3965
6828
|
};
|
|
3966
6829
|
var AffiliateLayout = (props) => {
|
|
3967
6830
|
const { ...rest } = props;
|
|
@@ -4062,6 +6925,6 @@ var AffiliateLayoutWidget = (props) => {
|
|
|
4062
6925
|
return /* @__PURE__ */ jsx(AffiliateLayout, { ...state, children: props.children });
|
|
4063
6926
|
};
|
|
4064
6927
|
|
|
4065
|
-
export { AffiliateLayoutWidget, dashboard_exports as Dashboard, ReferralContext, ReferralProvider, TabTypes, useReferralContext };
|
|
6928
|
+
export { AffiliateLayoutWidget, dashboard_exports as Dashboard, LandingPage, MultiLevelAffiliatePage, ReferralContext, ReferralProvider, TabTypes, useReferralContext };
|
|
4066
6929
|
//# sourceMappingURL=index.mjs.map
|
|
4067
6930
|
//# sourceMappingURL=index.mjs.map
|