@orderly.network/affiliate 2.8.4 → 2.8.5

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
@@ -103,7 +103,7 @@ var ReferralProvider = (props) => {
103
103
  const {
104
104
  becomeAnAffiliateUrl = "https://orderly.network/",
105
105
  learnAffiliateUrl = "https://orderly.network/",
106
- referralLinkUrl = "https://orderly.network/",
106
+ referralLinkUrl,
107
107
  chartConfig,
108
108
  overwrite,
109
109
  children,
@@ -774,16 +774,8 @@ var Alert = (props) => {
774
774
  }
775
775
  ) });
776
776
  };
777
- function addQueryParam(url, paramName, paramValue) {
778
- try {
779
- const urlObj = new URL(url);
780
- const searchParams = new URLSearchParams(urlObj.search);
781
- searchParams.set(paramName, paramValue);
782
- urlObj.search = searchParams.toString();
783
- return urlObj.toString();
784
- } catch (error) {
785
- return url;
786
- }
777
+ function generateReferralLink(referralLinkUrl, code) {
778
+ return `${referralLinkUrl || window?.location?.origin}?ref=${code}`;
787
779
  }
788
780
  async function copyText(content) {
789
781
  try {
@@ -855,7 +847,7 @@ var useReferralLinkScript = () => {
855
847
  const referralLink = react.useMemo(() => {
856
848
  if (!firstCode)
857
849
  return "";
858
- return addQueryParam(referralLinkUrl, "ref", firstCode.code);
850
+ return generateReferralLink(referralLinkUrl, firstCode.code);
859
851
  }, [firstCode]);
860
852
  const earn = react.useMemo(() => {
861
853
  const value = new utils.Decimal(firstCode?.referrer_rebate_rate || "0").mul(100).toDecimalPlaces(0, utils.Decimal.ROUND_DOWN).toString();
@@ -1736,7 +1728,7 @@ function maxDecimal(a, b) {
1736
1728
  var useReferralCodesScript = () => {
1737
1729
  const { referralInfo, referralLinkUrl, mutate, generateCode } = useReferralContext();
1738
1730
  const copyLink = (code) => {
1739
- copyText(addQueryParam(referralLinkUrl, "ref", code));
1731
+ copyText(generateReferralLink(referralLinkUrl, code));
1740
1732
  };
1741
1733
  const copyCode = (code) => {
1742
1734
  copyText(code);