@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.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createContext, useState, useEffect, useRef, useMemo, useContext, useCallback, Fragment as Fragment$1 } from 'react';
2
- import { useMutation, cleanStringStyle, useAccount, usePrivateQuery, noCacheConfig, useDaily, useMemoizedFn, useMediaQuery, useReferralRebateSummary, useLocalStorage, useRefereeRebateSummary, useRefereeInfo, useCheckReferralCode } from '@orderly.network/hooks';
2
+ import { useMutation, 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
- import { registerSimpleDialog, registerSimpleSheet, modal, useModal, SimpleDialog, TextField, inputFormatter, Flex, Text, cn, toast, Dialog, DialogContent, DialogTitle, Divider, Input as Input$1, Button, formatAddress, Box, Slider, WarningIcon, Grid, Spinner, Collapsible, CollapsibleContent, Select, Tabs, TabPanel, usePagination, DatePicker, TabsBase, TabsList, TabsTrigger, TabsContent, parseNumber, ListView, CopyIcon, DataTable, useScreen, Statistic, Tooltip, DialogTrigger, DialogHeader, DialogBody } from '@orderly.network/ui';
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, Grid, Spinner, Collapsible, CollapsibleContent, Select, Tabs, TabPanel, usePagination, DatePicker, TabsBase, TabsList, TabsTrigger, TabsContent, parseNumber, ListView, CopyIcon, DataTable, useScreen, Statistic, Tooltip, DialogTrigger, DialogHeader, DialogBody } from '@orderly.network/ui';
6
6
  import { subDays, format, toDate } from 'date-fns';
7
7
  import { Decimal, commify, commifyOptional } from '@orderly.network/utils';
8
8
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
@@ -76,7 +76,11 @@ var useMultiLevelStatistics = (time_range) => {
76
76
  // src/hooks/useMultiLevelReferralData.ts
77
77
  var useMultiLevelReferralData = () => {
78
78
  const { data: volumePrerequisite, isLoading: volumePrerequisiteLoading } = useVolumePrerequisite();
79
- const { data: maxRebateRateRes, isLoading: maxRebateRateLoading } = useMaxRebateRate();
79
+ const {
80
+ data: maxRebateRateRes,
81
+ mutate: maxRebateRateMutate,
82
+ isLoading: maxRebateRateLoading
83
+ } = useMaxRebateRate();
80
84
  const {
81
85
  data: multiLevelRebateInfoRes,
82
86
  mutate: multiLevelRebateInfoMutate,
@@ -106,6 +110,7 @@ var useMultiLevelReferralData = () => {
106
110
  isMultiLevelEnabled,
107
111
  isMultiLevelReferralUnlocked,
108
112
  multiLevelRebateInfoMutate,
113
+ maxRebateRateMutate,
109
114
  isLoading
110
115
  };
111
116
  };
@@ -154,6 +159,7 @@ var ReferralProvider = (props) => {
154
159
  isMultiLevelReferralUnlocked,
155
160
  multiLevelRebateInfoMutate,
156
161
  maxRebateRate,
162
+ maxRebateRateMutate,
157
163
  isLoading: isMultiLevelLoading
158
164
  } = useMultiLevelReferralData();
159
165
  const [showHome, setShowHome] = useState(isLoading);
@@ -197,10 +203,12 @@ var ReferralProvider = (props) => {
197
203
  }
198
204
  }, [isAffiliate, isTrader]);
199
205
  const memoMutate = useMemoizedFn(() => {
200
- volumeStatisticsMutate();
201
- dailyVolumeMutate();
202
- referralInfoMutate();
203
- generateCodeMutate();
206
+ return Promise.allSettled([
207
+ volumeStatisticsMutate(),
208
+ dailyVolumeMutate(),
209
+ referralInfoMutate(),
210
+ generateCodeMutate()
211
+ ]);
204
212
  });
205
213
  useEffect(() => {
206
214
  const searchParams = new URLSearchParams(window.location.search);
@@ -263,7 +271,8 @@ var ReferralProvider = (props) => {
263
271
  isMultiLevelEnabled,
264
272
  isMultiLevelReferralUnlocked,
265
273
  multiLevelRebateInfoMutate,
266
- maxRebateRate
274
+ maxRebateRate,
275
+ maxRebateRateMutate
267
276
  };
268
277
  }, [
269
278
  becomeAnAffiliateUrl,
@@ -294,7 +303,8 @@ var ReferralProvider = (props) => {
294
303
  isMultiLevelReferralUnlocked,
295
304
  multiLevelRebateInfoMutate,
296
305
  maxRebateRate,
297
- isMultiLevelLoading
306
+ isMultiLevelLoading,
307
+ maxRebateRateMutate
298
308
  ]);
299
309
  return /* @__PURE__ */ jsx(ReferralContext.Provider, { value: memoizedValue, children });
300
310
  };
