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