@orderly.network/affiliate 3.1.3 → 3.1.4
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.js +412 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +412 -74
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useState, useEffect, useRef, useMemo, useContext, useCallback, Fragment as Fragment$1 } from 'react';
|
|
2
|
-
import { useMutation, cleanStringStyle, useCheckReferralCode, useAccount, usePrivateQuery, noCacheConfig, useDaily, useMemoizedFn, useMediaQuery, useReferralRebateSummary, useLocalStorage, useRefereeRebateSummary, useRefereeInfo } from '@orderly.network/hooks';
|
|
2
|
+
import { useMutation, isReferralCodeLengthValid, REFERRAL_CODE_MIN_LENGTH, REFERRAL_CODE_MAX_LENGTH, formatReferralCodeInput, cleanStringStyle, useCheckReferralCode, useAccount, usePrivateQuery, noCacheConfig, useDaily, useMemoizedFn, useMediaQuery, useReferralRebateSummary, useLocalStorage, useRefereeRebateSummary, useRefereeInfo } from '@orderly.network/hooks';
|
|
3
3
|
import { useAppContext } from '@orderly.network/react-app';
|
|
4
4
|
import { AccountStatusEnum, EMPTY_LIST } from '@orderly.network/types';
|
|
5
5
|
import { registerSimpleDialog, registerSimpleSheet, modal, useModal, SimpleDialog, TextField, inputFormatter, Flex, Text, cn, toast, Dialog, DialogContent, DialogTitle, Divider, Input as Input$1, Button, formatAddress, Checkbox, Box, Slider, WarningIcon, Tooltip, Grid, Spinner, Collapsible, CollapsibleContent, Select, Tabs, TabPanel, useScreen, usePagination, DatePicker, TabsBase, TabsList, TabsTrigger, TabsContent, parseNumber, ListView, CopyIcon, DataTable, Statistic, DialogTrigger, DialogHeader, DialogBody } from '@orderly.network/ui';
|
|
@@ -485,6 +485,10 @@ var useReferralCodeFormScript = (options) => {
|
|
|
485
485
|
const { t } = useTranslation();
|
|
486
486
|
const [newCode, setNewCode] = useState(referralCode || "");
|
|
487
487
|
const [isReview, setIsReview] = useState(false);
|
|
488
|
+
const formattedNewCode = useMemo(
|
|
489
|
+
() => formatReferralCodeInput(newCode),
|
|
490
|
+
[newCode]
|
|
491
|
+
);
|
|
488
492
|
const bonusMaxRebatePercentage = useMemo(() => {
|
|
489
493
|
return new Decimal(options.bonusMaxRebateRate ?? options.maxRebateRate ?? 0).mul(100).toNumber();
|
|
490
494
|
}, [options.bonusMaxRebateRate, options.maxRebateRate]);
|
|
@@ -549,9 +553,13 @@ var useReferralCodeFormScript = (options) => {
|
|
|
549
553
|
}
|
|
550
554
|
};
|
|
551
555
|
const onEdit = async () => {
|
|
556
|
+
if (codeChanged && !isReferralCodeLengthValid(formattedNewCode)) {
|
|
557
|
+
toast.error(t("affiliate.referralCode.editCodeModal.helpText.length"));
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
552
560
|
const editReferralCodeParams = {
|
|
553
561
|
current_referral_code: referralCode,
|
|
554
|
-
new_referral_code:
|
|
562
|
+
new_referral_code: formattedNewCode
|
|
555
563
|
};
|
|
556
564
|
const updateRebateRateParams = {
|
|
557
565
|
referee_rebate_rate: new Decimal(refereeBonusRebatePercentage).div(100).toNumber(),
|
|
@@ -626,8 +634,11 @@ var useReferralCodeFormScript = (options) => {
|
|
|
626
634
|
if (type !== "edit" /* Edit */) {
|
|
627
635
|
return false;
|
|
628
636
|
}
|
|
637
|
+
if (codeChanged && !isReferralCodeLengthValid(formattedNewCode)) {
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
629
640
|
return !codeChanged && !rateChanged;
|
|
630
|
-
}, [codeChanged, rateChanged, type]);
|
|
641
|
+
}, [codeChanged, rateChanged, formattedNewCode, type]);
|
|
631
642
|
const confirmButtonLoading = isMutating;
|
|
632
643
|
return {
|
|
633
644
|
type,
|
|
@@ -688,8 +699,8 @@ var ReferralCodeInput = (props) => {
|
|
|
688
699
|
},
|
|
689
700
|
helpText: props.helpText,
|
|
690
701
|
color: props.color,
|
|
691
|
-
maxLength:
|
|
692
|
-
minLength:
|
|
702
|
+
maxLength: REFERRAL_CODE_MAX_LENGTH,
|
|
703
|
+
minLength: REFERRAL_CODE_MIN_LENGTH,
|
|
693
704
|
autoComplete: "off",
|
|
694
705
|
disabled: props.disabled,
|
|
695
706
|
autoFocus: props.autoFocus
|
|
@@ -1048,9 +1059,6 @@ registerSimpleDialog(ReferralCodeFormDialogId, ReferralCodeFormWidget, {
|
|
|
1048
1059
|
}
|
|
1049
1060
|
});
|
|
1050
1061
|
registerSimpleSheet(ReferralCodeFormSheetId, ReferralCodeFormWidget);
|
|
1051
|
-
function formatReferralCodeInput(raw) {
|
|
1052
|
-
return String(raw).replace(/[a-z]/g, (c) => c.toUpperCase()).replace(/[^A-Z0-9]/g, "");
|
|
1053
|
-
}
|
|
1054
1062
|
var useBindReferralCodeScript = (options) => {
|
|
1055
1063
|
const { t } = useTranslation();
|
|
1056
1064
|
const [bindCodeInput, setBindCodeInput] = useState("");
|
|
@@ -1061,7 +1069,7 @@ var useBindReferralCodeScript = (options) => {
|
|
|
1061
1069
|
[bindCodeInput]
|
|
1062
1070
|
);
|
|
1063
1071
|
const { isExist: isBindCodeExist, isLoading: isBindCodeChecking } = useCheckReferralCode(
|
|
1064
|
-
formattedBindCode.length >=
|
|
1072
|
+
formattedBindCode.length >= REFERRAL_CODE_MIN_LENGTH ? formattedBindCode : void 0
|
|
1065
1073
|
);
|
|
1066
1074
|
const { bindReferralCode, isMutating } = useReferralCode();
|
|
1067
1075
|
const getErrorMessage = (err) => {
|
|
@@ -1088,7 +1096,7 @@ var useBindReferralCodeScript = (options) => {
|
|
|
1088
1096
|
await runAfterSuccess({ skipped: true });
|
|
1089
1097
|
return;
|
|
1090
1098
|
}
|
|
1091
|
-
if (formattedBindCode
|
|
1099
|
+
if (!isReferralCodeLengthValid(formattedBindCode) || isBindCodeChecking || !isBindCodeExist) {
|
|
1092
1100
|
return;
|
|
1093
1101
|
}
|
|
1094
1102
|
try {
|
|
@@ -1099,7 +1107,7 @@ var useBindReferralCodeScript = (options) => {
|
|
|
1099
1107
|
handleError(err);
|
|
1100
1108
|
}
|
|
1101
1109
|
};
|
|
1102
|
-
const buttonDisabled = !skipBinding && (formattedBindCode
|
|
1110
|
+
const buttonDisabled = !skipBinding && (!isReferralCodeLengthValid(formattedBindCode) || isBindCodeChecking || !isBindCodeExist);
|
|
1103
1111
|
const confirmButtonLoading = isMutating || isAwaitingPostSuccess;
|
|
1104
1112
|
return {
|
|
1105
1113
|
bindCodeInput,
|
|
@@ -1131,7 +1139,7 @@ var WarningBox = (props) => /* @__PURE__ */ jsxs(
|
|
|
1131
1139
|
);
|
|
1132
1140
|
var BindReferralCode = (props) => {
|
|
1133
1141
|
const { t } = useTranslation();
|
|
1134
|
-
const bindCodeInvalid = !props.skipBinding && props.formattedBindCode.length >=
|
|
1142
|
+
const bindCodeInvalid = !props.skipBinding && props.formattedBindCode.length >= REFERRAL_CODE_MIN_LENGTH && !props.isBindCodeChecking && props.isBindCodeExist === false;
|
|
1135
1143
|
const titleView = /* @__PURE__ */ jsxs(
|
|
1136
1144
|
Flex,
|
|
1137
1145
|
{
|
|
@@ -2601,6 +2609,232 @@ var useMultiLevelReferees = (params = {}) => {
|
|
|
2601
2609
|
meta: response.data?.meta
|
|
2602
2610
|
};
|
|
2603
2611
|
};
|
|
2612
|
+
var useEditRefereeDescription = () => {
|
|
2613
|
+
const [doEditRefereeDescription, { isMutating }] = useMutation("/v1/referral/edit_referee_description");
|
|
2614
|
+
const editRefereeDescription = async (params) => {
|
|
2615
|
+
return doEditRefereeDescription(params);
|
|
2616
|
+
};
|
|
2617
|
+
return {
|
|
2618
|
+
editRefereeDescription,
|
|
2619
|
+
isMutating
|
|
2620
|
+
};
|
|
2621
|
+
};
|
|
2622
|
+
|
|
2623
|
+
// src/pages/multiLevel/affiliate/referrerTable/refereeDescriptionForm/refereeDescriptionForm.script.ts
|
|
2624
|
+
var DESCRIPTION_PATTERN = /^[a-zA-Z0-9@, _-]{0,50}$/;
|
|
2625
|
+
var useRefereeDescriptionFormScript = (options) => {
|
|
2626
|
+
const { t } = useTranslation();
|
|
2627
|
+
const [description, setDescription] = useState(options.description ?? "");
|
|
2628
|
+
const [isAwaitingPostSuccess, setIsAwaitingPostSuccess] = useState(false);
|
|
2629
|
+
const { editRefereeDescription, isMutating } = useEditRefereeDescription();
|
|
2630
|
+
const isValid = useMemo(() => {
|
|
2631
|
+
return DESCRIPTION_PATTERN.test(description);
|
|
2632
|
+
}, [description]);
|
|
2633
|
+
const buttonDisabled = !isValid;
|
|
2634
|
+
const getErrorMessage = (err) => {
|
|
2635
|
+
if (typeof err === "object" && err !== null && "message" in err) {
|
|
2636
|
+
const msg = err.message;
|
|
2637
|
+
return typeof msg === "string" ? msg : void 0;
|
|
2638
|
+
}
|
|
2639
|
+
return void 0;
|
|
2640
|
+
};
|
|
2641
|
+
const onConfirm = async () => {
|
|
2642
|
+
if (!isValid) return;
|
|
2643
|
+
const nextDescription = description.length === 0 ? null : description;
|
|
2644
|
+
try {
|
|
2645
|
+
const res = await editRefereeDescription({
|
|
2646
|
+
user_address: options.address,
|
|
2647
|
+
description: nextDescription
|
|
2648
|
+
});
|
|
2649
|
+
if (res.success) {
|
|
2650
|
+
setIsAwaitingPostSuccess(true);
|
|
2651
|
+
try {
|
|
2652
|
+
await Promise.resolve(options.onSuccess?.());
|
|
2653
|
+
} finally {
|
|
2654
|
+
setIsAwaitingPostSuccess(false);
|
|
2655
|
+
}
|
|
2656
|
+
toast.success(t("affiliate.refereeNote.save.success"));
|
|
2657
|
+
options.close?.();
|
|
2658
|
+
} else {
|
|
2659
|
+
toast.error(res.message || t("common.somethingWentWrong"));
|
|
2660
|
+
}
|
|
2661
|
+
} catch (err) {
|
|
2662
|
+
toast.error(getErrorMessage(err) || t("common.somethingWentWrong"));
|
|
2663
|
+
}
|
|
2664
|
+
};
|
|
2665
|
+
return {
|
|
2666
|
+
description,
|
|
2667
|
+
setDescription,
|
|
2668
|
+
isValid,
|
|
2669
|
+
buttonDisabled,
|
|
2670
|
+
confirmButtonLoading: isMutating || isAwaitingPostSuccess,
|
|
2671
|
+
onConfirm
|
|
2672
|
+
};
|
|
2673
|
+
};
|
|
2674
|
+
var RefereeDescriptionForm = (props) => {
|
|
2675
|
+
const { t } = useTranslation();
|
|
2676
|
+
const showError = !props.isValid;
|
|
2677
|
+
const titleView = /* @__PURE__ */ jsxs(
|
|
2678
|
+
Flex,
|
|
2679
|
+
{
|
|
2680
|
+
width: "100%",
|
|
2681
|
+
direction: "column",
|
|
2682
|
+
itemAlign: "start",
|
|
2683
|
+
className: "oui-refereeDescriptionForm-header",
|
|
2684
|
+
children: [
|
|
2685
|
+
/* @__PURE__ */ jsx(
|
|
2686
|
+
Flex,
|
|
2687
|
+
{
|
|
2688
|
+
width: "100%",
|
|
2689
|
+
height: 53,
|
|
2690
|
+
itemAlign: "center",
|
|
2691
|
+
className: "oui-px-5 oui-pt-3",
|
|
2692
|
+
children: /* @__PURE__ */ jsx(Text, { size: "base", intensity: 98, className: "oui-leading-6", children: t("affiliate.editNote") })
|
|
2693
|
+
}
|
|
2694
|
+
),
|
|
2695
|
+
/* @__PURE__ */ jsx(Divider, { intensity: 8, className: "oui-w-full" })
|
|
2696
|
+
]
|
|
2697
|
+
}
|
|
2698
|
+
);
|
|
2699
|
+
return /* @__PURE__ */ jsxs(
|
|
2700
|
+
Flex,
|
|
2701
|
+
{
|
|
2702
|
+
direction: "column",
|
|
2703
|
+
itemAlign: "start",
|
|
2704
|
+
className: "oui-affiliate-refereeDescriptionForm oui-font-semibold",
|
|
2705
|
+
children: [
|
|
2706
|
+
titleView,
|
|
2707
|
+
/* @__PURE__ */ jsxs(
|
|
2708
|
+
Flex,
|
|
2709
|
+
{
|
|
2710
|
+
width: "100%",
|
|
2711
|
+
direction: "column",
|
|
2712
|
+
itemAlign: "start",
|
|
2713
|
+
gap: 6,
|
|
2714
|
+
className: "oui-p-5",
|
|
2715
|
+
children: [
|
|
2716
|
+
/* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 1, children: [
|
|
2717
|
+
/* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, className: "oui-leading-[18px]", children: t("affiliate.remark") }),
|
|
2718
|
+
/* @__PURE__ */ jsx(
|
|
2719
|
+
"input",
|
|
2720
|
+
{
|
|
2721
|
+
autoFocus: true,
|
|
2722
|
+
value: props.description,
|
|
2723
|
+
onChange: (event) => props.setDescription(event.target.value),
|
|
2724
|
+
placeholder: t("affiliate.refereeNote.placeholder"),
|
|
2725
|
+
className: [
|
|
2726
|
+
"oui-h-10 oui-w-full oui-rounded-md oui-border oui-bg-base-6 oui-px-3 oui-py-2.5",
|
|
2727
|
+
"oui-text-sm oui-font-semibold oui-leading-5 oui-tracking-[0.03em] oui-text-base-contrast-98 oui-outline-none",
|
|
2728
|
+
"placeholder:oui-text-base-contrast-20",
|
|
2729
|
+
showError ? "oui-border-danger" : "oui-border-line-12 focus:oui-border-line-12"
|
|
2730
|
+
].join(" ")
|
|
2731
|
+
}
|
|
2732
|
+
),
|
|
2733
|
+
/* @__PURE__ */ jsxs(Flex, { width: "100%", gap: 1, itemAlign: "start", className: "oui-pl-1", children: [
|
|
2734
|
+
/* @__PURE__ */ jsx(
|
|
2735
|
+
"span",
|
|
2736
|
+
{
|
|
2737
|
+
className: [
|
|
2738
|
+
"oui-mt-[7px] oui-size-1 oui-shrink-0 oui-rounded-full",
|
|
2739
|
+
showError ? "oui-bg-danger" : "oui-bg-base-contrast-54"
|
|
2740
|
+
].join(" ")
|
|
2741
|
+
}
|
|
2742
|
+
),
|
|
2743
|
+
/* @__PURE__ */ jsx(
|
|
2744
|
+
Text,
|
|
2745
|
+
{
|
|
2746
|
+
size: "2xs",
|
|
2747
|
+
intensity: showError ? 98 : 54,
|
|
2748
|
+
className: [
|
|
2749
|
+
"oui-leading-[18px]",
|
|
2750
|
+
showError ? "oui-text-danger" : void 0
|
|
2751
|
+
].join(" "),
|
|
2752
|
+
children: showError ? t("affiliate.refereeNote.helpText") : t("affiliate.refereeNote.helpText.short")
|
|
2753
|
+
}
|
|
2754
|
+
)
|
|
2755
|
+
] })
|
|
2756
|
+
] }),
|
|
2757
|
+
/* @__PURE__ */ jsxs(
|
|
2758
|
+
Flex,
|
|
2759
|
+
{
|
|
2760
|
+
width: "100%",
|
|
2761
|
+
justify: "between",
|
|
2762
|
+
itemAlign: "center",
|
|
2763
|
+
gap: 2,
|
|
2764
|
+
className: "oui-text-2xs oui-font-semibold oui-leading-[18px]",
|
|
2765
|
+
children: [
|
|
2766
|
+
/* @__PURE__ */ jsx(Text, { intensity: 54, children: t("affiliate.userAddress") }),
|
|
2767
|
+
/* @__PURE__ */ jsx(Text, { intensity: 98, className: "oui-min-w-0 oui-flex-1 oui-text-end", children: formatAddress(props.address) })
|
|
2768
|
+
]
|
|
2769
|
+
}
|
|
2770
|
+
)
|
|
2771
|
+
]
|
|
2772
|
+
}
|
|
2773
|
+
),
|
|
2774
|
+
/* @__PURE__ */ jsxs(
|
|
2775
|
+
Flex,
|
|
2776
|
+
{
|
|
2777
|
+
direction: "row",
|
|
2778
|
+
gap: 3,
|
|
2779
|
+
width: "100%",
|
|
2780
|
+
className: "oui-px-5 oui-pb-5 oui-pt-3",
|
|
2781
|
+
children: [
|
|
2782
|
+
/* @__PURE__ */ jsx(
|
|
2783
|
+
Button,
|
|
2784
|
+
{
|
|
2785
|
+
variant: "contained",
|
|
2786
|
+
color: "gray",
|
|
2787
|
+
fullWidth: true,
|
|
2788
|
+
onClick: props.close,
|
|
2789
|
+
size: "md",
|
|
2790
|
+
className: "oui-refereeDescriptionForm-cancel-btn oui-rounded-md",
|
|
2791
|
+
children: t("common.cancel")
|
|
2792
|
+
}
|
|
2793
|
+
),
|
|
2794
|
+
/* @__PURE__ */ jsx(
|
|
2795
|
+
Button,
|
|
2796
|
+
{
|
|
2797
|
+
fullWidth: true,
|
|
2798
|
+
onClick: props.onConfirm,
|
|
2799
|
+
disabled: props.buttonDisabled || props.confirmButtonLoading,
|
|
2800
|
+
loading: props.confirmButtonLoading,
|
|
2801
|
+
size: "md",
|
|
2802
|
+
className: "oui-refereeDescriptionForm-confirm-btn oui-rounded-md",
|
|
2803
|
+
children: t("common.save")
|
|
2804
|
+
}
|
|
2805
|
+
)
|
|
2806
|
+
]
|
|
2807
|
+
}
|
|
2808
|
+
)
|
|
2809
|
+
]
|
|
2810
|
+
}
|
|
2811
|
+
);
|
|
2812
|
+
};
|
|
2813
|
+
var RefereeDescriptionFormWidget = (props) => {
|
|
2814
|
+
const state = useRefereeDescriptionFormScript(props);
|
|
2815
|
+
return /* @__PURE__ */ jsx(
|
|
2816
|
+
RefereeDescriptionForm,
|
|
2817
|
+
{
|
|
2818
|
+
...props,
|
|
2819
|
+
...state,
|
|
2820
|
+
initialDescription: props.description
|
|
2821
|
+
}
|
|
2822
|
+
);
|
|
2823
|
+
};
|
|
2824
|
+
|
|
2825
|
+
// src/pages/multiLevel/affiliate/referrerTable/refereeDescriptionForm/modal.ts
|
|
2826
|
+
var RefereeDescriptionFormDialogId = "RefereeDescriptionFormDialogId";
|
|
2827
|
+
registerSimpleDialog(
|
|
2828
|
+
RefereeDescriptionFormDialogId,
|
|
2829
|
+
RefereeDescriptionFormWidget,
|
|
2830
|
+
{
|
|
2831
|
+
size: "sm",
|
|
2832
|
+
classNames: {
|
|
2833
|
+
content: "oui-border oui-border-line-6 !oui-max-w-[360px] !oui-px-0",
|
|
2834
|
+
body: "!oui-py-0"
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
);
|
|
2604
2838
|
|
|
2605
2839
|
// src/pages/multiLevel/affiliate/referrerTable/refereesTable/refereesTable.script.tsx
|
|
2606
2840
|
var useRefereesTableScript = (props = {}) => {
|
|
@@ -2665,6 +2899,18 @@ var useRefereesTableScript = (props = {}) => {
|
|
|
2665
2899
|
refereesMutate
|
|
2666
2900
|
]
|
|
2667
2901
|
);
|
|
2902
|
+
const onEditDescription = useCallback(
|
|
2903
|
+
(item) => {
|
|
2904
|
+
modal.show(RefereeDescriptionFormDialogId, {
|
|
2905
|
+
address: item.address,
|
|
2906
|
+
description: item.description,
|
|
2907
|
+
onSuccess: () => {
|
|
2908
|
+
refereesMutate();
|
|
2909
|
+
}
|
|
2910
|
+
});
|
|
2911
|
+
},
|
|
2912
|
+
[refereesMutate]
|
|
2913
|
+
);
|
|
2668
2914
|
const refereesData = useMemo(() => {
|
|
2669
2915
|
const rows = refereesRows ?? [];
|
|
2670
2916
|
if (!refereesSort) return rows;
|
|
@@ -2699,6 +2945,7 @@ var useRefereesTableScript = (props = {}) => {
|
|
|
2699
2945
|
refereesPagination,
|
|
2700
2946
|
isRefereesLoading,
|
|
2701
2947
|
onEditReferee,
|
|
2948
|
+
onEditDescription,
|
|
2702
2949
|
onRefereesSort,
|
|
2703
2950
|
showActionColumn,
|
|
2704
2951
|
baseRebateRate
|
|
@@ -2723,11 +2970,63 @@ var getRefereeType = (bindType) => {
|
|
|
2723
2970
|
tooltip: t("affiliate.multiLevel.tooltip")
|
|
2724
2971
|
};
|
|
2725
2972
|
};
|
|
2726
|
-
var
|
|
2973
|
+
var useMobileDescriptionModal = (content, title) => {
|
|
2974
|
+
const { isMobile } = useScreen();
|
|
2975
|
+
return useCallback(
|
|
2976
|
+
(e) => {
|
|
2977
|
+
if (!isMobile) return;
|
|
2978
|
+
e.preventDefault();
|
|
2979
|
+
e.stopPropagation();
|
|
2980
|
+
modal.dialog({
|
|
2981
|
+
title,
|
|
2982
|
+
closable: true,
|
|
2983
|
+
size: "sm",
|
|
2984
|
+
content: /* @__PURE__ */ jsx("div", { className: "oui-text-sm oui-leading-5 oui-text-base-contrast", children: content })
|
|
2985
|
+
});
|
|
2986
|
+
},
|
|
2987
|
+
[isMobile, content, title]
|
|
2988
|
+
);
|
|
2989
|
+
};
|
|
2990
|
+
var DescriptionCell = ({ description }) => {
|
|
2991
|
+
const { t } = useTranslation();
|
|
2992
|
+
const hasDescription = !!description && description.length > 0;
|
|
2993
|
+
const onClick = useMobileDescriptionModal(
|
|
2994
|
+
description,
|
|
2995
|
+
t("affiliate.refereeNote")
|
|
2996
|
+
);
|
|
2997
|
+
const { isMobile } = useScreen();
|
|
2998
|
+
if (!hasDescription) {
|
|
2999
|
+
return /* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, className: "oui-leading-[18px]", children: "--" });
|
|
3000
|
+
}
|
|
3001
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: description, open: isMobile ? false : void 0, children: /* @__PURE__ */ jsx(
|
|
3002
|
+
Text,
|
|
3003
|
+
{
|
|
3004
|
+
size: "2xs",
|
|
3005
|
+
intensity: 54,
|
|
3006
|
+
className: "oui-block oui-max-w-full oui-cursor-pointer oui-truncate oui-underline oui-decoration-dashed oui-underline-offset-4 oui-decoration-base-contrast-36 oui-leading-[18px]",
|
|
3007
|
+
onClick,
|
|
3008
|
+
children: description
|
|
3009
|
+
}
|
|
3010
|
+
) });
|
|
3011
|
+
};
|
|
3012
|
+
var AddressDescriptionCell = ({ item }) => {
|
|
3013
|
+
const { t } = useTranslation();
|
|
3014
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, className: "oui-min-w-0", children: [
|
|
3015
|
+
/* @__PURE__ */ jsx(AddressCell, { address: item.address, title: t("common.address") }),
|
|
3016
|
+
/* @__PURE__ */ jsx(DescriptionCell, { description: item.description })
|
|
3017
|
+
] });
|
|
3018
|
+
};
|
|
3019
|
+
var MobileRefereeItem = ({
|
|
3020
|
+
item,
|
|
3021
|
+
onEditReferee,
|
|
3022
|
+
onEditDescription,
|
|
3023
|
+
showActionColumn,
|
|
3024
|
+
baseRebateRate
|
|
3025
|
+
}) => {
|
|
2727
3026
|
const { t } = useTranslation();
|
|
2728
3027
|
const typeInfo = getRefereeType(item.bind_type);
|
|
2729
3028
|
return /* @__PURE__ */ jsxs(MobileCard, { children: [
|
|
2730
|
-
/* @__PURE__ */ jsx(MobileCell, { label: t("common.address"), children: /* @__PURE__ */ jsx(
|
|
3029
|
+
/* @__PURE__ */ jsx(MobileCell, { label: t("common.address"), children: /* @__PURE__ */ jsx(AddressDescriptionCell, { item }) }),
|
|
2731
3030
|
/* @__PURE__ */ jsx(MobileCell, { label: t("common.type"), children: /* @__PURE__ */ jsx(
|
|
2732
3031
|
TooltipCell,
|
|
2733
3032
|
{
|
|
@@ -2787,30 +3086,46 @@ var MobileRefereeItem = ({ item, onEditReferee, showActionColumn, baseRebateRate
|
|
|
2787
3086
|
title: t("affiliate.commission")
|
|
2788
3087
|
}
|
|
2789
3088
|
) }),
|
|
2790
|
-
|
|
3089
|
+
/* @__PURE__ */ jsx(
|
|
2791
3090
|
MobileCell,
|
|
2792
3091
|
{
|
|
2793
3092
|
label: t("common.action"),
|
|
2794
3093
|
align: "end",
|
|
2795
3094
|
className: "oui-col-start-3",
|
|
2796
|
-
children:
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
3095
|
+
children: /* @__PURE__ */ jsxs(
|
|
3096
|
+
Flex,
|
|
3097
|
+
{
|
|
3098
|
+
gap: 2,
|
|
3099
|
+
itemAlign: "center",
|
|
3100
|
+
className: "oui-flex-wrap oui-justify-end oui-gap-y-1",
|
|
3101
|
+
children: [
|
|
3102
|
+
showActionColumn && item.bind_type !== "legacy" && /* @__PURE__ */ jsx(
|
|
3103
|
+
Text,
|
|
3104
|
+
{
|
|
3105
|
+
className: "oui-refereesTable-edit-btn oui-shrink-0 oui-cursor-pointer oui-text-primary-light",
|
|
3106
|
+
onClick: () => onEditReferee("edit" /* Edit */, item),
|
|
3107
|
+
children: t("common.edit")
|
|
3108
|
+
}
|
|
3109
|
+
),
|
|
3110
|
+
/* @__PURE__ */ jsx(
|
|
3111
|
+
Text,
|
|
3112
|
+
{
|
|
3113
|
+
className: "oui-refereesTable-note-btn oui-shrink-0 oui-cursor-pointer oui-text-primary-light",
|
|
3114
|
+
onClick: () => onEditDescription(item),
|
|
3115
|
+
children: t("affiliate.note")
|
|
3116
|
+
}
|
|
3117
|
+
),
|
|
3118
|
+
showActionColumn && item.bind_type !== "legacy" && !item.is_default_rate && /* @__PURE__ */ jsx(
|
|
3119
|
+
Text,
|
|
3120
|
+
{
|
|
3121
|
+
className: "oui-refereesTable-reset-btn oui-shrink-0 oui-cursor-pointer oui-text-primary-light",
|
|
3122
|
+
onClick: () => onEditReferee("reset" /* Reset */, item),
|
|
3123
|
+
children: t("common.reset")
|
|
3124
|
+
}
|
|
3125
|
+
)
|
|
3126
|
+
]
|
|
3127
|
+
}
|
|
3128
|
+
)
|
|
2814
3129
|
}
|
|
2815
3130
|
)
|
|
2816
3131
|
] });
|
|
@@ -2824,7 +3139,7 @@ var RefereesTableUI = (props) => {
|
|
|
2824
3139
|
{
|
|
2825
3140
|
title: t("common.address"),
|
|
2826
3141
|
dataIndex: "address",
|
|
2827
|
-
render: (
|
|
3142
|
+
render: (_, record) => /* @__PURE__ */ jsx(AddressDescriptionCell, { item: record })
|
|
2828
3143
|
},
|
|
2829
3144
|
{
|
|
2830
3145
|
title: t("common.type"),
|
|
@@ -2915,35 +3230,52 @@ var RefereesTableUI = (props) => {
|
|
|
2915
3230
|
),
|
|
2916
3231
|
onSort: true
|
|
2917
3232
|
},
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
3233
|
+
{
|
|
3234
|
+
title: t("common.action"),
|
|
3235
|
+
dataIndex: "action",
|
|
3236
|
+
render: (_, record) => /* @__PURE__ */ jsxs(
|
|
3237
|
+
Flex,
|
|
3238
|
+
{
|
|
3239
|
+
gap: 2,
|
|
3240
|
+
itemAlign: "center",
|
|
3241
|
+
className: "oui-flex-wrap oui-gap-y-1",
|
|
3242
|
+
children: [
|
|
3243
|
+
props.showActionColumn && record.bind_type !== "legacy" && /* @__PURE__ */ jsx(
|
|
3244
|
+
Text,
|
|
3245
|
+
{
|
|
3246
|
+
className: "oui-refereesTable-edit-btn oui-shrink-0 oui-cursor-pointer oui-text-primary-light",
|
|
3247
|
+
onClick: () => props.onEditReferee("edit" /* Edit */, record),
|
|
3248
|
+
children: t("common.edit")
|
|
3249
|
+
}
|
|
3250
|
+
),
|
|
3251
|
+
/* @__PURE__ */ jsx(
|
|
3252
|
+
Text,
|
|
3253
|
+
{
|
|
3254
|
+
className: "oui-refereesTable-note-btn oui-shrink-0 oui-cursor-pointer oui-text-primary-light",
|
|
3255
|
+
onClick: () => props.onEditDescription(record),
|
|
3256
|
+
children: t("affiliate.note")
|
|
3257
|
+
}
|
|
3258
|
+
),
|
|
3259
|
+
props.showActionColumn && record.bind_type !== "legacy" && !record.is_default_rate && /* @__PURE__ */ jsx(
|
|
3260
|
+
Text,
|
|
3261
|
+
{
|
|
3262
|
+
className: "oui-refereesTable-reset-btn oui-shrink-0 oui-cursor-pointer oui-text-primary-light",
|
|
3263
|
+
onClick: () => props.onEditReferee("reset" /* Reset */, record),
|
|
3264
|
+
children: t("common.reset")
|
|
3265
|
+
}
|
|
3266
|
+
)
|
|
3267
|
+
]
|
|
3268
|
+
}
|
|
3269
|
+
)
|
|
3270
|
+
}
|
|
2945
3271
|
];
|
|
2946
|
-
}, [
|
|
3272
|
+
}, [
|
|
3273
|
+
t,
|
|
3274
|
+
props.onEditReferee,
|
|
3275
|
+
props.onEditDescription,
|
|
3276
|
+
props.showActionColumn,
|
|
3277
|
+
props.baseRebateRate
|
|
3278
|
+
]);
|
|
2947
3279
|
return /* @__PURE__ */ jsx(Fragment, { children: isMobile ? /* @__PURE__ */ jsx("div", { className: "oui-affiliate-refereesTable oui-flex oui-flex-col oui-px-4", children: /* @__PURE__ */ jsx(
|
|
2948
3280
|
ListView,
|
|
2949
3281
|
{
|
|
@@ -2955,6 +3287,7 @@ var RefereesTableUI = (props) => {
|
|
|
2955
3287
|
{
|
|
2956
3288
|
item,
|
|
2957
3289
|
onEditReferee: props.onEditReferee,
|
|
3290
|
+
onEditDescription: props.onEditDescription,
|
|
2958
3291
|
showActionColumn: props.showActionColumn,
|
|
2959
3292
|
baseRebateRate: props.baseRebateRate
|
|
2960
3293
|
}
|
|
@@ -4890,7 +5223,7 @@ var EditCodeModal = modal.create((props) => {
|
|
|
4890
5223
|
length: false,
|
|
4891
5224
|
format: false
|
|
4892
5225
|
};
|
|
4893
|
-
if (_code
|
|
5226
|
+
if (!isReferralCodeLengthValid(_code)) {
|
|
4894
5227
|
_fieldError.length = true;
|
|
4895
5228
|
}
|
|
4896
5229
|
if (!/^[A-Z0-9]+$/.test(_code)) {
|
|
@@ -4916,7 +5249,7 @@ var EditCodeModal = modal.create((props) => {
|
|
|
4916
5249
|
try {
|
|
4917
5250
|
const res = await editCode({
|
|
4918
5251
|
current_referral_code: props.code.code,
|
|
4919
|
-
new_referral_code: newCode
|
|
5252
|
+
new_referral_code: formatReferralCodeInput(newCode)
|
|
4920
5253
|
});
|
|
4921
5254
|
if (res.success) {
|
|
4922
5255
|
toast.success(
|
|
@@ -4945,8 +5278,7 @@ var EditCodeModal = modal.create((props) => {
|
|
|
4945
5278
|
},
|
|
4946
5279
|
value: newCode,
|
|
4947
5280
|
onChange: (e) => {
|
|
4948
|
-
|
|
4949
|
-
setNewCode(_value);
|
|
5281
|
+
setNewCode(formatReferralCodeInput(e.target.value));
|
|
4950
5282
|
},
|
|
4951
5283
|
formatters: [
|
|
4952
5284
|
inputFormatter.createRegexInputFormatter((value) => {
|
|
@@ -4961,8 +5293,8 @@ var EditCodeModal = modal.create((props) => {
|
|
|
4961
5293
|
label: "oui-text-base-contrast-54 oui-text-xs",
|
|
4962
5294
|
input: "placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"
|
|
4963
5295
|
},
|
|
4964
|
-
maxLength:
|
|
4965
|
-
minLength:
|
|
5296
|
+
maxLength: REFERRAL_CODE_MAX_LENGTH,
|
|
5297
|
+
minLength: REFERRAL_CODE_MIN_LENGTH,
|
|
4966
5298
|
autoComplete: "off",
|
|
4967
5299
|
helpText: ""
|
|
4968
5300
|
}
|
|
@@ -6284,8 +6616,7 @@ var EntryCode = (props) => {
|
|
|
6284
6616
|
placeholder: t("affiliate.referralCode"),
|
|
6285
6617
|
value: props.code,
|
|
6286
6618
|
onChange: (e) => {
|
|
6287
|
-
|
|
6288
|
-
props.setCode(_value);
|
|
6619
|
+
props.setCode(formatReferralCodeInput(e.target.value));
|
|
6289
6620
|
},
|
|
6290
6621
|
formatters: [
|
|
6291
6622
|
inputFormatter.createRegexInputFormatter(
|
|
@@ -6302,11 +6633,13 @@ var EntryCode = (props) => {
|
|
|
6302
6633
|
props.setCode("");
|
|
6303
6634
|
},
|
|
6304
6635
|
label: t("affiliate.referralCode.label"),
|
|
6636
|
+
maxLength: REFERRAL_CODE_MAX_LENGTH,
|
|
6637
|
+
minLength: REFERRAL_CODE_MIN_LENGTH,
|
|
6305
6638
|
classNames: {
|
|
6306
6639
|
label: "oui-text-2xs oui-text-base-contrast-54"
|
|
6307
6640
|
},
|
|
6308
|
-
helpText:
|
|
6309
|
-
color:
|
|
6641
|
+
helpText: isReferralCodeLengthValid(props.code) && !props.isExist && !props.isLoading ? t("affiliate.referralCode.notExist") : void 0,
|
|
6642
|
+
color: isReferralCodeLengthValid(props.code) && !props.isExist && !props.isLoading ? "danger" : void 0
|
|
6310
6643
|
}
|
|
6311
6644
|
),
|
|
6312
6645
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", gapY: 3, mt: 6, children: [
|
|
@@ -6319,7 +6652,7 @@ var EntryCode = (props) => {
|
|
|
6319
6652
|
size: "md",
|
|
6320
6653
|
className: "oui-px-[40px]",
|
|
6321
6654
|
fullWidth: true,
|
|
6322
|
-
disabled: props.code
|
|
6655
|
+
disabled: !isReferralCodeLengthValid(props.code) || !props.isExist,
|
|
6323
6656
|
onClick: (e) => {
|
|
6324
6657
|
e.stopPropagation();
|
|
6325
6658
|
props.onClickConfirm();
|
|
@@ -6354,7 +6687,9 @@ var useAsTraderScript = () => {
|
|
|
6354
6687
|
isExist,
|
|
6355
6688
|
error: checkCodeError,
|
|
6356
6689
|
isLoading
|
|
6357
|
-
} = useCheckReferralCode(
|
|
6690
|
+
} = useCheckReferralCode(
|
|
6691
|
+
code.length >= REFERRAL_CODE_MIN_LENGTH ? code : void 0
|
|
6692
|
+
);
|
|
6358
6693
|
const hide = () => {
|
|
6359
6694
|
setOpen(false);
|
|
6360
6695
|
};
|
|
@@ -6363,6 +6698,9 @@ var useAsTraderScript = () => {
|
|
|
6363
6698
|
"POST"
|
|
6364
6699
|
);
|
|
6365
6700
|
const onClickConfirm = async () => {
|
|
6701
|
+
if (!isReferralCodeLengthValid(code) || !isExist) {
|
|
6702
|
+
return;
|
|
6703
|
+
}
|
|
6366
6704
|
try {
|
|
6367
6705
|
await bindCode({ referral_code: code });
|
|
6368
6706
|
toast.success(t("affiliate.referralCode.bound"));
|