@@ -415,6 +425,7 @@ var ChevronIcon = ({ expanded }) => /* @__PURE__ */ jsx(
415
425
  }
416
426
  );
417
427
  var useReferralCode = () => {
428
+ const [doBindReferralCode, { isMutating: isBindMutating }] = useMutation("/v1/referral/bind");
418
429
  const [doCreateReferralCode, { isMutating: isCreateMutating }] = useMutation(
419
430
  "/v1/referral/multi_level/claim_code"
420
431
  );
@@ -426,6 +437,9 @@ var useReferralCode = () => {
426
437
  const createReferralCode = async (params) => {
427
438
  return doCreateReferralCode(params);
428
439
  };
440
+ const bindReferralCode = async (params) => {
441
+ return doBindReferralCode(params);
442
+ };
429
443
  const editReferralCode = async (params) => {
430
444
  return doEditReferralCode(params);
431
445
  };
@@ -435,8 +449,9 @@ var useReferralCode = () => {
435
449
  const resetRebateRate = async (params) => {
436
450
  return doResetRebateRate(params);
437
451
  };
438
- const isMutating = isCreateMutating || isEditMutating || isUpdateRebateRateMutating || isResetRebateRateMutating;
452
+ const isMutating = isBindMutating || isCreateMutating || isEditMutating || isUpdateRebateRateMutating || isResetRebateRateMutating;
439
453
  return {
454
+ bindReferralCode,
440
455
  createReferralCode,
441
456
  editReferralCode,
442
457
  updateRebateRate,
@@ -446,11 +461,25 @@ var useReferralCode = () => {
446
461
  };
447
462
 
448
463
  // src/pages/multiLevel/affiliate/referralCodeForm/referralCodeForm.script.ts
464
+ function formatReferralCodeInput(raw) {
465
+ return String(raw).replace(/[a-z]/g, (c) => c.toUpperCase()).replace(/[^A-Z0-9]/g, "");
466
+ }
449
467
  var useReferralCodeFormScript = (options) => {
450
468
  const { type, referralCode, maxRebateRate, referrerRebateRate, accountId } = options;
451
469
  const { t } = useTranslation();
470
+ const isBind = type === "bind" /* Bind */;
452
471
  const [newCode, setNewCode] = useState(referralCode || "");
472
+ const [bindCodeInput, setBindCodeInput] = useState("");
453
473
  const [isReview, setIsReview] = useState(false);
474
+ const [skipBinding, setSkipBinding] = useState(false);
475
+ const [isAwaitingPostSuccess, setIsAwaitingPostSuccess] = useState(false);
476
+ const formattedBindCode = useMemo(
477
+ () => formatReferralCodeInput(bindCodeInput),
478
+ [bindCodeInput]
479
+ );
480
+ const { isExist: isBindCodeExist, isLoading: isBindCodeChecking } = useCheckReferralCode(
481
+ isBind && formattedBindCode.length >= 4 ? formattedBindCode : void 0
482
+ );
454
483
  const maxRebatePercentage = useMemo(() => {
455
484
  return new Decimal(maxRebateRate).mul(100).toNumber();
456
485
  }, [maxRebateRate]);
@@ -465,7 +494,20 @@ var useReferralCodeFormScript = (options) => {
465
494
  return 0;
466
495
  }
467
496
  );
497
+ const applyCreateDefaults = () => {
498
+ setReferrerRebatePercentage(Math.ceil(maxRebatePercentage / 2));
499
+ };
500
+ const runBindOnSuccessThenApplyDefaults = async () => {
501
+ setIsAwaitingPostSuccess(true);
502
+ try {
503
+ await Promise.resolve(options.onSuccess?.());
504
+ } finally {
505
+ setIsAwaitingPostSuccess(false);
506
+ }
507
+ applyCreateDefaults();
508
+ };
468
509
  const {
510
+ bindReferralCode,
469
511
  createReferralCode,
470
512
  editReferralCode,
471
513
  updateRebateRate,
@@ -477,15 +519,22 @@ var useReferralCodeFormScript = (options) => {
477
519
  0,
478
520
  new Decimal(maxRebatePercentage).sub(referrerRebatePercentage).toNumber()
479
521
  );
480
- }, [referrerRebatePercentage]);
522
+ }, [maxRebatePercentage, referrerRebatePercentage]);
481
523
  const codeChanged = useMemo(() => {
482
524
  return newCode !== referralCode;
483
525
  }, [newCode, referralCode]);
484
526
  const rateChanged = useMemo(() => {
485
527
  return new Decimal(referrerRebatePercentage).toNumber() !== new Decimal(referrerRebateRate || 0).mul(100).toNumber();
486
528
  }, [referrerRebatePercentage, referrerRebateRate, newCode]);
529
+ const getErrorMessage = (err) => {
530
+ if (typeof err === "object" && err !== null && "message" in err) {
531
+ const msg = err.message;
532
+ return typeof msg === "string" ? msg : void 0;
533
+ }
534
+ return void 0;
535
+ };
487
536
  const handleError = (err) => {
488
- toast.error(err?.message || t("common.somethingWentWrong"));
537
+ toast.error(getErrorMessage(err) || t("common.somethingWentWrong"));
489
538
  };
490
539
  const handleResult = (res) => {
491
540
  if (res.success) {
@@ -493,7 +542,7 @@ var useReferralCodeFormScript = (options) => {
493
542
  toast.success(t("affiliate.confirmChanges.success"));
494
543
  options.close?.();
495
544
  } else {
496
- toast.error(res.message);
545
+ toast.error(res.message || t("common.somethingWentWrong"));
497
546
  }
498
547
  };
499
548
  const onEdit = async () => {
@@ -548,8 +597,27 @@ var useReferralCodeFormScript = (options) => {
548
597
  handleError(err);
549
598
  }
550
599
  };
600
+ const onBind = async () => {
601
+ if (skipBinding) {
602
+ await runBindOnSuccessThenApplyDefaults();
603
+ return;
604
+ }
605
+ if (formattedBindCode.length < 4 || formattedBindCode.length > 10 || isBindCodeChecking || !isBindCodeExist) {
606
+ return;
607
+ }
608
+ try {
609
+ await bindReferralCode({ referral_code: formattedBindCode });
610
+ toast.success(t("affiliate.referralCode.bound"));
611
+ await runBindOnSuccessThenApplyDefaults();
612
+ } catch (err) {
613
+ handleError(err);
614
+ }
615
+ };
551
616
  const onClick = () => {
552
617
  switch (type) {
618
+ case "bind" /* Bind */:
619
+ onBind();
620
+ break;
553
621
  case "create" /* Create */:
554
622
  onCreate();
555
623
  break;
@@ -565,19 +633,28 @@ var useReferralCodeFormScript = (options) => {
565
633
  break;
566
634
  }
567
635
  };
568
- const buttonDisabled = type === "edit" /* Edit */ && !codeChanged && !rateChanged;
636
+ const buttonDisabled = type === "edit" /* Edit */ && !codeChanged && !rateChanged || isBind && !skipBinding && (formattedBindCode.length < 4 || formattedBindCode.length > 10 || isBindCodeChecking || !isBindCodeExist);
637
+ const confirmButtonLoading = isMutating || isAwaitingPostSuccess;
569
638
  return {
639
+ type,
570
640
  onClick,
571
641
  maxRebatePercentage,
572
642
  referrerRebatePercentage,
573
643
  setReferrerRebatePercentage,
574
644
  refereeRebatePercentage,
575
- isMutating,
645
+ confirmButtonLoading,
576
646
  newCode,
577
647
  setNewCode,
648
+ bindCodeInput,
649
+ setBindCodeInput,
650
+ formattedBindCode,
578
651
  isReview,
579
652
  buttonDisabled,
580
- onReset
653
+ onReset,
654
+ skipBinding,
655
+ setSkipBinding,
656
+ isBindCodeExist,
657
+ isBindCodeChecking
581
658
  };
582
659
  };
583
660
  var GiftIcon = (props) => {
@@ -605,12 +682,27 @@ var GiftIcon = (props) => {
605
682
  var ReferralCodeForm = (props) => {
606
683
  const { type, isReview } = props;
607
684
  const { t } = useTranslation();
685
+ const isBind = type === "bind" /* Bind */;
608
686
  const isReset = type === "reset" /* Reset */;
609
687
  const hasBoundReferee = !!props.directInvites && props.directInvites > 0;
610
688
  const isEditingRefereeRebateRate = !!props.accountId;
611
689
  const noCommissionAvailable = props.maxRebateRate === 0;
612
690
  const { title, description, buttonText } = useMemo(() => {
613
691
  switch (type) {
692
+ case "bind" /* Bind */:
693
+ return {
694
+ title: t("affiliate.referralCode.bind.modal.title"),
695
+ description: /* @__PURE__ */ jsx(
696
+ Text,
697
+ {
698
+ size: "2xs",
699
+ intensity: 54,
700
+ className: "oui-leading-[18px] oui-text-warning-darken",
701
+ children: t("affiliate.referralCode.bind.modal.description")
702
+ }
703
+ ),
704
+ buttonText: t("common.confirm")
705
+ };
614
706
  case "create" /* Create */:
615
707
  return {
616
708
  title: t("affiliate.referralCode.create.modal.title"),
@@ -656,15 +748,53 @@ var ReferralCodeForm = (props) => {
656
748
  }
657
749
  );
658
750
  const descriptionView = /* @__PURE__ */ jsx(WarningBox, { children: description });
751
+ const bindCodeInvalid = isBind && !props.skipBinding && props.formattedBindCode.length >= 4 && !props.isBindCodeChecking && props.isBindCodeExist === false;
752
+ const bindReferralCodeInput = /* @__PURE__ */ jsx(
753
+ ReferralCodeInput,
754
+ {
755
+ value: props.bindCodeInput,
756
+ onChange: props.setBindCodeInput,
757
+ autoFocus: true,
758
+ disabled: props.skipBinding,
759
+ placeholder: t("affiliate.referralCode.bind.input.placeholder"),
760
+ helpText: bindCodeInvalid ? t("affiliate.referralCode.notExist") : void 0,
761
+ color: bindCodeInvalid ? "danger" : void 0
762
+ }
763
+ );
659
764
  const referralCodeInput = /* @__PURE__ */ jsx(
660
765
  ReferralCodeInput,
661
766
  {
662
767
  value: props.newCode,
663
768
  onChange: props.setNewCode,
664
769
  autoFocus: props.focusField === "referralCode" /* ReferralCode */,
665
- disabled: isReview || hasBoundReferee
770
+ disabled: isReview || hasBoundReferee,
771
+ label: t("affiliate.referralCode.editCodeModal.label")
666
772
  }
667
773
  );
774
+ const bindCheckbox = isBind && /* @__PURE__ */ jsxs(Flex, { className: "oui-gap-[6px]", children: [
775
+ /* @__PURE__ */ jsx(
776
+ Checkbox,
777
+ {
778
+ color: "white",
779
+ id: "oui-checkbox-skipReferralBinding",
780
+ checked: props.skipBinding,
781
+ onCheckedChange: (checked) => {
782
+ props.setSkipBinding(checked);
783
+ if (checked) {
784
+ props.setBindCodeInput("");
785
+ }
786
+ }
787
+ }
788
+ ),
789
+ /* @__PURE__ */ jsx(
790
+ "label",
791
+ {
792
+ htmlFor: "oui-checkbox-skipReferralBinding",
793
+ className: "oui-text-2xs oui-font-normal oui-text-base-contrast-54",
794
+ children: t("affiliate.referralCode.bind.skip")
795
+ }
796
+ )
797
+ ] });
668
798
  const commissionConfiguration = /* @__PURE__ */ jsxs(Fragment, { children: [
669
799
  /* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, children: t("affiliate.commissionConfiguration") }),
670
800
  !isReview && /* @__PURE__ */ jsxs(Text, { size: "2xs", intensity: 54, children: [
@@ -717,8 +847,8 @@ var ReferralCodeForm = (props) => {
717
847
  {
718
848
  fullWidth: true,
719
849
  onClick: props.onClick,
720
- disabled: props.buttonDisabled || props.isMutating,
721
- loading: props.isMutating,
850
+ disabled: props.buttonDisabled || props.confirmButtonLoading,
851
+ loading: props.confirmButtonLoading,
722
852
  size: "md",
723
853
  className: "oui-referralCodeForm-confirm-btn",
724
854
  children: buttonText
@@ -727,6 +857,12 @@ var ReferralCodeForm = (props) => {
727
857
  ] });
728
858
  const renderContent = () => {
729
859
  switch (type) {
860
+ case "bind" /* Bind */:
861
+ return /* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 4, children: [
862
+ bindReferralCodeInput,
863
+ bindCheckbox,
864
+ buttons
865
+ ] });
730
866
  case "create" /* Create */:
731
867
  return /* @__PURE__ */ jsxs(Flex, { width: "100%", direction: "column", itemAlign: "start", gap: 2, children: [
732
868
  commissionConfiguration,
@@ -789,7 +925,7 @@ var NoCommissionCard = (props) => {
789
925
  /* @__PURE__ */ jsxs(Flex, { justify: "between", width: "100%", itemAlign: "center", children: [
790
926
  /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
791
927
  /* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, children: t("affiliate.noCommissionCard.title") }),
792
- /* @__PURE__ */ jsxs(Text, { size: "lg", className: "oui-text-primary-light oui-font-semibold", children: [
928
+ /* @__PURE__ */ jsxs(Text, { size: "lg", className: "oui-font-semibold oui-text-primary-light", children: [
793
929
  "+ ",
794
930
  amount,
795
931
  "%"
@@ -851,7 +987,7 @@ var RebateRateSlider = (props) => {
851
987
  GiftIcon,
852
988
  {
853
989
  size: 16,
854
- className: "oui-text-base-contrast oui-mt-[1px]"
990
+ className: "oui-mt-px oui-text-base-contrast"
855
991
  }
856
992
  ),
857
993
  /* @__PURE__ */ jsx(
@@ -876,14 +1012,14 @@ var RebateRateSlider = (props) => {
876
1012
  ] });
877
1013
  };
878
1014
  var ReferralCodeInput = (props) => {
879
- const { t } = useTranslation();
880
1015
  const hasSetCursorToEnd = useRef(false);
881
1016
  return /* @__PURE__ */ jsx(
882
1017
  TextField,
883
1018
  {
884
1019
  type: "text",
885
1020
  fullWidth: true,
886
- label: t("affiliate.referralCode.editCodeModal.label"),
1021
+ label: props.label ?? "",
1022
+ placeholder: props.placeholder,
887
1023
  value: props.value,
888
1024
  onChange: (e) => {
889
1025
  props.onChange(e.target.value);
@@ -912,6 +1048,8 @@ var ReferralCodeInput = (props) => {
912
1048
  label: "oui-text-base-contrast-54 oui-text-xs",
913
1049
  input: "placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"
914
1050
  },
1051
+ helpText: props.helpText,
1052
+ color: props.color,
915
1053
  maxLength: 10,
916
1054
  minLength: 4,
917
1055
  autoComplete: "off",
@@ -1059,6 +1197,11 @@ var TradingVolumeProgress = (props) => {
1059
1197
  }
1060
1198
  );
1061
1199
  };
1200
+ function parseMaxRebateRateFromSettled(result) {
1201
+ if (result.status !== "fulfilled") return void 0;
1202
+ const num = result.value?.max_rebate_rate;
1203
+ return typeof num === "number" ? num : void 0;
1204
+ }
1062
1205
  var Hero = () => {
1063
1206
  const { t } = useTranslation();
1064
1207
  const { state } = useAccount();
@@ -1067,20 +1210,42 @@ var Hero = () => {
1067
1210
  const {
1068
1211
  isMultiLevelReferralUnlocked,
1069
1212
  isMultiLevelEnabled,
1213
+ isTrader,
1070
1214
  multiLevelRebateInfo,
1071
1215
  multiLevelRebateInfoMutate,
1072
- maxRebateRate
1216
+ maxRebateRate,
1217
+ maxRebateRateMutate,
1218
+ mutate
1073
1219
  } = useReferralContext();
1074
- const onCreateReferralCode = () => {
1220
+ const showCreateReferralCodeModal = (maxRateOverride) => {
1075
1221
  modal.show(ReferralCodeFormDialogId, {
1076
1222
  type: "create" /* Create */,
1077
- maxRebateRate,
1223
+ maxRebateRate: maxRateOverride ?? maxRebateRate ?? 0,
1078
1224
  directBonusRebateRate: 0,
1079
1225
  onSuccess: () => {
1080
1226
  multiLevelRebateInfoMutate();
1081
1227
  }
1082
1228
  });
1083
1229
  };
1230
+ const onCreateReferralCode = () => {
1231
+ if (!isTrader) {
1232
+ modal.show(ReferralCodeFormDialogId, {
1233
+ type: "bind" /* Bind */,
1234
+ maxRebateRate,
1235
+ onSuccess: async () => {
1236
+ const results = await Promise.allSettled([
1237
+ maxRebateRateMutate(),
1238
+ multiLevelRebateInfoMutate(),
1239
+ mutate()
1240
+ ]);
1241
+ const latestMaxRebateRate = parseMaxRebateRateFromSettled(results[0]) ?? maxRebateRate;
1242
+ showCreateReferralCodeModal(latestMaxRebateRate);
1243
+ }
1244
+ });
1245
+ return;
1246
+ }
1247
+ showCreateReferralCodeModal();
1248
+ };
1084
1249
  const description = useMemo(() => {
1085
1250
  if (wrongNetwork) {
1086
1251
  return t("affiliate.wrongNetwork.description");
@@ -2978,6 +3143,7 @@ var Summary = (props) => {
2978
3143
  value: statistics.total_rebate,
2979
3144
  direct: statistics.direct_rebate + statistics.direct_bonus_rebate,
2980
3145
  indirect: statistics.indirect_rebate,
3146
+ referredByCode: props.referredByCode,
2981
3147
  classNames: {
2982
3148
  root: "!oui-py-12",
2983
3149
  value: "oui-text-trade-profit",
@@ -3041,7 +3207,7 @@ var SummaryItem = (props) => {
3041
3207
  Text.numeral,
3042
3208
  {
3043
3209
  rule,
3044
- dp: props.dp,
3210
+ dp,
3045
3211
  size: "3xl",
3046
3212
  prefix: props.prefix,
3047
3213
  placeholder: "--",
@@ -3060,7 +3226,7 @@ var SummaryItem = (props) => {
3060
3226
  Text.numeral,
3061
3227
  {
3062
3228
  rule,
3063
- dp: props.dp,
3229
+ dp,
3064
3230
  prefix: props.prefix,
3065
3231
  intensity: 54,
3066
3232
  className: props.classNames?.direct,
@@ -3078,7 +3244,7 @@ var SummaryItem = (props) => {
3078
3244
  Text.numeral,
3079
3245
  {
3080
3246
  rule,
3081
- dp: props.dp,
3247
+ dp,
3082
3248
  prefix: props.prefix,
3083
3249
  intensity: 54,
3084
3250
  className: props.classNames?.indirect,
@@ -3086,15 +3252,28 @@ var SummaryItem = (props) => {
3086
3252
  }
3087
3253
  )
3088
3254
  ] })
3089
- ] })
3255
+ ] }),
3256
+ props.referredByCode ? /* @__PURE__ */ jsx(
3257
+ Text,
3258
+ {
3259
+ intensity: 54,
3260
+ className: "oui-affiliate-summary-referred-by oui-mt-5 oui-text-base-contrast-54",
3261
+ children: t("affiliate.referredBy", { name: props.referredByCode })
3262
+ }
3263
+ ) : null
3090
3264
  ]
3091
3265
  }
3092
3266
  );
3093
3267
  };
3094
3268
  var useSummaryScript = () => {
3095
3269
  const { t } = useTranslation();
3270
+ const { referralInfo } = useReferralContext();
3096
3271
  const [period, setPeriod] = useState("all_time" /* All */);
3097
3272
  const { data } = useMultiLevelStatistics(period);
3273
+ const referredByCode = useMemo(() => {
3274
+ const code = referralInfo?.referee_info?.referer_code?.trim();
3275
+ return code || void 0;
3276
+ }, [referralInfo]);
3098
3277
  const periodTypes = [
3099
3278
  { label: t("common.all"), value: "all_time" /* All */ },
3100
3279
  { label: t("common.select.1d"), value: "1d" /* 1d */ },
@@ -3136,7 +3315,8 @@ var useSummaryScript = () => {
3136
3315
  period,
3137
3316
  periodTypes,
3138
3317
  onPeriodChange,
3139
- statistics
3318
+ statistics,
3319
+ referredByCode
3140
3320
  };
3141
3321
  };
3142
3322
  var SummaryWidget = () => {