@orderly.network/affiliate 3.0.0-beta.1 → 3.0.0-beta.3
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +215 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +217 -35
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +11 -11
package/dist/index.d.mts
CHANGED
|
@@ -53,6 +53,7 @@ declare const useMultiLevelReferralData: () => {
|
|
|
53
53
|
isMultiLevelEnabled: boolean;
|
|
54
54
|
isMultiLevelReferralUnlocked: boolean | undefined;
|
|
55
55
|
multiLevelRebateInfoMutate: _orderly_network_hooks.KeyedMutator<_orderly_network_types.API.Referral.MultiLevelRebateInfo>;
|
|
56
|
+
maxRebateRateMutate: _orderly_network_hooks.KeyedMutator<_orderly_network_types.API.Referral.MaxRebateRate>;
|
|
56
57
|
isLoading: boolean;
|
|
57
58
|
};
|
|
58
59
|
type MultiLevelReferralData = ReturnType<typeof useMultiLevelReferralData>;
|
package/dist/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ declare const useMultiLevelReferralData: () => {
|
|
|
53
53
|
isMultiLevelEnabled: boolean;
|
|
54
54
|
isMultiLevelReferralUnlocked: boolean | undefined;
|
|
55
55
|
multiLevelRebateInfoMutate: _orderly_network_hooks.KeyedMutator<_orderly_network_types.API.Referral.MultiLevelRebateInfo>;
|
|
56
|
+
maxRebateRateMutate: _orderly_network_hooks.KeyedMutator<_orderly_network_types.API.Referral.MaxRebateRate>;
|
|
56
57
|
isLoading: boolean;
|
|
57
58
|
};
|
|
58
59
|
type MultiLevelReferralData = ReturnType<typeof useMultiLevelReferralData>;
|
package/dist/index.js
CHANGED
|
@@ -78,7 +78,11 @@ var useMultiLevelStatistics = (time_range) => {
|
|
|
78
78
|
// src/hooks/useMultiLevelReferralData.ts
|
|
79
79
|
var useMultiLevelReferralData = () => {
|
|
80
80
|
const { data: volumePrerequisite, isLoading: volumePrerequisiteLoading } = useVolumePrerequisite();
|
|
81
|
-
const {
|
|
81
|
+
const {
|
|
82
|
+
data: maxRebateRateRes,
|
|
83
|
+
mutate: maxRebateRateMutate,
|
|
84
|
+
isLoading: maxRebateRateLoading
|
|
85
|
+
} = useMaxRebateRate();
|
|
82
86
|
const {
|
|
83
87
|
data: multiLevelRebateInfoRes,
|
|
84
88
|
mutate: multiLevelRebateInfoMutate,
|
|
@@ -108,6 +112,7 @@ var useMultiLevelReferralData = () => {
|
|
|
108
112
|
isMultiLevelEnabled,
|
|
109
113
|
isMultiLevelReferralUnlocked,
|
|
110
114
|
multiLevelRebateInfoMutate,
|
|
115
|
+
maxRebateRateMutate,
|
|
111
116
|
isLoading
|
|
112
117
|
};
|
|
113
118
|
};
|
|
@@ -156,6 +161,7 @@ var ReferralProvider = (props) => {
|
|
|
156
161
|
isMultiLevelReferralUnlocked,
|
|
157
162
|
multiLevelRebateInfoMutate,
|
|
158
163
|
maxRebateRate,
|
|
164
|
+
maxRebateRateMutate,
|
|
159
165
|
isLoading: isMultiLevelLoading
|
|
160
166
|
} = useMultiLevelReferralData();
|
|
161
167
|
const [showHome, setShowHome] = react.useState(isLoading);
|
|
@@ -199,10 +205,12 @@ var ReferralProvider = (props) => {
|
|
|
199
205
|
}
|
|
200
206
|
}, [isAffiliate, isTrader]);
|
|
201
207
|
const memoMutate = hooks.useMemoizedFn(() => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
208
|
+
return Promise.allSettled([
|
|
209
|
+
volumeStatisticsMutate(),
|
|
210
|
+
dailyVolumeMutate(),
|
|
211
|
+
referralInfoMutate(),
|
|
212
|
+
generateCodeMutate()
|
|
213
|
+
]);
|
|
206
214
|
});
|
|
207
215
|
react.useEffect(() => {
|
|
208
216
|
const searchParams = new URLSearchParams(window.location.search);
|
|
@@ -265,7 +273,8 @@ var ReferralProvider = (props) => {
|
|
|
265
273
|
isMultiLevelEnabled,
|
|
266
274
|
isMultiLevelReferralUnlocked,
|
|
267
275
|
multiLevelRebateInfoMutate,
|
|
268
|
-
maxRebateRate
|
|
276
|
+
maxRebateRate,
|
|
277
|
+
maxRebateRateMutate
|
|
269
278
|
};
|
|
270
279
|
}, [
|
|
271
280
|
becomeAnAffiliateUrl,
|
|
@@ -296,7 +305,8 @@ var ReferralProvider = (props) => {
|
|
|
296
305
|
isMultiLevelReferralUnlocked,
|
|
297
306
|
multiLevelRebateInfoMutate,
|
|
298
307
|
maxRebateRate,
|
|
299
|
-
isMultiLevelLoading
|
|
308
|
+
isMultiLevelLoading,
|
|
309
|
+
maxRebateRateMutate
|
|
300
310
|
]);
|
|
301
311
|
return /* @__PURE__ */ jsxRuntime.jsx(ReferralContext.Provider, { value: memoizedValue, children });
|
|
302
312
|
};
|
|
@@ -417,6 +427,7 @@ var ChevronIcon = ({ expanded }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
417
427
|
}
|
|
418
428
|
);
|
|
419
429
|
var useReferralCode = () => {
|
|
430
|
+
const [doBindReferralCode, { isMutating: isBindMutating }] = hooks.useMutation("/v1/referral/bind");
|
|
420
431
|
const [doCreateReferralCode, { isMutating: isCreateMutating }] = hooks.useMutation(
|
|
421
432
|
"/v1/referral/multi_level/claim_code"
|
|
422
433
|
);
|
|
@@ -428,6 +439,9 @@ var useReferralCode = () => {
|
|
|
428
439
|
const createReferralCode = async (params) => {
|
|
429
440
|
return doCreateReferralCode(params);
|
|
430
441
|
};
|
|
442
|
+
const bindReferralCode = async (params) => {
|
|
443
|
+
return doBindReferralCode(params);
|
|
444
|
+
};
|
|
431
445
|
const editReferralCode = async (params) => {
|
|
432
446
|
return doEditReferralCode(params);
|
|
433
447
|
};
|
|
@@ -437,8 +451,9 @@ var useReferralCode = () => {
|
|
|
437
451
|
const resetRebateRate = async (params) => {
|
|
438
452
|
return doResetRebateRate(params);
|
|
439
453
|
};
|
|
440
|
-
const isMutating = isCreateMutating || isEditMutating || isUpdateRebateRateMutating || isResetRebateRateMutating;
|
|
454
|
+
const isMutating = isBindMutating || isCreateMutating || isEditMutating || isUpdateRebateRateMutating || isResetRebateRateMutating;
|
|
441
455
|
return {
|
|
456
|
+
bindReferralCode,
|
|
442
457
|
createReferralCode,
|
|
443
458
|
editReferralCode,
|
|
444
459
|
updateRebateRate,
|
|
@@ -448,11 +463,25 @@ var useReferralCode = () => {
|
|
|
448
463
|
};
|
|
449
464
|
|
|
450
465
|
// src/pages/multiLevel/affiliate/referralCodeForm/referralCodeForm.script.ts
|
|
466
|
+
function formatReferralCodeInput(raw) {
|
|
467
|
+
return String(raw).replace(/[a-z]/g, (c) => c.toUpperCase()).replace(/[^A-Z0-9]/g, "");
|
|
468
|
+
}
|
|
451
469
|
var useReferralCodeFormScript = (options) => {
|
|
452
470
|
const { type, referralCode, maxRebateRate, referrerRebateRate, accountId } = options;
|
|
453
471
|
const { t } = i18n.useTranslation();
|
|
472
|
+
const isBind = type === "bind" /* Bind */;
|
|
454
473
|
const [newCode, setNewCode] = react.useState(referralCode || "");
|
|
474
|
+
const [bindCodeInput, setBindCodeInput] = react.useState("");
|
|
455
475
|
const [isReview, setIsReview] = react.useState(false);
|
|
476
|
+
const [skipBinding, setSkipBinding] = react.useState(false);
|
|
477
|
+
const [isAwaitingPostSuccess, setIsAwaitingPostSuccess] = react.useState(false);
|
|
478
|
+
const formattedBindCode = react.useMemo(
|
|
479
|
+
() => formatReferralCodeInput(bindCodeInput),
|
|
480
|
+
[bindCodeInput]
|
|
481
|
+
);
|
|
482
|
+
const { isExist: isBindCodeExist, isLoading: isBindCodeChecking } = hooks.useCheckReferralCode(
|
|
483
|
+
isBind && formattedBindCode.length >= 4 ? formattedBindCode : void 0
|
|
484
|
+
);
|
|
456
485
|
const maxRebatePercentage = react.useMemo(() => {
|
|
457
486
|
return new utils.Decimal(maxRebateRate).mul(100).toNumber();
|
|
458
487
|
}, [maxRebateRate]);
|
|
@@ -467,7 +496,20 @@ var useReferralCodeFormScript = (options) => {
|
|
|
467
496
|
return 0;
|
|
468
497
|
}
|
|
469
498
|
);
|
|
499
|
+
const applyCreateDefaults = () => {
|
|
500
|
+
setReferrerRebatePercentage(Math.ceil(maxRebatePercentage / 2));
|
|
501
|
+
};
|
|
502
|
+
const runBindOnSuccessThenApplyDefaults = async () => {
|
|
503
|
+
setIsAwaitingPostSuccess(true);
|
|
504
|
+
try {
|
|
505
|
+
await Promise.resolve(options.onSuccess?.());
|
|
506
|
+
} finally {
|
|
507
|
+
setIsAwaitingPostSuccess(false);
|
|
508
|
+
}
|
|
509
|
+
applyCreateDefaults();
|
|
510
|
+
};
|
|
470
511
|
const {
|
|
512
|
+
bindReferralCode,
|
|
471
513
|
createReferralCode,
|
|
472
514
|
editReferralCode,
|
|
473
515
|
updateRebateRate,
|
|
@@ -479,15 +521,22 @@ var useReferralCodeFormScript = (options) => {
|
|
|
479
521
|
0,
|
|
480
522
|
new utils.Decimal(maxRebatePercentage).sub(referrerRebatePercentage).toNumber()
|
|
481
523
|
);
|
|
482
|
-
}, [referrerRebatePercentage]);
|
|
524
|
+
}, [maxRebatePercentage, referrerRebatePercentage]);
|
|
483
525
|
const codeChanged = react.useMemo(() => {
|
|
484
526
|
return newCode !== referralCode;
|
|
485
527
|
}, [newCode, referralCode]);
|
|
486
528
|
const rateChanged = react.useMemo(() => {
|
|
487
529
|
return new utils.Decimal(referrerRebatePercentage).toNumber() !== new utils.Decimal(referrerRebateRate || 0).mul(100).toNumber();
|
|
488
530
|
}, [referrerRebatePercentage, referrerRebateRate, newCode]);
|
|
531
|
+
const getErrorMessage = (err) => {
|
|
532
|
+
if (typeof err === "object" && err !== null && "message" in err) {
|
|
533
|
+
const msg = err.message;
|
|
534
|
+
return typeof msg === "string" ? msg : void 0;
|
|
535
|
+
}
|
|
536
|
+
return void 0;
|
|
537
|
+
};
|
|
489
538
|
const handleError = (err) => {
|
|
490
|
-
ui.toast.error(err
|
|
539
|
+
ui.toast.error(getErrorMessage(err) || t("common.somethingWentWrong"));
|
|
491
540
|
};
|
|
492
541
|
const handleResult = (res) => {
|
|
493
542
|
if (res.success) {
|
|
@@ -495,7 +544,7 @@ var useReferralCodeFormScript = (options) => {
|
|
|
495
544
|
ui.toast.success(t("affiliate.confirmChanges.success"));
|
|
496
545
|
options.close?.();
|
|
497
546
|
} else {
|
|
498
|
-
ui.toast.error(res.message);
|
|
547
|
+
ui.toast.error(res.message || t("common.somethingWentWrong"));
|
|
499
548
|
}
|
|
500
549
|
};
|
|
501
550
|
const onEdit = async () => {
|
|
@@ -550,8 +599,27 @@ var useReferralCodeFormScript = (options) => {
|
|
|
550
599
|
handleError(err);
|
|
551
600
|
}
|
|
552
601
|
};
|
|
602
|
+
const onBind = async () => {
|
|
603
|
+
if (skipBinding) {
|
|
604
|
+
await runBindOnSuccessThenApplyDefaults();
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (formattedBindCode.length < 4 || formattedBindCode.length > 10 || isBindCodeChecking || !isBindCodeExist) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
try {
|
|
611
|
+
await bindReferralCode({ referral_code: formattedBindCode });
|
|
612
|
+
ui.toast.success(t("affiliate.referralCode.bound"));
|
|
613
|
+
await runBindOnSuccessThenApplyDefaults();
|
|
614
|
+
} catch (err) {
|
|
615
|
+
handleError(err);
|
|
616
|
+
}
|
|
617
|
+
};
|
|
553
618
|
const onClick = () => {
|
|
554
619
|
switch (type) {
|
|
620
|
+
case "bind" /* Bind */:
|
|
621
|
+
onBind();
|
|
622
|
+
break;
|
|
555
623
|
case "create" /* Create */:
|
|
556
624
|
onCreate();
|
|
557
625
|
break;
|
|
@@ -567,19 +635,28 @@ var useReferralCodeFormScript = (options) => {
|
|
|
567
635
|
break;
|
|
568
636
|
}
|
|
569
637
|
};
|
|
570
|
-
const buttonDisabled = type === "edit" /* Edit */ && !codeChanged && !rateChanged;
|
|
638
|
+
const buttonDisabled = type === "edit" /* Edit */ && !codeChanged && !rateChanged || isBind && !skipBinding && (formattedBindCode.length < 4 || formattedBindCode.length > 10 || isBindCodeChecking || !isBindCodeExist);
|
|
639
|
+
const confirmButtonLoading = isMutating || isAwaitingPostSuccess;
|
|
571
640
|
return {
|
|
641
|
+
type,
|
|
572
642
|
onClick,
|
|
573
643
|
maxRebatePercentage,
|
|
574
644
|
referrerRebatePercentage,
|
|
575
645
|
setReferrerRebatePercentage,
|
|
576
646
|
refereeRebatePercentage,
|
|
577
|
-
|
|
647
|
+
confirmButtonLoading,
|
|
578
648
|
newCode,
|
|
579
649
|
setNewCode,
|
|
650
|
+
bindCodeInput,
|
|
651
|
+
setBindCodeInput,
|
|
652
|
+
formattedBindCode,
|
|
580
653
|
isReview,
|
|
581
654
|
buttonDisabled,
|
|
582
|
-
onReset
|
|
655
|
+
onReset,
|
|
656
|
+
skipBinding,
|
|
657
|
+
setSkipBinding,
|
|
658
|
+
isBindCodeExist,
|
|
659
|
+
isBindCodeChecking
|
|
583
660
|
};
|
|
584
661
|
};
|
|
585
662
|
var GiftIcon = (props) => {
|
|
@@ -607,12 +684,27 @@ var GiftIcon = (props) => {
|
|
|
607
684
|
var ReferralCodeForm = (props) => {
|
|
608
685
|
const { type, isReview } = props;
|
|
609
686
|
const { t } = i18n.useTranslation();
|
|
687
|
+
const isBind = type === "bind" /* Bind */;
|
|
610
688
|
const isReset = type === "reset" /* Reset */;
|
|
611
689
|
const hasBoundReferee = !!props.directInvites && props.directInvites > 0;
|
|
612
690
|
const isEditingRefereeRebateRate = !!props.accountId;
|
|
613
691
|
const noCommissionAvailable = props.maxRebateRate === 0;
|
|
614
692
|
const { title, description, buttonText } = react.useMemo(() => {
|
|
615
693
|
switch (type) {
|
|
694
|
+
case "bind" /* Bind */:
|
|
695
|
+
return {
|
|
696
|
+
title: t("affiliate.referralCode.bind.modal.title"),
|
|
697
|
+
description: /* @__PURE__ */ jsxRuntime.jsx(
|
|
698
|
+
ui.Text,
|
|
699
|
+
{
|
|
700
|
+
size: "2xs",
|
|
701
|
+
intensity: 54,
|
|
702
|
+
className: "oui-leading-[18px] oui-text-warning-darken",
|
|
703
|
+
children: t("affiliate.referralCode.bind.modal.description")
|
|
704
|
+
}
|
|
705
|
+
),
|
|
706
|
+
buttonText: t("common.confirm")
|
|
707
|
+
};
|
|
616
708
|
case "create" /* Create */:
|
|
617
709
|
return {
|
|
618
710
|
title: t("affiliate.referralCode.create.modal.title"),
|
|
@@ -658,15 +750,53 @@ var ReferralCodeForm = (props) => {
|
|
|
658
750
|
}
|
|
659
751
|
);
|
|
660
752
|
const descriptionView = /* @__PURE__ */ jsxRuntime.jsx(WarningBox, { children: description });
|
|
753
|
+
const bindCodeInvalid = isBind && !props.skipBinding && props.formattedBindCode.length >= 4 && !props.isBindCodeChecking && props.isBindCodeExist === false;
|
|
754
|
+
const bindReferralCodeInput = /* @__PURE__ */ jsxRuntime.jsx(
|
|
755
|
+
ReferralCodeInput,
|
|
756
|
+
{
|
|
757
|
+
value: props.bindCodeInput,
|
|
758
|
+
onChange: props.setBindCodeInput,
|
|
759
|
+
autoFocus: true,
|
|
760
|
+
disabled: props.skipBinding,
|
|
761
|
+
placeholder: t("affiliate.referralCode.bind.input.placeholder"),
|
|
762
|
+
helpText: bindCodeInvalid ? t("affiliate.referralCode.notExist") : void 0,
|
|
763
|
+
color: bindCodeInvalid ? "danger" : void 0
|
|
764
|
+
}
|
|
765
|
+
);
|
|
661
766
|
const referralCodeInput = /* @__PURE__ */ jsxRuntime.jsx(
|
|
662
767
|
ReferralCodeInput,
|
|
663
768
|
{
|
|
664
769
|
value: props.newCode,
|
|
665
770
|
onChange: props.setNewCode,
|
|
666
771
|
autoFocus: props.focusField === "referralCode" /* ReferralCode */,
|
|
667
|
-
disabled: isReview || hasBoundReferee
|
|
772
|
+
disabled: isReview || hasBoundReferee,
|
|
773
|
+
label: t("affiliate.referralCode.editCodeModal.label")
|
|
668
774
|
}
|
|
669
775
|
);
|
|
776
|
+
const bindCheckbox = isBind && /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-gap-[6px]", children: [
|
|
777
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
778
|
+
ui.Checkbox,
|
|
779
|
+
{
|
|
780
|
+
color: "white",
|
|
781
|
+
id: "oui-checkbox-skipReferralBinding",
|
|
782
|
+
checked: props.skipBinding,
|
|
783
|
+
onCheckedChange: (checked) => {
|
|
784
|
+
props.setSkipBinding(checked);
|
|
785
|
+
if (checked) {
|
|
786
|
+
props.setBindCodeInput("");
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
),
|
|
791
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
792
|
+
"label",
|
|
793
|
+
{
|
|
794
|
+
htmlFor: "oui-checkbox-skipReferralBinding",
|
|
795
|
+
className: "oui-text-2xs oui-font-normal oui-text-base-contrast-54",
|
|
796
|
+
children: t("affiliate.referralCode.bind.skip")
|
|
797
|
+
}
|
|
798
|
+
)
|
|
799
|
+
] });
|
|
670
800
|
const commissionConfiguration = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
671
801
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "2xs", intensity: 54, children: t("affiliate.commissionConfiguration") }),
|
|
672
802
|
!isReview && /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "2xs", intensity: 54, children: [
|
|
@@ -719,8 +849,8 @@ var ReferralCodeForm = (props) => {
|
|
|
719
849
|
{
|
|
720
850
|
fullWidth: true,
|
|
721
851
|
onClick: props.onClick,
|
|
722
|
-
disabled: props.buttonDisabled || props.
|
|
723
|
-
loading: props.
|
|
852
|
+
disabled: props.buttonDisabled || props.confirmButtonLoading,
|
|
853
|
+
loading: props.confirmButtonLoading,
|
|
724
854
|
size: "md",
|
|
725
855
|
className: "oui-referralCodeForm-confirm-btn",
|
|
726
856
|
children: buttonText
|
|
@@ -729,6 +859,12 @@ var ReferralCodeForm = (props) => {
|
|
|
729
859
|
] });
|
|
730
860
|
const renderContent = () => {
|
|
731
861
|
switch (type) {
|
|
862
|
+
case "bind" /* Bind */:
|
|
863
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 4, children: [
|
|
864
|
+
bindReferralCodeInput,
|
|
865
|
+
bindCheckbox,
|
|
866
|
+
buttons
|
|
867
|
+
] });
|
|
732
868
|
case "create" /* Create */:
|
|
733
869
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 2, children: [
|
|
734
870
|
commissionConfiguration,
|
|
@@ -774,6 +910,9 @@ var ReferralCodeForm = (props) => {
|
|
|
774
910
|
var NoCommissionCard = (props) => {
|
|
775
911
|
const { t } = i18n.useTranslation();
|
|
776
912
|
const amount = props.directBonusRebateRate;
|
|
913
|
+
if (!amount || amount <= 0) {
|
|
914
|
+
return null;
|
|
915
|
+
}
|
|
777
916
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
778
917
|
ui.Flex,
|
|
779
918
|
{
|
|
@@ -788,7 +927,7 @@ var NoCommissionCard = (props) => {
|
|
|
788
927
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "between", width: "100%", itemAlign: "center", children: [
|
|
789
928
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
790
929
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "2xs", intensity: 54, children: t("affiliate.noCommissionCard.title") }),
|
|
791
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "lg", className: "oui-text-primary-light
|
|
930
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "lg", className: "oui-font-semibold oui-text-primary-light", children: [
|
|
792
931
|
"+ ",
|
|
793
932
|
amount,
|
|
794
933
|
"%"
|
|
@@ -850,7 +989,7 @@ var RebateRateSlider = (props) => {
|
|
|
850
989
|
GiftIcon,
|
|
851
990
|
{
|
|
852
991
|
size: 16,
|
|
853
|
-
className: "oui-text-base-contrast
|
|
992
|
+
className: "oui-mt-px oui-text-base-contrast"
|
|
854
993
|
}
|
|
855
994
|
),
|
|
856
995
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -875,14 +1014,14 @@ var RebateRateSlider = (props) => {
|
|
|
875
1014
|
] });
|
|
876
1015
|
};
|
|
877
1016
|
var ReferralCodeInput = (props) => {
|
|
878
|
-
const { t } = i18n.useTranslation();
|
|
879
1017
|
const hasSetCursorToEnd = react.useRef(false);
|
|
880
1018
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
881
1019
|
ui.TextField,
|
|
882
1020
|
{
|
|
883
1021
|
type: "text",
|
|
884
1022
|
fullWidth: true,
|
|
885
|
-
label:
|
|
1023
|
+
label: props.label ?? "",
|
|
1024
|
+
placeholder: props.placeholder,
|
|
886
1025
|
value: props.value,
|
|
887
1026
|
onChange: (e) => {
|
|
888
1027
|
props.onChange(e.target.value);
|
|
@@ -911,6 +1050,8 @@ var ReferralCodeInput = (props) => {
|
|
|
911
1050
|
label: "oui-text-base-contrast-54 oui-text-xs",
|
|
912
1051
|
input: "placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"
|
|
913
1052
|
},
|
|
1053
|
+
helpText: props.helpText,
|
|
1054
|
+
color: props.color,
|
|
914
1055
|
maxLength: 10,
|
|
915
1056
|
minLength: 4,
|
|
916
1057
|
autoComplete: "off",
|
|
@@ -1058,6 +1199,11 @@ var TradingVolumeProgress = (props) => {
|
|
|
1058
1199
|
}
|
|
1059
1200
|
);
|
|
1060
1201
|
};
|
|
1202
|
+
function parseMaxRebateRateFromSettled(result) {
|
|
1203
|
+
if (result.status !== "fulfilled") return void 0;
|
|
1204
|
+
const num = result.value?.max_rebate_rate;
|
|
1205
|
+
return typeof num === "number" ? num : void 0;
|
|
1206
|
+
}
|
|
1061
1207
|
var Hero = () => {
|
|
1062
1208
|
const { t } = i18n.useTranslation();
|
|
1063
1209
|
const { state } = hooks.useAccount();
|
|
@@ -1066,21 +1212,42 @@ var Hero = () => {
|
|
|
1066
1212
|
const {
|
|
1067
1213
|
isMultiLevelReferralUnlocked,
|
|
1068
1214
|
isMultiLevelEnabled,
|
|
1215
|
+
isTrader,
|
|
1069
1216
|
multiLevelRebateInfo,
|
|
1070
1217
|
multiLevelRebateInfoMutate,
|
|
1071
|
-
maxRebateRate
|
|
1218
|
+
maxRebateRate,
|
|
1219
|
+
maxRebateRateMutate,
|
|
1220
|
+
mutate
|
|
1072
1221
|
} = useReferralContext();
|
|
1073
|
-
const
|
|
1222
|
+
const showCreateReferralCodeModal = (maxRateOverride) => {
|
|
1074
1223
|
ui.modal.show(ReferralCodeFormDialogId, {
|
|
1075
1224
|
type: "create" /* Create */,
|
|
1076
|
-
maxRebateRate,
|
|
1077
|
-
directBonusRebateRate:
|
|
1078
|
-
// Hardcoded value before API is ready
|
|
1225
|
+
maxRebateRate: maxRateOverride ?? maxRebateRate ?? 0,
|
|
1226
|
+
directBonusRebateRate: 0,
|
|
1079
1227
|
onSuccess: () => {
|
|
1080
1228
|
multiLevelRebateInfoMutate();
|
|
1081
1229
|
}
|
|
1082
1230
|
});
|
|
1083
1231
|
};
|
|
1232
|
+
const onCreateReferralCode = () => {
|
|
1233
|
+
if (!isTrader) {
|
|
1234
|
+
ui.modal.show(ReferralCodeFormDialogId, {
|
|
1235
|
+
type: "bind" /* Bind */,
|
|
1236
|
+
maxRebateRate,
|
|
1237
|
+
onSuccess: async () => {
|
|
1238
|
+
const results = await Promise.allSettled([
|
|
1239
|
+
maxRebateRateMutate(),
|
|
1240
|
+
multiLevelRebateInfoMutate(),
|
|
1241
|
+
mutate()
|
|
1242
|
+
]);
|
|
1243
|
+
const latestMaxRebateRate = parseMaxRebateRateFromSettled(results[0]) ?? maxRebateRate;
|
|
1244
|
+
showCreateReferralCodeModal(latestMaxRebateRate);
|
|
1245
|
+
}
|
|
1246
|
+
});
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
showCreateReferralCodeModal();
|
|
1250
|
+
};
|
|
1084
1251
|
const description = react.useMemo(() => {
|
|
1085
1252
|
if (wrongNetwork) {
|
|
1086
1253
|
return t("affiliate.wrongNetwork.description");
|
|
@@ -1532,8 +1699,8 @@ var useMultiLevelReferralScript = () => {
|
|
|
1532
1699
|
ui.modal.show(ReferralCodeFormDialogId, {
|
|
1533
1700
|
type: "create" /* Create */,
|
|
1534
1701
|
maxRebateRate,
|
|
1535
|
-
|
|
1536
|
-
|
|
1702
|
+
// because there is no multi level code, the /v1/referral/multi_level/rebate_info interface will throw an error, so here set to 0, and hide the extra bonus display when creating multi level code
|
|
1703
|
+
directBonusRebateRate: 0,
|
|
1537
1704
|
onSuccess: () => {
|
|
1538
1705
|
multiLevelRebateInfoMutate();
|
|
1539
1706
|
}
|
|
@@ -2978,6 +3145,7 @@ var Summary = (props) => {
|
|
|
2978
3145
|
value: statistics.total_rebate,
|
|
2979
3146
|
direct: statistics.direct_rebate + statistics.direct_bonus_rebate,
|
|
2980
3147
|
indirect: statistics.indirect_rebate,
|
|
3148
|
+
referredByCode: props.referredByCode,
|
|
2981
3149
|
classNames: {
|
|
2982
3150
|
root: "!oui-py-12",
|
|
2983
3151
|
value: "oui-text-trade-profit",
|
|
@@ -3041,7 +3209,7 @@ var SummaryItem = (props) => {
|
|
|
3041
3209
|
ui.Text.numeral,
|
|
3042
3210
|
{
|
|
3043
3211
|
rule,
|
|
3044
|
-
dp
|
|
3212
|
+
dp,
|
|
3045
3213
|
size: "3xl",
|
|
3046
3214
|
prefix: props.prefix,
|
|
3047
3215
|
placeholder: "--",
|
|
@@ -3060,7 +3228,7 @@ var SummaryItem = (props) => {
|
|
|
3060
3228
|
ui.Text.numeral,
|
|
3061
3229
|
{
|
|
3062
3230
|
rule,
|
|
3063
|
-
dp
|
|
3231
|
+
dp,
|
|
3064
3232
|
prefix: props.prefix,
|
|
3065
3233
|
intensity: 54,
|
|
3066
3234
|
className: props.classNames?.direct,
|
|
@@ -3078,7 +3246,7 @@ var SummaryItem = (props) => {
|
|
|
3078
3246
|
ui.Text.numeral,
|
|
3079
3247
|
{
|
|
3080
3248
|
rule,
|
|
3081
|
-
dp
|
|
3249
|
+
dp,
|
|
3082
3250
|
prefix: props.prefix,
|
|
3083
3251
|
intensity: 54,
|
|
3084
3252
|
className: props.classNames?.indirect,
|
|
@@ -3086,15 +3254,28 @@ var SummaryItem = (props) => {
|
|
|
3086
3254
|
}
|
|
3087
3255
|
)
|
|
3088
3256
|
] })
|
|
3089
|
-
] })
|
|
3257
|
+
] }),
|
|
3258
|
+
props.referredByCode ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3259
|
+
ui.Text,
|
|
3260
|
+
{
|
|
3261
|
+
intensity: 54,
|
|
3262
|
+
className: "oui-affiliate-summary-referred-by oui-mt-5 oui-text-base-contrast-54",
|
|
3263
|
+
children: t("affiliate.referredBy", { name: props.referredByCode })
|
|
3264
|
+
}
|
|
3265
|
+
) : null
|
|
3090
3266
|
]
|
|
3091
3267
|
}
|
|
3092
3268
|
);
|
|
3093
3269
|
};
|
|
3094
3270
|
var useSummaryScript = () => {
|
|
3095
3271
|
const { t } = i18n.useTranslation();
|
|
3272
|
+
const { referralInfo } = useReferralContext();
|
|
3096
3273
|
const [period, setPeriod] = react.useState("all_time" /* All */);
|
|
3097
3274
|
const { data } = useMultiLevelStatistics(period);
|
|
3275
|
+
const referredByCode = react.useMemo(() => {
|
|
3276
|
+
const code = referralInfo?.referee_info?.referer_code?.trim();
|
|
3277
|
+
return code || void 0;
|
|
3278
|
+
}, [referralInfo]);
|
|
3098
3279
|
const periodTypes = [
|
|
3099
3280
|
{ label: t("common.all"), value: "all_time" /* All */ },
|
|
3100
3281
|
{ label: t("common.select.1d"), value: "1d" /* 1d */ },
|
|
@@ -3136,7 +3317,8 @@ var useSummaryScript = () => {
|
|
|
3136
3317
|
period,
|
|
3137
3318
|
periodTypes,
|
|
3138
3319
|
onPeriodChange,
|
|
3139
|
-
statistics
|
|
3320
|
+
statistics,
|
|
3321
|
+
referredByCode
|
|
3140
3322
|
};
|
|
3141
3323
|
};
|
|
3142
3324
|
var SummaryWidget = () => {
|