@orderly.network/affiliate 2.12.0 → 2.12.1

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 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 { data: maxRebateRateRes, isLoading: maxRebateRateLoading } = useMaxRebateRate();
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
- volumeStatisticsMutate();
203
- dailyVolumeMutate();
204
- referralInfoMutate();
205
- generateCodeMutate();
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?.message || t("common.somethingWentWrong"));
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
- isMutating,
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.isMutating,
723
- loading: props.isMutating,
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,
@@ -791,7 +927,7 @@ var NoCommissionCard = (props) => {
791
927
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "between", width: "100%", itemAlign: "center", children: [
792
928
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
793
929
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "2xs", intensity: 54, children: t("affiliate.noCommissionCard.title") }),
794
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "lg", className: "oui-text-primary-light oui-font-semibold", children: [
930
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "lg", className: "oui-font-semibold oui-text-primary-light", children: [
795
931
  "+ ",
796
932
  amount,
797
933
  "%"
@@ -853,7 +989,7 @@ var RebateRateSlider = (props) => {
853
989
  GiftIcon,
854
990
  {
855
991
  size: 16,
856
- className: "oui-text-base-contrast oui-mt-[1px]"
992
+ className: "oui-mt-px oui-text-base-contrast"
857
993
  }
858
994
  ),
859
995
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -878,14 +1014,14 @@ var RebateRateSlider = (props) => {
878
1014
  ] });
879
1015
  };
880
1016
  var ReferralCodeInput = (props) => {
881
- const { t } = i18n.useTranslation();
882
1017
  const hasSetCursorToEnd = react.useRef(false);
883
1018
  return /* @__PURE__ */ jsxRuntime.jsx(
884
1019
  ui.TextField,
885
1020
  {
886
1021
  type: "text",
887
1022
  fullWidth: true,
888
- label: t("affiliate.referralCode.editCodeModal.label"),
1023
+ label: props.label ?? "",
1024
+ placeholder: props.placeholder,
889
1025
  value: props.value,
890
1026
  onChange: (e) => {
891
1027
  props.onChange(e.target.value);
@@ -914,6 +1050,8 @@ var ReferralCodeInput = (props) => {
914
1050
  label: "oui-text-base-contrast-54 oui-text-xs",
915
1051
  input: "placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"
916
1052
  },
1053
+ helpText: props.helpText,
1054
+ color: props.color,
917
1055
  maxLength: 10,
918
1056
  minLength: 4,
919
1057
  autoComplete: "off",
@@ -1061,6 +1199,11 @@ var TradingVolumeProgress = (props) => {
1061
1199
  }
1062
1200
  );
1063
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
+ }
1064
1207
  var Hero = () => {
1065
1208
  const { t } = i18n.useTranslation();
1066
1209
  const { state } = hooks.useAccount();
@@ -1069,20 +1212,42 @@ var Hero = () => {
1069
1212
  const {
1070
1213
  isMultiLevelReferralUnlocked,
1071
1214
  isMultiLevelEnabled,
1215
+ isTrader,
1072
1216
  multiLevelRebateInfo,
1073
1217
  multiLevelRebateInfoMutate,
1074
- maxRebateRate
1218
+ maxRebateRate,
1219
+ maxRebateRateMutate,
1220
+ mutate
1075
1221
  } = useReferralContext();
1076
- const onCreateReferralCode = () => {
1222
+ const showCreateReferralCodeModal = (maxRateOverride) => {
1077
1223
  ui.modal.show(ReferralCodeFormDialogId, {
1078
1224
  type: "create" /* Create */,
1079
- maxRebateRate,
1225
+ maxRebateRate: maxRateOverride ?? maxRebateRate ?? 0,
1080
1226
  directBonusRebateRate: 0,
1081
1227
  onSuccess: () => {
1082
1228
  multiLevelRebateInfoMutate();
1083
1229
  }
1084
1230
  });
1085
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
+ };
1086
1251
  const description = react.useMemo(() => {
1087
1252
  if (wrongNetwork) {
1088
1253
  return t("affiliate.wrongNetwork.description");
@@ -2980,6 +3145,7 @@ var Summary = (props) => {
2980
3145
  value: statistics.total_rebate,
2981
3146
  direct: statistics.direct_rebate + statistics.direct_bonus_rebate,
2982
3147
  indirect: statistics.indirect_rebate,
3148
+ referredByCode: props.referredByCode,
2983
3149
  classNames: {
2984
3150
  root: "!oui-py-12",
2985
3151
  value: "oui-text-trade-profit",
@@ -3043,7 +3209,7 @@ var SummaryItem = (props) => {
3043
3209
  ui.Text.numeral,
3044
3210
  {
3045
3211
  rule,
3046
- dp: props.dp,
3212
+ dp,
3047
3213
  size: "3xl",
3048
3214
  prefix: props.prefix,
3049
3215
  placeholder: "--",
@@ -3062,7 +3228,7 @@ var SummaryItem = (props) => {
3062
3228
  ui.Text.numeral,
3063
3229
  {
3064
3230
  rule,
3065
- dp: props.dp,
3231
+ dp,
3066
3232
  prefix: props.prefix,
3067
3233
  intensity: 54,
3068
3234
  className: props.classNames?.direct,
@@ -3080,7 +3246,7 @@ var SummaryItem = (props) => {
3080
3246
  ui.Text.numeral,
3081
3247
  {
3082
3248
  rule,
3083
- dp: props.dp,
3249
+ dp,
3084
3250
  prefix: props.prefix,
3085
3251
  intensity: 54,
3086
3252
  className: props.classNames?.indirect,
@@ -3088,15 +3254,28 @@ var SummaryItem = (props) => {
3088
3254
  }
3089
3255
  )
3090
3256
  ] })
3091
- ] })
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
3092
3266
  ]
3093
3267
  }
3094
3268
  );
3095
3269
  };
3096
3270
  var useSummaryScript = () => {
3097
3271
  const { t } = i18n.useTranslation();
3272
+ const { referralInfo } = useReferralContext();
3098
3273
  const [period, setPeriod] = react.useState("all_time" /* All */);
3099
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]);
3100
3279
  const periodTypes = [
3101
3280
  { label: t("common.all"), value: "all_time" /* All */ },
3102
3281
  { label: t("common.select.1d"), value: "1d" /* 1d */ },
@@ -3138,7 +3317,8 @@ var useSummaryScript = () => {
3138
3317
  period,
3139
3318
  periodTypes,
3140
3319
  onPeriodChange,
3141
- statistics
3320
+ statistics,
3321
+ referredByCode
3142
3322
  };
3143
3323
  };
3144
3324
  var SummaryWidget = () => {