@orderly.network/affiliate 3.0.0-beta.1 → 3.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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,
@@ -772,6 +908,9 @@ var ReferralCodeForm = (props) => {
772
908
  var NoCommissionCard = (props) => {
773
909
  const { t } = useTranslation();
774
910
  const amount = props.directBonusRebateRate;
911
+ if (!amount || amount <= 0) {
912
+ return null;
913
+ }
775
914
  return /* @__PURE__ */ jsxs(
776
915
  Flex,
777
916
  {
@@ -786,7 +925,7 @@ var NoCommissionCard = (props) => {
786
925
  /* @__PURE__ */ jsxs(Flex, { justify: "between", width: "100%", itemAlign: "center", children: [
787
926
  /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
788
927
  /* @__PURE__ */ jsx(Text, { size: "2xs", intensity: 54, children: t("affiliate.noCommissionCard.title") }),
789
- /* @__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: [
790
929
  "+ ",
791
930
  amount,
792
931
  "%"
@@ -848,7 +987,7 @@ var RebateRateSlider = (props) => {
848
987
  GiftIcon,
849
988
  {
850
989
  size: 16,
851
- className: "oui-text-base-contrast oui-mt-[1px]"
990
+ className: "oui-mt-px oui-text-base-contrast"
852
991
  }
853
992
  ),
854
993
  /* @__PURE__ */ jsx(
@@ -873,14 +1012,14 @@ var RebateRateSlider = (props) => {
873
1012
  ] });
874
1013
  };
875
1014
  var ReferralCodeInput = (props) => {
876
- const { t } = useTranslation();
877
1015
  const hasSetCursorToEnd = useRef(false);
878
1016
  return /* @__PURE__ */ jsx(
879
1017
  TextField,
880
1018
  {
881
1019
  type: "text",
882
1020
  fullWidth: true,
883
- label: t("affiliate.referralCode.editCodeModal.label"),
1021
+ label: props.label ?? "",
1022
+ placeholder: props.placeholder,
884
1023
  value: props.value,
885
1024
  onChange: (e) => {
886
1025
  props.onChange(e.target.value);
@@ -909,6 +1048,8 @@ var ReferralCodeInput = (props) => {
909
1048
  label: "oui-text-base-contrast-54 oui-text-xs",
910
1049
  input: "placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"
911
1050
  },
1051
+ helpText: props.helpText,
1052
+ color: props.color,
912
1053
  maxLength: 10,
913
1054
  minLength: 4,
914
1055
  autoComplete: "off",
@@ -1056,6 +1197,11 @@ var TradingVolumeProgress = (props) => {
1056
1197
  }
1057
1198
  );
1058
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
+ }
1059
1205
  var Hero = () => {
1060
1206
  const { t } = useTranslation();
1061
1207
  const { state } = useAccount();
@@ -1064,21 +1210,42 @@ var Hero = () => {
1064
1210
  const {
1065
1211
  isMultiLevelReferralUnlocked,
1066
1212
  isMultiLevelEnabled,
1213
+ isTrader,
1067
1214
  multiLevelRebateInfo,
1068
1215
  multiLevelRebateInfoMutate,
1069
- maxRebateRate
1216
+ maxRebateRate,
1217
+ maxRebateRateMutate,
1218
+ mutate
1070
1219
  } = useReferralContext();
1071
- const onCreateReferralCode = () => {
1220
+ const showCreateReferralCodeModal = (maxRateOverride) => {
1072
1221
  modal.show(ReferralCodeFormDialogId, {
1073
1222
  type: "create" /* Create */,
1074
- maxRebateRate,
1075
- directBonusRebateRate: 10,
1076
- // Hardcoded value before API is ready
1223
+ maxRebateRate: maxRateOverride ?? maxRebateRate ?? 0,
1224
+ directBonusRebateRate: 0,
1077
1225
  onSuccess: () => {
1078
1226
  multiLevelRebateInfoMutate();
1079
1227
  }
1080
1228
  });
1081
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
+ };
1082
1249
  const description = useMemo(() => {
1083
1250
  if (wrongNetwork) {
1084
1251
  return t("affiliate.wrongNetwork.description");
@@ -1530,8 +1697,8 @@ var useMultiLevelReferralScript = () => {
1530
1697
  modal.show(ReferralCodeFormDialogId, {
1531
1698
  type: "create" /* Create */,
1532
1699
  maxRebateRate,
1533
- directBonusRebateRate: 10,
1534
- // Hardcoded value before API is ready
1700
+ // because there is no multi level code, the /v1/referral/multi_level/rebate_info interface will throw an error, so here set to 0, and hide the extra bonus display when creating multi level code
1701
+ directBonusRebateRate: 0,
1535
1702
  onSuccess: () => {
1536
1703
  multiLevelRebateInfoMutate();
1537
1704
  }
@@ -2976,6 +3143,7 @@ var Summary = (props) => {
2976
3143
  value: statistics.total_rebate,
2977
3144
  direct: statistics.direct_rebate + statistics.direct_bonus_rebate,
2978
3145
  indirect: statistics.indirect_rebate,
3146
+ referredByCode: props.referredByCode,
2979
3147
  classNames: {
2980
3148
  root: "!oui-py-12",
2981
3149
  value: "oui-text-trade-profit",
@@ -3039,7 +3207,7 @@ var SummaryItem = (props) => {
3039
3207
  Text.numeral,
3040
3208
  {
3041
3209
  rule,
3042
- dp: props.dp,
3210
+ dp,
3043
3211
  size: "3xl",
3044
3212
  prefix: props.prefix,
3045
3213
  placeholder: "--",
@@ -3058,7 +3226,7 @@ var SummaryItem = (props) => {
3058
3226
  Text.numeral,
3059
3227
  {
3060
3228
  rule,
3061
- dp: props.dp,
3229
+ dp,
3062
3230
  prefix: props.prefix,
3063
3231
  intensity: 54,
3064
3232
  className: props.classNames?.direct,
@@ -3076,7 +3244,7 @@ var SummaryItem = (props) => {
3076
3244
  Text.numeral,
3077
3245
  {
3078
3246
  rule,
3079
- dp: props.dp,
3247
+ dp,
3080
3248
  prefix: props.prefix,
3081
3249
  intensity: 54,
3082
3250
  className: props.classNames?.indirect,
@@ -3084,15 +3252,28 @@ var SummaryItem = (props) => {
3084
3252
  }
3085
3253
  )
3086
3254
  ] })
3087
- ] })
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
3088
3264
  ]
3089
3265
  }
3090
3266
  );
3091
3267
  };
3092
3268
  var useSummaryScript = () => {
3093
3269
  const { t } = useTranslation();
3270
+ const { referralInfo } = useReferralContext();
3094
3271
  const [period, setPeriod] = useState("all_time" /* All */);
3095
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]);
3096
3277
  const periodTypes = [
3097
3278
  { label: t("common.all"), value: "all_time" /* All */ },
3098
3279
  { label: t("common.select.1d"), value: "1d" /* 1d */ },
@@ -3134,7 +3315,8 @@ var useSummaryScript = () => {
3134
3315
  period,
3135
3316
  periodTypes,
3136
3317
  onPeriodChange,
3137
- statistics
3318
+ statistics,
3319
+ referredByCode
3138
3320
  };
3139
3321
  };
3140
3322
  var SummaryWidget = () => {