@kodiak-finance/orderly-affiliate 2.8.18 → 2.8.19-rc.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.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4064 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4061 -6
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,25 +1,4080 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var orderlyUi = require('@kodiak-finance/orderly-ui');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var orderlyUtils = require('@kodiak-finance/orderly-utils');
|
|
6
4
|
var orderlyI18n = require('@kodiak-finance/orderly-i18n');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
6
|
var react = require('react');
|
|
8
7
|
var dateFns = require('date-fns');
|
|
9
8
|
var orderlyHooks = require('@kodiak-finance/orderly-hooks');
|
|
10
9
|
var orderlyReactApp = require('@kodiak-finance/orderly-react-app');
|
|
11
10
|
var orderlyTypes = require('@kodiak-finance/orderly-types');
|
|
11
|
+
var orderlyUtils = require('@kodiak-finance/orderly-utils');
|
|
12
12
|
var orderlyChart = require('@kodiak-finance/orderly-chart');
|
|
13
13
|
var orderlyUiConnector = require('@kodiak-finance/orderly-ui-connector');
|
|
14
14
|
var orderlyUiScaffold = require('@kodiak-finance/orderly-ui-scaffold');
|
|
15
15
|
|
|
16
|
-
var gi=Object.defineProperty;var hi=(e,t)=>{for(var r in t)gi(e,r,{get:t[r],enumerable:true});};var si={};hi(si,{AffiliatePage:()=>_e,DashboardPage:()=>li,HomePage:()=>ve,TraderPage:()=>Le});var mt=e=>{let{size:t=16,className:r,...a}=e;return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"#fff",fillOpacity:".98",xmlns:"http://www.w3.org/2000/svg",className:e.className,...a,children:[jsxRuntime.jsx("path",{d:"M8 1.302c-3.683 0-6.655 2.985-6.667 6.667-.013 3.676 2.987 6.68 6.666 6.687s6.674-3.037 6.667-6.687c-.007-3.682-2.985-6.667-6.667-6.667m0 1.333a5.333 5.333 0 0 1 5.333 5.334c0 1.5-.625 2.852-1.622 3.821-.49-1.062-1.545-1.821-2.753-1.821H7.04c-1.207 0-2.259.75-2.75 1.812A5.3 5.3 0 0 1 2.666 7.97a5.333 5.333 0 0 1 5.333-5.334M8 3.97a2.667 2.667 0 1 0 0 5.333A2.667 2.667 0 0 0 8 3.97"}),jsxRuntime.jsx("path",{d:"M16 12.667a3.333 3.333 0 1 1-6.667 0 3.333 3.333 0 0 1 6.667 0",fill:"#1828C3"}),jsxRuntime.jsx("path",{d:"M11.917 11.433a.917.917 0 0 0-.917.917c0 .53.302 1.031.802 1.49a4.6 4.6 0 0 0 .713.53l.068.043c.05.027.117.027.167 0l.068-.042q.08-.05.177-.115c.182-.123.366-.26.536-.416.5-.459.802-.96.802-1.49a.917.917 0 0 0-.917-.917.97.97 0 0 0-.744.386.95.95 0 0 0-.756-.386"})]})};var dt=e=>{let{size:t=16,className:r,...a}=e;return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"white",fillOpacity:"0.36",xmlns:"http://www.w3.org/2000/svg",className:e.className,...a,children:[jsxRuntime.jsx("path",{d:"M7.99929 1.30212C4.31735 1.30212 1.34509 4.28679 1.33262 7.96878C1.32015 11.6454 4.32042 14.6488 7.99929 14.6561C11.6782 14.6634 14.6726 11.6194 14.666 7.96878C14.6593 4.28679 11.6812 1.30212 7.99929 1.30212ZM7.99929 2.63546C10.9448 2.63546 13.3326 5.02345 13.3326 7.96878C13.3326 9.46878 12.7078 10.8208 11.7112 11.7901C11.2202 10.7281 10.1656 9.96878 8.95762 9.96878C8.71802 9.96878 7.28042 9.96878 7.04095 9.96878C5.83369 9.96878 4.78215 10.7188 4.29095 11.7814C3.29429 10.8121 2.66595 9.46878 2.66595 7.96878C2.66595 5.02345 5.05375 2.63546 7.99929 2.63546ZM7.99929 3.96879C6.52649 3.96879 5.33255 5.16279 5.33262 6.63545C5.33262 8.10812 6.52649 9.30212 7.99929 9.30212C9.47202 9.30212 10.666 8.10812 10.666 6.63545C10.666 5.16279 9.47202 3.96879 7.99929 3.96879Z"}),jsxRuntime.jsx("path",{d:"M16 12.6667C16 14.5076 14.5076 16 12.6666 16C10.8257 16 9.33331 14.5076 9.33331 12.6667C9.33331 10.8257 10.8257 9.33333 12.6666 9.33333C14.5076 9.33333 16 10.8257 16 12.6667Z",fill:"#005A4F"}),jsxRuntime.jsx("path",{d:"M14.3325 13.3345C14.3325 13.2918 14.3182 13.2473 14.2857 13.2147L13.6658 12.6002L13.4315 12.8345L13.7595 13.1678H11.3325C11.2405 13.1678 11.1658 13.2425 11.1658 13.3345C11.1658 13.4265 11.2405 13.5012 11.3325 13.5012H13.7595L13.4315 13.8345L13.6658 14.0688L14.2857 13.4543C14.3182 13.4217 14.3325 13.3772 14.3325 13.3345ZM14.1658 12.0012C14.1658 11.9092 14.0912 11.8345 13.9992 11.8345H11.572L11.9002 11.5012L11.6658 11.2668L11.046 11.8813C10.981 11.9465 10.981 12.0558 11.046 12.121L11.6658 12.7355L11.9002 12.5012L11.572 12.1678H13.9992C14.0912 12.1678 14.1658 12.0932 14.1658 12.0012Z",fill:"white",fillOpacity:"0.98"})]})};var J=e=>jsxRuntime.jsxs("svg",{width:"21",height:"20",viewBox:"0 0 21 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e.className,children:[jsxRuntime.jsxs("g",{clipPath:"url(#a)",children:[jsxRuntime.jsx("path",{d:"M10.5 20c5.542 0 10-4.458 10-10s-4.458-10-10-10S.5 4.458.5 10s4.458 10 10 10",fill:"#2775CA"}),jsxRuntime.jsx("path",{d:"M13.5 11.473c0-1.452-.94-1.95-2.82-2.158-1.344-.166-1.613-.498-1.613-1.078s.448-.955 1.343-.955c.806 0 1.254.25 1.478.872.045.124.18.207.313.207h.717c.179 0 .313-.125.313-.29v-.042c-.179-.913-.985-1.618-2.015-1.701v-.996c0-.166-.134-.29-.358-.332h-.671c-.18 0-.314.124-.359.332v.954c-1.343.166-2.194.996-2.194 2.034 0 1.369.896 1.908 2.776 2.116 1.254.207 1.657.456 1.657 1.12s-.627 1.12-1.477 1.12c-1.165 0-1.568-.456-1.702-1.078a.32.32 0 0 0-.313-.25h-.762c-.179 0-.313.125-.313.291v.042c.179 1.037.895 1.784 2.373 1.991v.996c0 .166.134.29.358.332h.672c.18 0 .313-.124.358-.332v-.996c1.344-.207 2.239-1.079 2.239-2.199",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{d:"M8.24 16.57c-3.458-1.215-5.23-4.986-3.945-8.324.665-1.821 2.127-3.208 3.944-3.859.178-.086.266-.216.266-.433v-.607c0-.174-.088-.304-.266-.347-.044 0-.133 0-.177.043-4.21 1.3-6.516 5.68-5.186 9.798.798 2.428 2.704 4.292 5.186 5.072.177.087.355 0 .4-.173.043-.043.043-.087.043-.173v-.608c0-.13-.133-.303-.266-.39m4.698-13.527c-.178-.086-.355 0-.4.174-.043.043-.043.086-.043.173v.607c0 .174.133.347.266.434 3.457 1.213 5.23 4.985 3.944 8.323-.664 1.821-2.127 3.209-3.944 3.859-.178.086-.266.216-.266.433v.607c0 .174.088.304.266.347.044 0 .133 0 .177-.043 4.21-1.3 6.515-5.68 5.186-9.798-.798-2.471-2.748-4.335-5.186-5.116",fill:"#fff",fillOpacity:".98"})]}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:"a",children:jsxRuntime.jsx("path",{fill:"#fff",d:"M.5 0h20v20H.5z"})})})]});var gt=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-affiliate-summary",r:"2xl",p:6,width:"100%",height:"100%",gap:4,direction:"column",className:"oui-bg-base-9",children:[jsxRuntime.jsx(yi,{...e}),jsxRuntime.jsx(vi,{...e}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",width:"100%",gap:2,children:[jsxRuntime.jsx(xt,{title:`${t("affiliate.referralVol")} (USDC)`,value:e.referralVol,dp:2,...e}),jsxRuntime.jsx(xt,{title:t("affiliate.referees"),value:e.referees,dp:0,...e}),jsxRuntime.jsx(xt,{title:t("affiliate.summary.refereesTraded"),value:e.refereesTades,dp:0,...e})]})]})},yi=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.summary")}),jsxRuntime.jsx("div",{className:"oui-min-w-14",children:jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes})})]})},vi=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{gradient:"primary",angle:180,r:"xl",py:4,px:6,width:"100%",direction:"column",gap:3,height:"100%",className:"oui-max-h-[104px]",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-base 2xl:oui-text-lg",children:`${t("affiliate.commission")} (USDC)`}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:3,className:"oui-text-xl md:oui-text-2xl xl:oui-text-3xl",children:[jsxRuntime.jsx(J,{className:"md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] "}),jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(e.commission,{fix:2,fallback:"0"})})]})]})},xt=e=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:e.title}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-xs md:oui-text-sm xl:oui-text-base",children:orderlyUtils.commifyOptional(e.value,{fix:e.dp,fallback:"0"})})]});var Ne=(r=>(r.affiliate="affiliate",r.trader="trader",r))(Ne||{}),Vr=react.createContext({}),Ss=e=>{let{becomeAnAffiliateUrl:t="https://orderly.network/",learnAffiliateUrl:r="https://orderly.network/",referralLinkUrl:a="https://orderly.network/",chartConfig:o,overwrite:n,children:i,splashPage:f,onBecomeAnAffiliate:s,bindReferralCodeState:x,onLearnAffiliate:m,showReferralPage:u}=e,{state:l}=orderlyHooks.useAccount(),{data:d,mutate:p,isLoading:c}=orderlyHooks.usePrivateQuery("/v1/referral/info",{revalidateOnFocus:true,errorRetryCount:3,...orderlyHooks.noCacheConfig}),{data:C,mutate:k}=orderlyHooks.usePrivateQuery("/v1/referral/auto_referral/progress",{revalidateOnFocus:true,errorRetryCount:2,formatter:O=>({code:O.auto_referral_code,requireVolume:O.required_volume,completedVolume:O.completed_volume})}),[ne,U]=react.useState(c);react.useEffect(()=>{U(true);},[c]);let{data:I,mutate:_}=orderlyHooks.useDaily({startDate:dateFns.subDays(new Date,1),endDate:dateFns.subDays(new Date,90)}),{data:A,mutate:B}=orderlyHooks.usePrivateQuery("/v1/volume/user/stats",{revalidateOnFocus:true}),ce=react.useMemo(()=>(d?.referrer_info?.referral_codes?.length||0)>0,[d?.referrer_info]),H=react.useMemo(()=>(d?.referee_info?.referer_code?.length||0)>0,[d?.referee_info]),K=react.useMemo(()=>{let O={};if(I&&I.length>0){let Be=dateFns.format(new Date,"yyyy-MM-dd"),_r=I.findIndex(pi=>pi.date===Be),Mr=0;_r!==-1&&(Mr=I[_r].perp_volume),O["1d_volume"]=Mr;}return A&&(O["7d_volume"]=A.perp_volume_last_7_days,O["30d_volume"]=A.perp_volume_last_30_days,O.all_volume=A.perp_volume_ltd),O},[I,A]);react.useEffect(()=>{(ce||H)&&U(false);},[ce,H]);let Ie=orderlyHooks.useMemoizedFn(()=>{B(),_(),p(),k();});react.useEffect(()=>{let Be=new URLSearchParams(window.location.search).get("ref");Be&&localStorage.setItem("referral_code",Be);},[]);let[Nr,di]=react.useState("affiliate"),{wrongNetwork:Ar,disabledConnect:Dr}=orderlyReactApp.useAppContext(),Fr=react.useRef(orderlyTypes.AccountStatusEnum.NotConnected),ft=react.useRef(null);react.useEffect(()=>(Fr.current!==l.status&&(Fr.current=l.status,ft.current=setTimeout(()=>{Ie();},1e3)),()=>{ft.current&&clearTimeout(ft.current);}),[Ie,l.status]);let xi=react.useMemo(()=>({generateCode:C,showHome:ne,referralInfo:d,isAffiliate:ce,isTrader:H,tab:Nr,becomeAnAffiliateUrl:t,learnAffiliateUrl:r,referralLinkUrl:a,userVolume:K,dailyVolume:I,chartConfig:o,overwrite:n,isLoading:c,wrongNetwork:Ar,disabledConnect:Dr,setShowHome:U,setTab:di,mutate:Ie,onBecomeAnAffiliate:s,bindReferralCodeState:x,onLearnAffiliate:m,showReferralPage:u,splashPage:f}),[t,o,I,d,Dr,C,ce,c,H,r,n,a,ne,Nr,K,Ar,s,x,m,u,f,Ie]);return jsxRuntime.jsx(Vr.Provider,{value:xi,children:i})},y=()=>react.useContext(Vr);var bt=()=>{let{t:e}=orderlyI18n.useTranslation(),[t,r]=react.useState("All"),a=[{label:e("common.all"),value:"All"},{label:e("common.select.1d"),value:"1D"},{label:e("common.select.7d"),value:"7D"},{label:e("common.select.30d"),value:"30D"}],{referralInfo:o}=y(),n=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_referrer_rebate;case "1D":return o.referrer_info["1d_referrer_rebate"];case "7D":return o.referrer_info["7d_referrer_rebate"];case "30D":return o.referrer_info["30d_referrer_rebate"]}},[o,t]),i=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_referee_volume;case "1D":return o.referrer_info["1d_referee_volume"];case "7D":return o.referrer_info["7d_referee_volume"];case "30D":return o.referrer_info["30d_referee_volume"]}},[o,t]),f=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_invites;case "1D":return o.referrer_info["1d_invites"];case "7D":return o.referrer_info["7d_invites"];case "30D":return o.referrer_info["30d_invites"]}},[o,t]),s=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_traded;case "1D":return o.referrer_info["1d_traded"];case "7D":return o.referrer_info["7d_traded"];case "30D":return o.referrer_info["30d_traded"]}},[o,t]);return {period:t,periodTypes:a,onPeriodChange:m=>{r(m);},commission:n,referralVol:i,referees:f,refereesTades:s}};var Ee=()=>{let e=bt();return jsxRuntime.jsx(gt,{...e})};var Or=e=>{let{text:t,visibleCount:r}=e,a=react.useRef(null),o=react.useRef(null),n=react.useRef(void 0);function i(m,u){let d=document.createElement("canvas").getContext("2d"),p=m;if(d&&p){let c=getComputedStyle(p).font;return c.length===0&&(c=[getComputedStyle(p).fontWeight,getComputedStyle(p).fontSize,getComputedStyle(p).fontFamily].join(" ")),d.font=c,d.letterSpacing=getComputedStyle(p).letterSpacing,d.measureText(u).width}}let[f,s]=react.useState(0);react.useEffect(()=>{let m=()=>{if(e.visibleCount===void 0&&a.current&&o.current){let u=a.current.clientWidth;if(u==n.current)return;n.current=u;let l=o.current,d=t,p=Math.ceil(i(l,"...")||0),c=u-p,C=0;for(;C<t.length&&!((i(l,Oi(t,C++))||c)<=c););s(d.length-C);}};return n.current=void 0,m(),window.addEventListener("resize",m),()=>{n.current=void 0,window.removeEventListener("resize",m);}},[t,o]);let x=react.useMemo(()=>{if(f+1>=t.length)return t;let m=r||f,u=t.slice(0,Math.ceil(m/2)),l=t.slice(t.length-Math.floor(m/2),t.length);return `${u}...${l}`},[t,r,f]);return jsxRuntime.jsxs("div",{ref:a,className:orderlyUi.cn("oui-relative oui-w-full oui-text-end",e.className),children:[jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-hidden oui-whitespace-nowrap oui-absolute oui-top-0 oui-bottom-0 oui-right-0 oui-left-0"),children:jsxRuntime.jsx("span",{ref:o,children:t})}),jsxRuntime.jsx("span",{children:x})]})},Oi=(e,t)=>{let r=Math.floor(e.length/2-(t>0?t/2:1)),a=e.slice(0,r),o=e.slice(r+t);return a+o};var vt=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-affiliate-referralLink",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9",children:[jsxRuntime.jsx(qi,{...e}),jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",className:"oui-flex oui-flex-col 3xl:oui-flex-row",gap:4,children:[jsxRuntime.jsx("div",{className:"oui-w-full 3xl:oui-w-1/3",children:jsxRuntime.jsx(Zi,{...e})}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",width:"100%",className:"3xl:oui-w-2/3 3xl:oui-gap-2",children:[jsxRuntime.jsx(Er,{title:t("affiliate.referralCode"),value:e.refCode,...e}),jsxRuntime.jsx(Er,{title:t("affiliate.referralLink"),value:e.refLink,...e})]})]})]})},qi=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.referralLink")})})},Zi=e=>{let{t}=orderlyI18n.useTranslation(),r=(a,o,n,i,f)=>{let s="oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl";return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",className:i,children:[jsxRuntime.jsx(orderlyUi.Flex,{direction:"row",gap:2,children:jsxRuntime.jsx(Qi,{title:a,tooltip:f})}),n?jsxRuntime.jsx(orderlyUi.Text.gradient,{color:"brand",className:s,children:o}):jsxRuntime.jsx(orderlyUi.Text,{className:s,children:o})]})};return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",children:[r(t("affiliate.referralLink.earn"),e.earn||"-",true,"oui-flex-1",jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx(orderlyUi.Text.gradient,{color:"brand",children:e.earn||"-"})," ",t("affiliate.referralLink.earn.tooltip",{brokerName:e.brokerName})]})),r(t("affiliate.referralLink.share"),e.share||"-",false,"oui-flex-1",jsxRuntime.jsx(orderlyI18n.Trans,{i18nKey:"affiliate.referralLink.share.tooltip",values:{value:e.share||"-",brokerName:e.brokerName},components:[jsxRuntime.jsx(orderlyUi.Text.gradient,{color:"brand"})]}))]})},Er=e=>{let{title:t,value:r="-"}=e;return jsxRuntime.jsxs(orderlyUi.Flex,{r:"xl",p:3,gap:4,direction:"row",width:"100%",className:"oui-bg-base-8",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-54 oui-flex-shrink oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:t}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"end",gap:2,className:"oui-flex-1 oui-text-xs md:oui-text-sm xl:oui-text-base",children:[jsxRuntime.jsx(Or,{text:r}),jsxRuntime.jsx("button",{className:"oui-cursor-pointer oui-text-sm oui-flex-shrink",onClick:()=>{navigator.clipboard.writeText(r),e.onCopy?.(r);},children:jsxRuntime.jsx(orderlyUi.CopyIcon,{size:12,color:"white",className:"oui-w-[13px] oui-h-[13px] md:oui-w-[14px] md:oui-h-[14px] xl:oui-w-4 xl:oui-h-4"})})]})]})},Qi=e=>jsxRuntime.jsx(orderlyUi.Tooltip,{content:e.tooltip,className:"oui-max-w-[200px]",children:jsxRuntime.jsx("div",{onClick:()=>{orderlyUi.modal.alert({title:e.title,message:jsxRuntime.jsx("div",{className:"oui-text-base-contrast/30 oui-space-y-3 oui-text-xs desktop:oui-text-xs",children:e.tooltip})});},children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:e.title}),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-w-full",lineStyle:"dotted",intensity:16})]})})});function ze(e,t,r){try{let a=new URL(e),o=new URLSearchParams(a.search);return o.set(t,r),a.search=o.toString(),a.toString()}catch{return e}}async function Rt(e){try{await navigator.clipboard.writeText(e),orderlyUi.toast.success(orderlyI18n.i18n.t("common.copy.copied"));}catch{orderlyUi.toast.success(orderlyI18n.i18n.t("common.copy.failed"));}}function Gr(e){if(e===void 0)return "";let t=dateFns.toDate(e),r=Qr(t);return dateFns.format(r,"yyyy-MM-dd HH:mm:ss 'UTC'")}function qr(e){if(e===void 0)return;let t=dateFns.toDate(e),r=Qr(t);return dateFns.format(r,"yyyy-MM-dd")}function Zr(e,t){return e&&t&&e.toISOString().substring(0,10)===t.toISOString().substring(0,10)}function Qr(e){return new Date(e.toUTCString())}var Tt=()=>{let{t:e}=orderlyI18n.useTranslation(),t=d=>{orderlyUi.toast.success(e("common.copy.copied"));},{referralInfo:r,referralLinkUrl:a,overwrite:o}=y(),[n,i]=orderlyHooks.useLocalStorage("orderly_referral_codes",[]),f=react.useMemo(()=>{if(!r?.referrer_info?.referral_codes)return [];let d=[...r?.referrer_info?.referral_codes],p=[];for(let c=0;c<n.length;c++){let C=n[c],k=d.findIndex(ne=>ne.code===C);k!==-1&&(p.push({...d[k]}),d.splice(k,1));}return [...p,...d]},[r?.referrer_info?.referral_codes,n]),s=react.useMemo(()=>{if(f.length!==0)return f[0]},[f]),x=react.useMemo(()=>s?.code,[s]),m=react.useMemo(()=>s?ze(a,"ref",s.code):"",[s]),u=react.useMemo(()=>`${new orderlyUtils.Decimal(s?.referrer_rebate_rate||"0").mul(100).toDecimalPlaces(0,orderlyUtils.Decimal.ROUND_DOWN).toString()}%`,[s?.referrer_rebate_rate]),l=react.useMemo(()=>`${new orderlyUtils.Decimal(s?.referee_rebate_rate||"0").mul(100).toDecimalPlaces(0,orderlyUtils.Decimal.ROUND_DOWN).toString()}%`,[s?.referee_rebate_rate]);return {onCopy:t,refLink:m,refCode:x,share:l,earn:u,brokerName:o?.brokerName??o?.shortBrokerName}};var He=()=>{let e=Tt();return jsxRuntime.jsx(vt,{...e})};var Nt=e=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-affiliate-titleStatistic",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9",children:[jsxRuntime.jsx(ia,{...e}),jsxRuntime.jsx(orderlyUi.Flex,{className:"oui-h-[170px] 2xl:oui-h-[196px] oui-w-full oui-flex oui-flex-row oui-items-stretch",children:jsxRuntime.jsx(orderlyChart.VolBarChart,{data:e.dataSource||orderlyTypes.EMPTY_LIST,colors:{fill:"rgba(0, 180, 158, 1)"},className:"oui-w-full oui-flex-1",tooltip:{rm:orderlyUtils.Decimal.ROUND_DOWN,dp:e.volType==="Commission"?6:2}})})]}),ia=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.statistics")}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:2,className:"oui-min-w-14",children:[jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes}),jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.volType,onValueChange:e.onVolTypeChange,options:e.volTypes})]})]})};function Ge(e,t){let r=Date(),a=new Array(e).fill(0).map((n,i)=>({date:dateFns.format(dateFns.subDays(r,i+1),"yyyy-MM-dd"),volume:0,opacity:0})).reverse(),o=t?.reduce((n,i)=>(n[i.date]=i,n),{});for(let n=0;n<a.length;n++){let i=a[n],f=o?.[i.date];f&&(a[n]={...f,opacity:f.volume>0?1:0});}return a}var At=()=>{let{t:e}=orderlyI18n.useTranslation(),[t,r]=react.useState("7"),a=[{label:e("common.select.7d"),value:"7"},{label:e("common.select.30d"),value:"30"},{label:e("common.select.90d"),value:"90"}],o=l=>{r(l);},[n,i]=react.useState("Commission"),f=[{label:e("affiliate.commission"),value:"Commission"},{label:e("affiliate.referralVol"),value:"ref"}],s=l=>{i(l);},x=react.useMemo(()=>t==="7"?{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)}:t==="30"?{startDate:dateFns.subDays(new Date,30),endDate:dateFns.subDays(new Date,1)}:t==="90"?{startDate:dateFns.subDays(new Date,90),endDate:dateFns.subDays(new Date,1)}:{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)},[t]),[m]=orderlyHooks.useReferralRebateSummary({startDate:dateFns.format(x.startDate,"yyyy-MM-dd"),endDate:dateFns.format(x.endDate,"yyyy-MM-dd"),size:Number(t)}),u=react.useMemo(()=>(m?.map(l=>({date:l.date,volume:n==="Commission"?l.referral_rebate:l.volume}))||[]).reverse(),[m,n]);return {period:t,periodTypes:a,onPeriodChange:o,volType:n,volTypes:f,onVolTypeChange:s,dataSource:Ge(Number(t),u)}};var qe=()=>{let e=At();return jsxRuntime.jsx(Nt,{...e})};var Ae=e=>{let{className:t,...r}=e;return jsxRuntime.jsx("svg",{width:"12",height:"13",viewBox:"0 0 12 13",xmlns:"http://www.w3.org/2000/svg",fill:"white",fillOpacity:"0.36",className:t,...r,children:jsxRuntime.jsx("path",{d:"M8.49773 1.47656C8.36523 1.47656 8.23223 1.52357 8.13823 1.61707C7.86023 1.89507 6.85973 2.89558 6.63773 3.11808L2.13523 7.62059L1.63473 8.12059C1.56523 8.19059 1.52923 8.28958 1.50973 8.38658L1.00973 10.8881C0.939727 11.2381 1.23773 11.5361 1.58773 11.4666C1.90073 11.4036 3.77673 11.0286 4.08923 10.9661C4.18623 10.9466 4.28523 10.9106 4.35523 10.8411L4.85523 10.3406L9.35773 5.83808C9.58023 5.61608 10.5807 4.61506 10.8587 4.33756C10.9522 4.24356 10.9992 4.11056 10.9992 3.97806C10.9992 3.15956 10.7907 2.57456 10.3582 2.13306C9.92173 1.68756 9.33873 1.47656 8.49773 1.47656ZM8.69473 2.48606C9.14623 2.51256 9.43873 2.61608 9.63923 2.82108C9.84423 3.03008 9.97373 3.32008 10.0017 3.76258C9.72773 4.03608 9.32673 4.43106 8.99823 4.75956C8.60173 4.36306 8.11273 3.87407 7.71623 3.47757C8.04523 3.14907 8.42123 2.75956 8.69473 2.48606ZM6.99723 4.19657L8.27923 5.47858L4.49573 9.26207L3.21373 7.98009L6.99723 4.19657ZM2.49473 8.69908L3.77673 9.98107L3.72973 10.0281C3.39973 10.0941 2.73323 10.2336 2.11923 10.3566L2.44773 8.74608L2.49473 8.69908Z"})})};var to=e=>jsxRuntime.jsx("button",{children:jsxRuntime.jsx(Ae,{className:" oui-mt-px oui-cursor-pointer oui-fill-base-contrast-36 hover:oui-fill-base-contrast-80",fillOpacity:1,fill:"currentColor",onClick:e.onClick})});var Dt=e=>jsxRuntime.jsx("button",{onClick:t=>{e?.onClick?.(!e.pinned);},children:e.pinned===false?jsxRuntime.jsx(ma,{size:e.size,fillOpacity:1,className:"orderly-fill-primary-darken hover:orderly-fill-primary-darken/80"}):jsxRuntime.jsx(ua,{size:e.size,fillOpacity:1,className:"orderly-fill-base-contrast-36 hover:orderly-fill-base-contrast"})}),ua=e=>{let{size:t=12}=e;return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"#608CFF",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208"})})},ma=e=>{let{size:t=12}=e;return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"#fff",fillOpacity:".36",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208m.258 1.37c.708.131 1.421.6 1.93 1.108.507.507.94 1.13 1.119 1.944-.636.61-1.026.659-1.662.324a.67.67 0 0 0-.779.116c-1.214 1.213-1.533 2.314-1.533 3.8 0 1.293-.076 1.774-.48 2.207-.113.123-.27.104-.374 0L3.799 7.486a.24.24 0 0 1-.017-.34c.239-.29.769-.514 2.226-.514 1.742.001 2.668-.447 3.812-1.52a.67.67 0 0 0 .125-.77c-.343-.685-.29-1.046.321-1.67"})})};var _t=e=>{let t=orderlyHooks.useMediaQuery("(max-width: 767px)");return jsxRuntime.jsxs(orderlyUi.Flex,{r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-h-full oui-bg-base-9 oui-p-6 oui-tabular-nums",children:[jsxRuntime.jsx(ba,{...e}),jsxRuntime.jsxs("div",{className:"oui-flex oui-w-full oui-flex-col 2xl:oui-h-full",children:[jsxRuntime.jsx(orderlyUi.Divider,{}),t?jsxRuntime.jsx(Ca,{...e}):jsxRuntime.jsx(ya,{...e})]})]})},ba=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.referralCodes")}),jsxRuntime.jsxs("div",{className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-54",children:`${t("affiliate.referralCodes.remaining")}: `}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-primary-light",children:e.codes?.length||"--"})]})]})},Ca=e=>jsxRuntime.jsx(orderlyUi.ListView,{dataSource:e.codes,className:"oui-max-h-[240px] oui-w-full",renderItem:(t,r)=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",children:[jsxRuntime.jsx(wa,{data:t,editRate:e.editRate,copyLink:e.copyLink,copyCode:e.copyCode,setPinCode:e.setPinCode,editCode:e.editCode},r),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-mt-3 oui-w-full"})]})}),De=e=>{let{title:t,copyable:r,value:a,align:o,className:n,editRate:i,onCopy:f}=e;return jsxRuntime.jsx(orderlyUi.Statistic,{id:"oui-affiliate-affiliate-referralCodes",className:orderlyUi.cn("oui-flex-1",n),label:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-2xs oui-text-base-contrast-36",children:t}),align:o,children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,children:[jsxRuntime.jsx(orderlyUi.Text.formatted,{copyable:r,onCopy:()=>{f?.();},className:"oui-mt-[6px] oui-text-sm oui-text-base-contrast-80",children:a}),i&&jsxRuntime.jsx(Ae,{className:"oui-mt-px oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",fillOpacity:1,fill:"currentColor",onClick:()=>i()})]})})},wa=e=>{let{data:t,setPinCode:r,copyLink:a,editRate:o,editCode:n}=e,{t:i}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{gap:3,direction:"column",className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",itemAlign:"stretch",width:"100%",children:[jsxRuntime.jsx(De,{title:i("affiliate.referralCode"),value:t.code,copyable:true,onCopy:()=>{e.copyCode?.(t.code);},editRate:()=>{n(t);}}),jsxRuntime.jsx(De,{title:i("affiliate.referralCodes.column.you&Referee"),value:ao(t),align:"end",editRate:()=>{o(t);}}),jsxRuntime.jsx(De,{title:i("affiliate.referralCodes.column.referees&Traders"),value:Ce(t),align:"end",className:"oui-hidden md:oui-flex"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",itemAlign:"stretch",width:"100%",className:"md:oui-hidden",children:[jsxRuntime.jsx(De,{title:i("affiliate.referees"),value:Ce(t).split("/")?.[0],align:"start"}),jsxRuntime.jsx(De,{title:i("affiliate.referralCodes.column.traders"),value:Ce(t).split("/")?.[1],align:"end"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",itemAlign:"stretch",width:"100%",children:[jsxRuntime.jsx(Dt,{pinned:t.isPined||false,onClick:f=>{r(t.code,!f);}}),jsxRuntime.jsx(orderlyUi.Button,{variant:"outlined",size:"xs",className:"oui-px-[20px]",onClick:f=>{a(t.code);},children:i("affiliate.referralCodes.copyLink")})]})]},t.code)},ya=e=>{let{t}=orderlyI18n.useTranslation(),r=orderlyHooks.useMediaQuery("(min-width: 1024px)"),a=react.useMemo(()=>{let o=[{title:t("affiliate.referralCode"),dataIndex:"code",width:r?115:120,className:"!oui-px-0",render:(n,i)=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",itemAlign:"center",gap:1,children:[jsxRuntime.jsx(Dt,{size:12,pinned:i.isPined||false,onClick:f=>{e.setPinCode(i.code,!f);}}),jsxRuntime.jsx(orderlyUi.Text.formatted,{suffix:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i.isAutoGenerated&&i.total_invites<1&&jsxRuntime.jsx(to,{onClick:()=>e.editCode?.(i)}),jsxRuntime.jsx(orderlyUi.CopyIcon,{className:"oui-cursor-pointer",size:12,color:"white",onClick:()=>e.copyCode?.(i.code)})]}),copyable:true,onCopy:()=>{e.copyCode?.(i.code);},children:n})]})},{title:t("affiliate.referralCodes.column.you&Referee"),dataIndex:"dffd",width:120,className:"oui-pr-0",render:(n,i)=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",itemAlign:"center",gap:1,children:[ao(i),jsxRuntime.jsx(Ae,{className:"oui-mt-[6px] oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",fillOpacity:1,fill:"currentColor",onClick:f=>e.editRate?.(i)})]})}];return r?(o.push({title:t("affiliate.referees"),dataIndex:"referee_rebate_rate",width:65,className:"oui-pr-0",render:(n,i)=>Ce(i).split("/")[0]}),o.push({title:t("affiliate.referralCodes.column.traders"),dataIndex:"referrer_rebate_rate",width:65,className:"oui-pr-0",render:(n,i)=>Ce(i).split("/")[1]})):o.push({title:t("affiliate.referralCodes.column.referees&Traders"),dataIndex:"total_invites/total_traded",width:120,fixed:"left",render:(n,i)=>Ce(i)}),o.push({dataIndex:"link",align:"right",width:74,className:"!oui-px-0",render:(n,i)=>jsxRuntime.jsx(orderlyUi.Button,{variant:"outlined",size:"sm",className:"oui-px-5",onClick:f=>{e?.copyLink?.(i.code);},children:t("affiliate.referralCodes.copyLink")})}),o},[r,t]);return jsxRuntime.jsx(orderlyUi.DataTable,{bordered:true,columns:a,dataSource:e.codes,classNames:{header:"oui-px-0",root:"2xl:oui-flex-1 2xl:oui-max-h-[230px] 3xl:oui-max-h-[300px]"},onRow:o=>({className:"oui-h-[45px]"})})},ao=e=>{let t=new orderlyUtils.Decimal(e.referee_rebate_rate).mul(100).toFixed(1,orderlyUtils.Decimal.ROUND_DOWN).toString();return `${new orderlyUtils.Decimal(e.referrer_rebate_rate).mul(100).toFixed(1,orderlyUtils.Decimal.ROUND_DOWN).toString()}% / ${t}%`},Ce=e=>`${e.total_invites} / ${e.total_traded}`;var xo=orderlyUi.modal.create(e=>{let{t}=orderlyI18n.useTranslation(),{visible:r,onOpenChange:a}=orderlyUi.useModal(),[o,n]=react.useState(""),[i,f]=react.useState({length:false,format:false}),[s,{error:x,isMutating:m}]=orderlyHooks.useMutation("/v1/referral/edit_referral_code","POST");return react.useEffect(()=>{n(e.code.code);},[e.code]),react.useEffect(()=>{let u=o.toUpperCase(),l={length:false,format:false};(u.length<4||u.length>10)&&(l.length=true),/^[A-Z0-9]+$/.test(u)||(l.format=true),f(l);},[o]),jsxRuntime.jsxs(orderlyUi.SimpleDialog,{classNames:{content:"oui-max-w-[360px]"},title:jsxRuntime.jsx("div",{children:t("affiliate.referralCode.editCodeModal.title")}),open:r,onOpenChange:a,actions:{primary:{loading:m,disabled:i.length||i.format,label:t("common.confirm"),onClick:async()=>{try{let u=await s({current_referral_code:e.code.code,new_referral_code:o.toUpperCase()});if(u.success){orderlyUi.toast.success(t("affiliate.referralCode.editCodeModal.success")),e.successCallback(),a(!1);return}orderlyUi.toast.error(u.message);}catch{}}}},children:[jsxRuntime.jsx("div",{className:"oui-mb-6 oui-text-xs oui-text-base-contrast-54",children:t("affiliate.referralCode.editCodeModal.description")}),jsxRuntime.jsx(orderlyUi.TextField,{placeholder:"",fullWidth:true,label:t("affiliate.referralCode.editCodeModal.label"),onClean:()=>{n("");},value:o,onChange:u=>{let l=u.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"");n(l);},formatters:[orderlyUi.inputFormatter.createRegexInputFormatter(u=>String(u).replace(/[a-z]/g,l=>l.toUpperCase())),orderlyUi.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)],classNames:{label:"oui-text-base-contrast-54 oui-text-xs",input:"placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"},maxLength:10,minLength:4,autoComplete:"off",helpText:""}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",justify:"center",itemAlign:"start",gap:1,className:"oui-mt-3",children:[jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs",i.length?"oui-text-danger":"oui-text-success"),children:t("affiliate.referralCode.editCodeModal.helpText.length")}),jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs","oui-text-success"),children:t("affiliate.referralCode.editCodeModal.helpText.format")})]})]})});var wo=orderlyUi.modal.create(e=>{let{code:t,mutate:r}=e,{visible:a,hide:o,resolve:n,reject:i,onOpenChange:f}=orderlyUi.useModal(),s=new orderlyUtils.Decimal(t.max_rebate_rate).mul(100),[x,m]=react.useState(`${new orderlyUtils.Decimal(t.referee_rebate_rate).mul(100)}`),[u,l]=react.useState(`${new orderlyUtils.Decimal(t.referrer_rebate_rate).mul(100)}`),[d,p]=react.useState(false),c=react.useRef(null),{t:C}=orderlyI18n.useTranslation();react.useEffect(()=>{c?.current&&(c.current.focus(),c.current.setSelectionRange(c.current.value.length,c.current.value.length));},[c]),react.useEffect(()=>{m(`${new orderlyUtils.Decimal(t.referee_rebate_rate).mul(100)}`),l(`${new orderlyUtils.Decimal(t.referrer_rebate_rate).mul(100)}`);},[t]);let[k,{error:ne,isMutating:U}]=orderlyHooks.useMutation("/v1/referral/edit_split","POST"),I=async()=>{try{let _=Number.parseFloat(x),A=Number.parseFloat(u);await k({referral_code:t.code,referee_rebate_rate:_/100,referrer_rebate_rate:A/100}),orderlyUi.toast.success(C("affiliate.referralRate.editRateModal.success")),r(),o();}catch(_){orderlyUi.toast.error(_?.message||_||"");}};return jsxRuntime.jsx(orderlyUi.Dialog,{open:a,onOpenChange:f,children:jsxRuntime.jsxs(orderlyUi.DialogContent,{className:"oui-px-6 oui-max-w-[320px] oui-bg-base-8 oui-shadow-[0px_12px_20px_0px_rgba(0,0,0,0.25)]",closable:true,children:[jsxRuntime.jsxs(orderlyUi.DialogTitle,{children:[jsxRuntime.jsx("div",{className:"oui-my-3",children:C("affiliate.referralRate.editRateModal.title")}),jsxRuntime.jsx(orderlyUi.Divider,{})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-h-full oui-flex oui-flex-col oui-justify-end",children:[jsxRuntime.jsx("div",{className:"oui-text-xs oui-text-base-contrast-54",children:C("affiliate.referralRate.editRateModal.description")}),jsxRuntime.jsxs("div",{className:"oui-text-xs oui-text-base-contrast-80 oui-mt-2 oui-flex",children:[C("affiliate.referralRate.editRateModal.label"),jsxRuntime.jsx("div",{className:"oui-text-warning-darken oui-pl-1",children:`${new orderlyUtils.Decimal(t.max_rebate_rate).mul(100).toFixed(0,orderlyUtils.Decimal.ROUND_DOWN)}%`})]}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-mt-6 oui-text-base-contrast-80",children:C("affiliate.referralRate.editRateModal.label.you")}),jsxRuntime.jsx(orderlyUi.Input,{ref:c,containerClassName:"oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",placeholder:"Enter code",type:"text",inputMode:"decimal",autoComplete:"off",value:u,onChange:_=>{let A=orderlyHooks.cleanStringStyle(_.target.value),B=Number.parseFloat(A);l(A),Number.isNaN(B)?(m(""),l("")):(m(`${Co(new orderlyUtils.Decimal(0),s.sub(B))}`),p(s.sub(B)<new orderlyUtils.Decimal(0)));},suffix:jsxRuntime.jsx("div",{className:"oui-px-3 oui-text-base-contrast-54 oui-text-base",children:"%"}),color:d?"danger":void 0}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-mt-6 oui-text-base-contrast-80",children:C("affiliate.referralRate.editRateModal.label.referee")}),jsxRuntime.jsx(orderlyUi.Input,{containerClassName:"oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",placeholder:"Enter code",type:"text",inputMode:"decimal",autoComplete:"off",autoFocus:false,value:x,onChange:_=>{let A=orderlyHooks.cleanStringStyle(_.target.value),B=Number.parseFloat(A);m(A),Number.isNaN(B)?(m(""),l("")):(l(`${Co(new orderlyUtils.Decimal(0),s.sub(B))}`),p(s.sub(B)<new orderlyUtils.Decimal(0)));},suffix:jsxRuntime.jsx("div",{className:"oui-px-3 oui-text-base-contrast-54 oui-text-base",children:"%"}),color:d?"danger":void 0}),d&&jsxRuntime.jsx("div",{className:"oui-text-danger oui-text-xs oui-mt-8 oui-text-center oui-px-4",children:C("affiliate.referralRate.editRateModal.helpText.max")}),jsxRuntime.jsx(orderlyUi.Flex,{width:"100%",justify:"center",children:jsxRuntime.jsx(orderlyUi.Button,{id:"referral_bind_referral_code_btn",disabled:x.length===0||u.length===0||d,loading:U,className:orderlyUi.cn("oui-mt-8 oui-mb-4 oui-w-[154px]",d&&"oui-mt-3"),onClick:_=>{_.stopPropagation(),I();},children:C("common.confirm")})})]})]})})});function Co(e,t){return e>t?e:t}var Pt=()=>{let{referralInfo:e,referralLinkUrl:t,mutate:r,generateCode:a}=y(),o=l=>{Rt(ze(t,"ref",l));},n=l=>{Rt(l);},i=l=>{orderlyUi.modal.show(wo,{code:{...l},mutate:r});},f=l=>{orderlyUi.modal.show(xo,{code:{...l},successCallback:()=>{r();}});},[s,x]=orderlyHooks.useLocalStorage("orderly_referral_codes",[]),m=(l,d)=>{if(d){let p=s.findIndex(c=>c===l);p!==-1&&s.splice(p,1);}else s.splice(0,0,l);s.length>6&&s.splice(s.length-1,1),x([...s]);},u=react.useMemo(()=>{if(!e?.referrer_info?.referral_codes)return;let l=e?.referrer_info?.referral_codes?.map(p=>(a&&a.code===p.code&&(p.isAutoGenerated=true),p)),d=[];for(let p=0;p<s.length;p++){let c=s[p],C=l.findIndex(k=>k.code===c);C!==-1&&(d.push({...l[C],isPined:true}),l.splice(C,1));}return [...d,...l]},[e?.referrer_info?.referral_codes,s,a]);return {copyCode:n,copyLink:o,editRate:i,editCode:f,setPinCode:m,codes:u}};var Ye=()=>{let e=Pt();return jsxRuntime.jsx(_t,{...e})};var kt=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.Flex,{id:"oui-affiliate-affiliate-commissionAndReferees",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9 oui-tabular-nums",children:jsxRuntime.jsxs(orderlyUi.Tabs,{defaultValue:"account",className:"oui-w-full",variant:"contained",children:[jsxRuntime.jsx(orderlyUi.TabPanel,{value:"account",title:t("affiliate.commission"),children:jsxRuntime.jsx(Xa,{...e})}),jsxRuntime.jsx(orderlyUi.TabPanel,{value:"password",title:t("affiliate.myReferees"),children:jsxRuntime.jsx(Ka,{...e})})]})})},G=e=>{let{title:t,value:r,align:a,className:o,rule:n,formatString:i,prefix:f}=e;return jsxRuntime.jsx(orderlyUi.Statistic,{className:orderlyUi.cn("oui-flex-1",o),label:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-36 oui-text-2xs",children:t}),align:a,children:jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:n||"",formatString:i,prefix:f,className:"oui-text-base-contrast-80 oui-text-sm oui-mt-[6px]",children:r})})},Xa=e=>{let{t}=orderlyI18n.useTranslation(),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),a=react.useMemo(()=>[{title:`${t("affiliate.commission")} (USDC)`,dataIndex:"referral_rebate",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(i,{fix:6,fallback:"0",padEnd:true,prefix:"$"})}),width:216},{title:`${t("affiliate.referralVol")} (USDC)`,dataIndex:"volume",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(i,{fix:2,fallback:"0",padEnd:true,prefix:"$"})}),width:216},{title:t("affiliate.commission.column.activeUsers"),dataIndex:"daily_traded_referral",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:i}),width:216},{title:t("common.date"),dataIndex:"date",render:i=>qr(i),width:216}],[t]),o=react.useMemo(()=>r?jsxRuntime.jsx(orderlyUi.ListView,{className:"oui-max-h-[200px] oui-w-full",dataSource:e.commission.data,loadMore:e.commission.loadMore,isLoading:e.commission.isLoading,renderItem:n=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",children:[jsxRuntime.jsx(G,{title:t("affiliate.commission"),value:orderlyUtils.commifyOptional(n.referral_rebate,{fix:6,fallback:"0",padEnd:true}),prefix:"$"}),jsxRuntime.jsx(G,{title:t("affiliate.referralVol"),value:orderlyUtils.commifyOptional(n.volume,{fix:2,fallback:"0",padEnd:true}),prefix:"$"}),jsxRuntime.jsx(G,{title:t("affiliate.commission.column.activeUsers"),value:n.daily_traded_referral}),jsxRuntime.jsx(G,{title:t("common.date"),value:n.date,rule:"date",formatString:"yyyy-MM-dd",align:"end"})]}),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-mt-3 oui-w-full"})]})}):jsxRuntime.jsx(orderlyUiConnector.AuthGuardDataTable,{bordered:true,columns:a,loading:e.commission.isLoading,ignoreLoadingCheck:true,dataSource:e.commission.data,pagination:e.commission.pagination,onRow:n=>({className:"oui-h-[41px]"})}),[r,e.commission]);return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",width:"100%",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(Ja,{value:e.commission.dateRange,setValue:e.commission.setDateRange}),o]})},Ka=e=>{let{t}=orderlyI18n.useTranslation(),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),a=react.useMemo(()=>[{title:t("affiliate.referees.column.refereeAddress"),dataIndex:"user_address",render:i=>jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:"address",children:i}),className:"oui-w-1/5"},{title:t("affiliate.referralCode"),dataIndex:"referral_code",className:"oui-w-1/5"},{title:`${t("affiliate.referees.column.totalCommission")} (USDC)`,dataIndex:"referral_rebate",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(i,{fix:6,prefix:"$",padEnd:true})}),className:"oui-w-1/5"},{title:`${t("affiliate.referees.column.totalVol")} (USDC)`,dataIndex:"volume",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(i,{fix:2,prefix:"$",padEnd:true})}),className:"oui-w-1/5"},{title:t("affiliate.referees.column.invitationTime"),dataIndex:"code_binding_time",render:i=>jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:"date",formatString:"yyyy-MM-dd",children:i}),className:"oui-w-1/5"}],[t]),o=react.useMemo(()=>r?jsxRuntime.jsx(orderlyUi.ListView,{className:"oui-w-full oui-max-h-[200px]",dataSource:e.referees.data,loadMore:e.referees.loadMore,isLoading:e.referees.isLoading,renderItem:(n,i)=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",gap:3,className:"oui-border-b-2 oui-border-line-6 oui-pb-3",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",children:[jsxRuntime.jsx(G,{title:t("affiliate.referralCode"),value:n.referral_code}),jsxRuntime.jsx(G,{title:`${t("affiliate.referees.column.totalCommission")} (USDC)`,value:orderlyUtils.commifyOptional(n.referral_rebate,{fix:6,prefix:"$",padEnd:true}),className:"oui-min-w-[102px]"}),jsxRuntime.jsx(G,{title:t("affiliate.referees.column.totalVol"),value:orderlyUtils.commifyOptional(n.volume,{fix:2,prefix:"$",padEnd:true}),align:"end"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",pt:3,gap:3,width:"100%",children:[jsxRuntime.jsx(G,{title:t("affiliate.referees.column.refereeAddress"),value:n.user_address,rule:"address"}),jsxRuntime.jsx(G,{title:t("affiliate.referees.column.invitationTime"),value:n.code_binding_time,align:"end",rule:"date",formatString:"yyyy-MM-dd"})]})]},i)}):jsxRuntime.jsx(orderlyUiConnector.AuthGuardDataTable,{bordered:true,loading:e.referees.isLoading,ignoreLoadingCheck:true,columns:a,dataSource:e.referees.data,pagination:e.referees.pagination,onRow:n=>({className:"oui-h-[41px]"})}),[r,e.referees]);return jsxRuntime.jsx(orderlyUi.Flex,{direction:"column",width:"100%",justify:"start",itemAlign:"start",children:o})},Ja=e=>jsxRuntime.jsx(orderlyUi.Flex,{width:"100%",height:49,className:"oui-border-b oui-border-line-6",children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(orderlyUi.DatePicker.range,{size:"xs",value:e.value,onChange:t=>{e.setValue(t);},max:90,disabled:{after:new Date}})})});var It=()=>{let e=tn(),t=rn();return {commission:e,referees:t}},tn=()=>{let[e,t]=react.useState({from:dateFns.subDays(new Date,90),to:dateFns.subDays(new Date,1)}),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),{page:a,pageSize:o,setPage:n,parsePagination:i}=orderlyUi.usePagination(),[f,{refresh:s,isLoading:x,loadMore:m,meta:u}]=orderlyHooks.useReferralRebateSummary({startDate:e?.from!==void 0?dateFns.format(e.from,"yyyy-MM-dd"):void 0,endDate:e?.to!==void 0?dateFns.format(e.to,"yyyy-MM-dd"):void 0,size:o,page:r?void 0:a});react.useEffect(()=>{s();},[e]);let l=react.useMemo(()=>i(u),[i,u]);return react.useEffect(()=>{n(1);},[e]),{data:f||void 0,pagination:l,dateRange:e,setDateRange:t,isLoading:x,loadMore:m}},rn=()=>{let[e,t]=react.useState({from:dateFns.subDays(new Date,90),to:dateFns.subDays(new Date,1)}),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),{page:a,pageSize:o,setPage:n,parsePagination:i}=orderlyUi.usePagination(),[f,{refresh:s,isLoading:x,loadMore:m,meta:u}]=orderlyHooks.useRefereeInfo({startDate:e?.from!==void 0?dateFns.format(e.from,"yyyy-MM-dd"):void 0,endDate:e?.to!==void 0?dateFns.format(e.to,"yyyy-MM-dd"):void 0,size:o,page:r?void 0:a,sort:"descending_code_binding_time"});react.useEffect(()=>{s();},[e]);let l=react.useMemo(()=>i(u),[i,u]);return react.useEffect(()=>{n(1);},[e]),{data:f||void 0,pagination:l,dateRange:e,setDateRange:t,isLoading:x,loadMore:m}};var Bt=()=>{let e=It();return jsxRuntime.jsx(kt,{...e})};var _e=()=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-affiliate-page",className:orderlyUi.cn("oui-h-lvw","oui-font-semibold"),direction:"column",gap:4,children:[jsxRuntime.jsx(ln,{}),jsxRuntime.jsx(Bt,{})]}),ln=()=>orderlyHooks.useMediaQuery("(max-width: 1279px)")?jsxRuntime.jsx(sn,{}):jsxRuntime.jsx(fn,{}),sn=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-col xl:oui-flex-row oui-gap-4 oui-w-full",children:[jsxRuntime.jsx(Ee,{}),jsxRuntime.jsx(He,{})]}),jsxRuntime.jsx(qe,{}),jsxRuntime.jsx(Ye,{})]}),fn=()=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",itemAlign:"stretch",gap:4,children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",gap:4,className:"oui-flex-1 oui-w-1/2",children:[jsxRuntime.jsx("div",{className:"oui-flex-1 oui-h-full oui-w-full",children:jsxRuntime.jsx(Ee,{})}),jsxRuntime.jsx(qe,{})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",gap:4,className:"oui-w-1/2",children:[jsxRuntime.jsx(He,{}),jsxRuntime.jsx("div",{className:"oui-flex-1",children:jsxRuntime.jsx(Ye,{})})]})]});var Vt=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-trader-summary",r:"2xl",p:6,width:"100%",height:"100%",gap:4,direction:"column",className:"oui-bg-base-9 xl:oui-flex-1",children:[jsxRuntime.jsx(dn,{...e}),jsxRuntime.jsx(Mo,{className:"md:oui-hidden",...e}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",gap:3,width:"100%",className:"md:oui-mt-3",children:[jsxRuntime.jsx(xn,{...e}),jsxRuntime.jsx(pn,{...e})]}),jsxRuntime.jsx(gn,{title:`${t("affiliate.trader.tradingVol")} (USDC)`,...e})]})},dn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",gap:3,children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:3,className:"oui-flex-1",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.trader.yourReferrer")}),jsxRuntime.jsx(orderlyUi.Button,{color:"secondary",size:"sm",className:"oui-text-primary-light oui-text-2xs md:oui-text-xs 2xl:oui-text-sm oui-bg-base-6",children:e.code})]}),jsxRuntime.jsx(Mo,{className:"oui-hidden md:oui-flex md:oui-flex-shrink md:oui-w-fit",...e})]})},Mo=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",gap:2,className:e.className,children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-sm md:oui-text-base 2xl:oui-text-lg",children:`${t("affiliate.trader.rebate")}:`}),jsxRuntime.jsx(orderlyUi.Text.gradient,{color:"brand",className:"oui-text-lg md:oui-text-xl 2xl:oui-text-2xl",children:e.rebateText})]})},xn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",justify:"between",gap:3,children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm",children:t("affiliate.summary")}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes})})]})},pn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{gradient:"success",angle:180,r:"xl",py:4,px:6,width:"100%",direction:"column",gap:3,children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-base 2xl:oui-text-lg",children:`${t("affiliate.trader.rebates")} (USDC)`}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:3,className:"oui-text-xl md:oui-text-2xl xl:oui-text-3xl",children:[jsxRuntime.jsx(J,{className:"md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] "}),jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(e.rebates,{fix:2,fallback:"0"})})]})]})},gn=e=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:e.title}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-xs md:oui-text-sm xl:oui-text-base",children:orderlyUtils.commifyOptional(e.vol,{fix:2,fallback:"0"})})]});var Ot=()=>{let{t:e}=orderlyI18n.useTranslation(),[t,r]=react.useState("All"),a=[{label:e("common.all"),value:"All"},{label:e("common.select.1d"),value:"1D"},{label:e("common.select.7d"),value:"7D"},{label:e("common.select.30d"),value:"30D"}],{referralInfo:o,userVolume:n}=y(),i=react.useMemo(()=>{if(!o)return 0;switch(t){case "All":return o.referee_info.total_referee_rebate;case "1D":return o.referee_info["1d_referee_rebate"];case "7D":return o.referee_info["7d_referee_rebate"];case "30D":return o.referee_info["30d_referee_rebate"]}},[o,t]),f=react.useMemo(()=>{if(n)switch(t){case "All":return n.all_volume;case "1D":return n["1d_volume"];case "7D":return n["7d_volume"];case "30D":return n["30d_volume"]}},[n,t]),s=o?.referee_info?.referer_code,x=o?.referee_info?.referee_rebate_rate,m=react.useMemo(()=>x?new orderlyUtils.Decimal(x).mul(100).toDecimalPlaces(2,orderlyUtils.Decimal.ROUND_DOWN).toString()+"%":"-",[x]);return {period:t,periodTypes:a,onPeriodChange:l=>{r(l);},rebates:i,vol:f,rebateText:m,code:s}};var Et=()=>{let e=Ot();return jsxRuntime.jsx(Vt,{...e})};var Ut=e=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-trader-titleStatistic",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9 xl:oui-flex-1",children:[jsxRuntime.jsx(Tn,{...e}),jsxRuntime.jsx(orderlyUi.Flex,{className:"oui-min-h-[170px] oui-h-full oui-w-full oui-flex oui-flex-row oui-items-stretch",children:jsxRuntime.jsx(orderlyChart.VolBarChart,{data:e.dataSource,colors:{fill:"rgba(0, 180, 158, 1)"},className:"oui-w-full oui-flex-1",tooltip:{rm:orderlyUtils.Decimal.ROUND_DOWN,dp:e.volType==="volume"?2:6}})})]}),Tn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.statistics")}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:2,className:"oui-min-w-14",children:[jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes}),jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.volType,onValueChange:e.onVolTypeChange,options:e.volTypes})]})]})};var Ht=()=>{let{t:e}=orderlyI18n.useTranslation(),[t,r]=react.useState("7"),a=[{label:e("common.select.7d"),value:"7"},{label:e("common.select.30d"),value:"30"},{label:e("common.select.90d"),value:"90"}],o=c=>{r(c);},[n,i]=react.useState("rebate"),f=[{label:e("affiliate.trader.rebate"),value:"rebate"},{label:e("common.volume"),value:"volume"}],s=c=>{i(c);},x=react.useMemo(()=>t==="7"?{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)}:t==="30"?{startDate:dateFns.subDays(new Date,30),endDate:dateFns.subDays(new Date,1)}:t==="90"?{startDate:dateFns.subDays(new Date,90),endDate:dateFns.subDays(new Date,1)}:{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)},[t]),{data:m,mutate:u}=orderlyHooks.useRefereeRebateSummary(x),{dailyVolume:l,chartConfig:d}=y(),p=react.useMemo(()=>n==="rebate"?(m||[]).map(C=>({date:C.date,volume:C.referee_rebate})).reverse():n==="volume"?l?.filter(c=>c.date>dateFns.format(dateFns.subDays(Date(),Number(t)+1),"yyyy-MM-dd")).map(c=>({date:c.date,volume:c.perp_volume}))||[]:[],[m,l,n]);return {period:t,periodTypes:a,onPeriodChange:o,volType:n,volTypes:f,onVolTypeChange:s,dataSource:Ge(Number(t),p)}};var $t=()=>{let e=Ht();return jsxRuntime.jsx(Ut,{...e})};var Zt=e=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-trader-rebates",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9 oui-tabular-nums",children:[jsxRuntime.jsx(kn,{...e}),jsxRuntime.jsx(orderlyUi.Flex,{width:"100%",className:"oui-border-y-2 oui-border-line-6",height:49,direction:"row",itemAlign:"center",children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(orderlyUi.DatePicker.range,{size:"xs",value:e.dateRange,onChange:t=>{e.setDateRange(t);},max:90,disabled:{after:new Date}})})}),jsxRuntime.jsx(In,{...e})]}),kn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.trader.myRebates")}),jsxRuntime.jsx(orderlyUi.Text,{intensity:36,className:"oui-text-2xs",children:e.displayDate})]})},In=e=>{let{t}=orderlyI18n.useTranslation(),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),a=[{title:`${t("affiliate.trader.rebates")} (USDC)`,dataIndex:"referee_rebate",render:o=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(o,{fix:6,fallback:"0",padEnd:true,prefix:"$"})}),width:127},{title:`${t("affiliate.trader.tradingVol")} (USDC)`,dataIndex:"vol",render:o=>orderlyUtils.commifyOptional(o,{fix:2,fallback:"0",padEnd:true,prefix:"$"}),width:127},{title:t("common.date"),dataIndex:"date",render:o=>jsxRuntime.jsx(orderlyUi.Text.formatted,{formatString:"yyyy-MM-dd",children:o}),width:127}];return r?jsxRuntime.jsx(orderlyUi.ListView,{dataSource:e.dataSource,className:"oui-h-[197px] oui-w-full",renderItem:(o,n)=>jsxRuntime.jsx(Bn,{item:o})}):jsxRuntime.jsx(orderlyUiConnector.AuthGuardDataTable,{bordered:true,loading:e.isLoading,columns:a,dataSource:e.dataSource,ignoreLoadingCheck:true,onRow:o=>({className:"oui-h-[41px]"}),pagination:e.pagination,manualPagination:false})},Bn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",width:"100%",children:[jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",gap:1,children:[jsxRuntime.jsx(orderlyUi.Statistic,{label:`${t("affiliate.trader.rebates")} (USDC)`,className:"oui-text-xs oui-text-base-contrast-54 oui-flex-1 oui-min-w-[105px]",children:jsxRuntime.jsx(orderlyUi.Text,{size:"sm",intensity:80,children:orderlyUtils.commifyOptional(e.item.referee_rebate,{fix:6,fallback:"0",padEnd:true,prefix:"$"})})}),jsxRuntime.jsx(orderlyUi.Statistic,{label:`${t("affiliate.trader.tradingVol")} (USDC)`,className:"oui-text-xs oui-text-base-contrast-54 oui-flex-shrink",children:jsxRuntime.jsx(orderlyUi.Text,{size:"sm",intensity:80,children:orderlyUtils.commifyOptional(e.item.vol,{fix:2,fallback:"0",padEnd:true,prefix:"$"})})}),jsxRuntime.jsx(orderlyUi.Statistic,{label:t("common.date"),className:"oui-text-xs oui-text-base-contrast-54 oui-flex-1",align:"end",children:jsxRuntime.jsx(orderlyUi.Text.formatted,{size:"sm",intensity:80,formatString:"yyyy-MM-dd",children:e.item.date})})]}),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-w-full oui-mt-3"})]})};var Qt=()=>{let[e,t]=react.useState({from:dateFns.subDays(new Date,90),to:dateFns.subDays(new Date,1)}),{data:r,mutate:a,isLoading:o}=orderlyHooks.useRefereeRebateSummary({startDate:e?.from,endDate:e?.to}),{data:n,mutate:i}=orderlyHooks.useDaily({startDate:e?.to,endDate:e?.from}),f=react.useMemo(()=>typeof r>"u"?[]:r.map(u=>{let l=u.date,d=n?.filter(p=>Zr(dateFns.toDate(l),dateFns.toDate(p.date)))?.[0];return d?{...u,vol:d.perp_volume}:u}),[r,n]),s;(f?.length||0)>0&&(s=Gr(f?.[0].date));let{pagination:x,setPage:m}=orderlyUi.usePagination();return react.useEffect(()=>{m(1);},[e]),{dateRange:e,setDateRange:t,displayDate:s,dataSource:f,pagination:x,isLoading:o}};var Yt=()=>{let e=Qt();return jsxRuntime.jsx(Zt,{...e})};var Le=()=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-trader-page",className:orderlyUi.cn("oui-h-lvw oui-w-full","oui-font-semibold"),direction:"column",gap:4,children:[jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",gap:4,className:"oui-flex oui-flex-col xl:oui-flex-row xl:oui-items-stretch",children:[jsxRuntime.jsx(Et,{}),jsxRuntime.jsx($t,{})]}),jsxRuntime.jsx(Yt,{})]});var jt=e=>{let{t}=orderlyI18n.useTranslation(),{generateCode:r}=y(),a=react.useMemo(()=>r?r.requireVolume>0?{title:t("affiliate.process.step1.volumeGt0.title",{requireVolume:r.requireVolume}),desc:t("affiliate.process.step1.volumeGt0.description",{volume:orderlyUtils.commify(r.completedVolume??0,2),requireVolume:orderlyUtils.commify(r.requireVolume)})}:{title:t("affiliate.process.step1.volumeEq0.title"),desc:t("affiliate.process.step1.volumeEq0.description")}:{title:t("affiliate.process.step1.title"),desc:t("affiliate.process.step1.description")},[r,t]);return typeof e.overwrite=="function"?e.overwrite?.(e.state):jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-becomeAffiliate",direction:"column",gap:6,p:6,itemAlign:"center",r:"2xl",className:"oui-bg-base-9",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.process.title")}),jsxRuntime.jsxs(orderlyUi.Flex,{className:"oui-flex oui-flex-col oui-gap-3 lg:oui-w-full lg:oui-flex-row lg:oui-items-stretch",children:[jsxRuntime.jsx(Kt,{icon:jsxRuntime.jsx(Zn,{}),title:a.title,content:a.desc}),jsxRuntime.jsx("div",{className:"oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center",children:jsxRuntime.jsx(Uo,{})}),jsxRuntime.jsx(Kt,{icon:jsxRuntime.jsx(Qn,{}),title:t("affiliate.process.step2.title"),content:t("affiliate.process.step2.description")}),jsxRuntime.jsx("div",{className:"oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center",children:jsxRuntime.jsx(Uo,{})}),jsxRuntime.jsx(Kt,{icon:jsxRuntime.jsx(Yn,{}),title:t("affiliate.process.step3.title"),content:t("affiliate.process.step3.description")})]})]})},Kt=e=>jsxRuntime.jsxs(orderlyUi.Flex,{className:orderlyUi.cn("oui-flex oui-flex-row oui-gap-3","lg:oui-flex-1 lg:oui-flex-col lg:oui-gap-[6px]"),width:"100%",children:[jsxRuntime.jsx("div",{className:"oui-shrink-0",children:e.icon}),jsxRuntime.jsxs(orderlyUi.Flex,{className:orderlyUi.cn("oui-flex oui-flex-col oui-items-start oui-h-full oui-justify-between","lg:oui-items-center lg:oui-justify-start"),children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm md:oui-text-base 2xl:oui-text-lg lg:oui-text-center",children:e.title}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-2xs oui-text-base-contrast-36 lg:oui-text-center",children:e.content})]})]}),Zn=()=>jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",children:[jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24.941 5.4h-6.682a.6.6 0 0 0-.593.509l-.462 3a.6.6 0 0 0 .593.691h7.606a.6.6 0 0 0 .593-.691l-.462-3a.6.6 0 0 0-.593-.509m-6.682-1.8a2.4 2.4 0 0 0-2.372 2.035l-.462 3a2.4 2.4 0 0 0 2.372 2.765h7.606a2.4 2.4 0 0 0 2.372-2.765l-.462-3A2.4 2.4 0 0 0 24.941 3.6z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{d:"M32.721 28.2c.924-1.6 3.233-1.6 4.157 0l7.275 12.6c.924 1.6-.231 3.6-2.079 3.6H27.525c-1.848 0-3.002-2-2.078-3.6z",fill:"#335FFC"}),jsxRuntime.jsx("path",{d:"M33.492 38.12H31.56c-.252 0-.426-.276-.336-.535l1.92-5.53a.4.4 0 0 1 .132-.185.34.34 0 0 1 .204-.07h3.24c.255 0 .43.284.333.544l-1.118 3.011h2.104c.31 0 .475.4.27.656l-5.158 6.453c-.251.313-.716.041-.619-.362z",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.4 16.8v2.4h2.4v-2.4zM13.2 15a.6.6 0 0 0-.6.6v4.8a.6.6 0 0 0 .6.6H18a.6.6 0 0 0 .6-.6v-4.8a.6.6 0 0 0-.6-.6z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{d:"M20.4 16.2a.6.6 0 0 1 .6-.6h2.4a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H21a.6.6 0 0 1-.6-.6zm0 3a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6zm-7.8 5.4a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.739 6.6H10.2A2.4 2.4 0 0 0 7.8 9v30a2.4 2.4 0 0 0 2.4 2.4h13.84l1.014-1.8H10.2a.6.6 0 0 1-.6-.6V9a.6.6 0 0 1 .6-.6h5.262zm12 1.8H33a.6.6 0 0 1 .6.6v16.47a2.8 2.8 0 0 1 1.8-.205V9A2.4 2.4 0 0 0 33 6.6h-5.538z",fill:"#fff",fillOpacity:".36"})]}),Qn=()=>jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",children:[jsxRuntime.jsx("path",{d:"M24 33a9 9 0 1 1-18 0 9 9 0 0 1 18 0",fill:"#335FFC"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15 32.4a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0 1.8a3.6 3.6 0 1 0 0-7.2 3.6 3.6 0 0 0 0 7.2m-6.578 4.942A4.8 4.8 0 0 1 13.2 34.8h3.6a4.8 4.8 0 0 1 4.778 4.342 9 9 0 0 1-1.778 1.473V39.6a3 3 0 0 0-3-3h-3.6a3 3 0 0 0-3 3v1.015a9 9 0 0 1-1.778-1.473",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.2 12a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0m1.8 0c0 1.37-.459 2.632-1.231 3.642l2.308 2.308a7.76 7.76 0 0 1 4.023-1.7v-.764A3.602 3.602 0 0 1 24 8.4a3.6 3.6 0 0 1 .9 7.087v.764c1.48.17 2.833.754 3.942 1.633l2.326-2.326a6 6 0 1 1 1.273 1.273l-2.326 2.326a7.76 7.76 0 0 1 1.634 3.943h.764a3.602 3.602 0 0 1 7.087.9 3.6 3.6 0 0 1-7.087.9h-.764a7.76 7.76 0 0 1-1.699 4.023l2.308 2.308a6 6 0 1 1-1.25 1.295l-2.347-2.347a7.8 7.8 0 0 1-3.05 1.433 11 11 0 0 0-.377-1.76 6 6 0 1 0-7.185-7.185q-.855-.261-1.76-.379a7.8 7.8 0 0 1 1.432-3.049l-2.347-2.347A6 6 0 1 1 18 12m7.8 0a1.8 1.8 0 1 1-3.6 0 1.8 1.8 0 0 1 3.6 0M36 25.8a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0-9.6a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4M40.2 36a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0",fill:"#fff",fillOpacity:".36"})]}),Yn=()=>jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",children:[jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 24a2.4 2.4 0 1 0 0-4.8 2.4 2.4 0 0 0 0 4.8m0 1.8a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{d:"M45 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0",fill:"#335FFC"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M35.1 6.6a.9.9 0 1 1 1.8 0v.437A3 3 0 0 1 39 9.9h-1.8a1.2 1.2 0 1 0-1.2 1.2 3 3 0 0 1 .9 5.863v.437a.9.9 0 0 1-1.8 0v-.437A3 3 0 0 1 33 14.1h1.8a1.2 1.2 0 1 0 1.2-1.2 3 3 0 0 1-.9-5.863z",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M40.2 23.7a.9.9 0 0 1 1.8 0v.6q0 .045-.004.086c-.197 9.351-7.525 16.948-16.765 17.573l1.205 1.205a.9.9 0 1 1-1.272 1.272l-2.7-2.7a.9.9 0 0 1 0-1.272l2.7-2.7a.9.9 0 1 1 1.272 1.272l-1.11 1.11c8.325-.674 14.87-7.642 14.874-16.14zM21.564 4.836a.9.9 0 1 1 1.272-1.272l2.7 2.7a.9.9 0 0 1 0 1.272l-2.7 2.7a.9.9 0 1 1-1.272-1.272l1.11-1.11C14.347 8.528 7.8 15.5 7.8 24v.3a.9.9 0 1 1-1.8 0v-.6l.004-.086C6.201 14.263 13.53 6.666 22.77 6.042z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 11.4q.615 0 1.213.058a11 11 0 0 0 .061 1.816Q24.647 13.2 24 13.2c-5.965 0-10.8 4.835-10.8 10.8 0 2.898 1.142 5.53 3 7.47a4.8 4.8 0 0 1 4.8-4.79h6a4.8 4.8 0 0 1 4.8 4.789c1.858-1.94 3-4.572 3-7.47q0-.647-.074-1.274a11 11 0 0 0 1.816.06q.057.6.058 1.214c0 6.959-5.641 12.6-12.6 12.6S11.4 30.959 11.4 24 17.041 11.4 24 11.4m6 21.581v-1.5a3 3 0 0 0-3-3h-6a3 3 0 0 0-3 3v1.5a10.75 10.75 0 0 0 6 1.819c2.22 0 4.284-.67 6-1.819",fill:"#fff",fillOpacity:".36"})]}),Uo=()=>jsxRuntime.jsx("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M8.5048 4.00806C8.8728 4.00806 9.1708 4.30626 9.1708 4.67406C9.1708 4.99259 9.1708 8.71739 9.1708 9.71072L11.1688 7.73339L12.1055 8.67005L8.98346 11.8127C8.85346 11.9434 8.6788 12.0081 8.50413 12.0081C8.33013 12.0081 8.15612 11.9427 8.02612 11.8127L4.90413 8.67005L5.8408 7.73339L7.83881 9.71072C7.83881 8.71739 7.83881 4.99259 7.83881 4.67406C7.83881 4.30626 8.1368 4.00806 8.5048 4.00806Z",fill:"#608CFF"})});var er=()=>{let e=y();return {overwrite:e.overwrite?.ref?.step,state:e}};var tr=()=>{let e=er();return jsxRuntime.jsx(jt,{...e})};var rr=()=>{let{t:e}=orderlyI18n.useTranslation();return jsxRuntime.jsx("div",{id:"oui-affiliate-home-title",className:"oui-text-center oui-text-3xl oui-font-bold md:oui-text-3xl lg:oui-text-4xl xl:oui-text-5xl",children:e("affiliate.page.title")})};var or=()=>jsxRuntime.jsx(rr,{});var ir=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-subtitle",direction:"column",className:"oui-text-sm md:oui-text-base xl:oui-text-lg oui-text-base-contrast-80 oui-text-center",gap:3,children:[jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.page.subTitle")}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,className:"oui-text-primary-light oui-fill-primary-light hover:oui-text-primary-darken oui-cursor-pointer oui-text-2xs md:oui-text-xs xl:oui-text-sm",onClick:r=>{e.onLearnAffiliate?e.onLearnAffiliate?.():e.learnAffiliateUrl&&window.open(e.learnAffiliateUrl,"_blank");},children:[jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.page.learnMore")}),jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4.008 7.995c0-.368.298-.666.666-.666H9.71L7.733 5.331l.937-.936 3.143 3.122c.13.13.195.304.195.479a.67.67 0 0 1-.195.478L8.67 11.596l-.937-.937 1.978-1.998H4.674a.666.666 0 0 1-.666-.666"})})]})]})};var ar=()=>{let e=y(),{onLearnAffiliate:t,learnAffiliateUrl:r}=e;return {onLearnAffiliate:t,learnAffiliateUrl:r}};var nr=()=>{let e=ar();return jsxRuntime.jsx(ir,{...e})};var lr=e=>e.overwriteTop!==void 0?e.overwriteTop?.(e.state):jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-top",direction:"column",gap:6,children:[jsxRuntime.jsx(or,{}),jsxRuntime.jsx(nr,{})]});var sr=()=>{let e=y();return {overwriteTop:e.overwrite?.ref?.top,state:e}};var fr=()=>{let e=sr();return jsxRuntime.jsx(lr,{...e})};var nt=e=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"white",fillOpacity:"0.98",xmlns:"http://www.w3.org/2000/svg",className:e.className,children:jsxRuntime.jsx("path",{d:"M4.00806 7.9952C4.00806 7.6272 4.30626 7.3292 4.67406 7.3292C4.99259 7.3292 8.71739 7.3292 9.71072 7.3292L7.73339 5.3312L8.67005 4.39453L11.8127 7.51654C11.9434 7.64654 12.0081 7.8212 12.0081 7.99587C12.0081 8.16987 11.9427 8.34388 11.8127 8.47388L8.67005 11.5959L7.73339 10.6592L9.71072 8.66119C8.71739 8.66119 4.99259 8.66119 4.67406 8.66119C4.30626 8.66119 4.00806 8.3632 4.00806 7.9952Z"})});var cr=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-asTrader",gradient:"success",r:"2xl",p:6,gap:6,direction:"column",angle:180,width:"100%",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{height:80,direction:"row",gap:3,itemAlign:"start",width:"100%",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"between",className:"oui-h-full",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl",children:e.isTrader?t("affiliate.trader"):t("affiliate.asTrader.title")}),jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-text-xs md:oui-text-sm 2xl:oui-text-base oui-text-base-contrast-54",e.isTrader&&"oui-hidden"),children:t("affiliate.asTrader.description")})]}),jsxRuntime.jsx("div",{className:"oui-flex-shrink-0",children:jsxRuntime.jsx(hl,{})})]}),jsxRuntime.jsx(bl,{...e})]})},hl=()=>jsxRuntime.jsxs("svg",{width:"72",height:"72",viewBox:"0 0 90 90",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"xl:oui-w-[90px] xl:oui-h-[90px] ",children:[jsxRuntime.jsx("path",{d:"M44.996 7.324c-20.71 0-37.43 16.79-37.5 37.5-.07 20.682 16.806 37.575 37.5 37.617 20.694.04 37.537-17.082 37.5-37.617-.037-20.71-16.79-37.5-37.5-37.5m0 7.5c16.569 0 30 13.433 30 30 0 8.438-3.514 16.043-9.12 21.495-2.762-5.973-8.694-10.245-15.49-10.245h-10.78c-6.791 0-12.706 4.22-15.47 10.197-5.606-5.453-9.14-13.01-9.14-21.447 0-16.567 13.431-30 30-30m0 7.5c-8.284 0-15 6.717-15 15s6.716 15 15 15 15-6.716 15-15-6.716-15-15-15",fill:"#fff",fillOpacity:".2"}),jsxRuntime.jsx("path",{d:"M90 71.25C90 81.605 81.605 90 71.25 90S52.5 81.605 52.5 71.25 60.895 52.5 71.25 52.5 90 60.895 90 71.25",fill:"#005A4F"}),jsxRuntime.jsx("path",{d:"M80.62 75.007c0-.24-.08-.49-.263-.675l-3.487-3.456-1.318 1.318 1.845 1.875H63.745a.938.938 0 0 0 0 1.875h13.652l-1.845 1.875 1.318 1.318 3.487-3.456a.95.95 0 0 0 .263-.674m-.937-7.5a.94.94 0 0 0-.938-.938H65.093l1.846-1.875-1.319-1.318-3.486 3.456a.966.966 0 0 0 0 1.349l3.486 3.456 1.319-1.318-1.846-1.875h13.652c.518 0 .938-.42.938-.937",fill:"#fff",fillOpacity:".98"})]}),bl=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",itemAlign:"end",children:(()=>{if(e.isTrader&&!e.wrongNetwork){let a=e.referralInfo?.referee_info?.total_referee_rebate;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",gap:2,children:[jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:[t("affiliate.commission")," ",jsxRuntime.jsx(orderlyUi.Text,{intensity:36,children:"(USDC)"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,children:[jsxRuntime.jsx(J,{}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl",children:orderlyUtils.commifyOptional(a,{fix:2,fallback:"0"})})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,justify:"end",itemAlign:"center",className:"oui-cursor-pointer",onClick:e?.onEnterTraderPage,children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm md:oui-text-base xl:oui-text-lg",children:t("affiliate.enter")}),jsxRuntime.jsx(nt,{className:"md:oui-size-[18px] lg:oui-size-[20px] xl:oui-size-[24px]"})]})]})}return jsxRuntime.jsx(Cl,{...e})})()})},Cl=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Dialog,{open:e.open,onOpenChange:e.setOpen,children:[jsxRuntime.jsx(orderlyUi.DialogTrigger,{children:jsxRuntime.jsx(orderlyUi.Tooltip,{content:e.wrongNetwork?t("connector.wrongNetwork.tooltip"):t("affiliate.connectWallet.tooltip"),children:e.isMobile?jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"light",onClick:r=>{(!e.isSignIn||e.wrongNetwork)&&(r.stopPropagation(),r.preventDefault(),orderlyUi.modal.alert({title:t("common.tips"),message:jsxRuntime.jsx(orderlyUi.Text,{intensity:54,children:e.wrongNetwork?t("connector.wrongNetwork.tooltip"):t("affiliate.connectWallet.tooltip")})}));},className:!e.isSignIn||e.wrongNetwork?"oui-bg-white/[.54] oui-text-black/[.36] hover:oui-bg-white/[.54]":void 0,children:t("affiliate.asTrader.button")}):jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"light",disabled:!e.isSignIn||e.wrongNetwork,children:t("affiliate.asTrader.button")})})}),jsxRuntime.jsxs(orderlyUi.DialogContent,{className:"oui-w-[320px] oui-font-semibold",children:[jsxRuntime.jsx(orderlyUi.DialogHeader,{children:jsxRuntime.jsx(orderlyUi.DialogTitle,{children:t("affiliate.referralCode.dialog.title")})}),jsxRuntime.jsx(orderlyUi.Divider,{}),jsxRuntime.jsxs(orderlyUi.DialogBody,{children:[jsxRuntime.jsx(orderlyUi.Text,{size:"sm",intensity:54,children:t("affiliate.referralCode.dialog.description")}),jsxRuntime.jsx(orderlyUi.TextField,{className:"oui-mt-4 oui-w-full",placeholder:t("affiliate.referralCode"),value:e.code,onChange:r=>{let a=r.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"");e.setCode(a);},formatters:[orderlyUi.inputFormatter.createRegexInputFormatter(r=>String(r).replace(/[a-z]/g,a=>a.toUpperCase())),orderlyUi.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)],onClean:()=>{e.setCode("");},label:t("affiliate.referralCode.label"),classNames:{label:"oui-text-2xs oui-text-base-contrast-54"},helpText:!e.isExist&&!e.isLoading&&e.code.length>0?t("affiliate.referralCode.notExist"):void 0,color:!e.isExist&&!e.isLoading&&e.code.length>0?"danger":void 0}),jsxRuntime.jsx(orderlyUi.Flex,{itemAlign:"center",width:"100%",direction:"row",justify:"center",mt:6,children:jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"primary",size:"md",className:"oui-px-[40px]",disabled:e.code.length<4||!e.isExist,onClick:r=>{r.stopPropagation(),e.onClickConfirm();},children:t("common.confirm")})})]})]})]})};var xr=()=>{let{t:e}=orderlyI18n.useTranslation(),{isTrader:t,referralInfo:r,setShowHome:a,bindReferralCodeState:o,setTab:n,mutate:i,wrongNetwork:f,disabledConnect:s}=y(),{state:x}=orderlyHooks.useAccount(),m=!s&&(x.status===orderlyTypes.AccountStatusEnum.EnableTrading||x.status===orderlyTypes.AccountStatusEnum.EnableTradingWithoutConnected),u=()=>{n("trader"),a(false);},[l,d]=react.useState(""),[p,c]=react.useState(false),{isExist:C,error:k,isLoading:ne}=orderlyHooks.useCheckReferralCode(l),U=()=>{c(false);},[I,{error:_,isMutating:A}]=orderlyHooks.useMutation("/v1/referral/bind","POST"),B=async()=>{try{await I({referral_code:l}),orderlyUi.toast.success(e("affiliate.referralCode.bound")),i(),o?o(!0,null,U,{tab:1}):U();}catch(H){let K=`${H}`;"message"in H&&(K=H.message),K==="referral code not exist"&&(K=e("affiliate.referralCode.notExist")),o?(orderlyUi.toast.error(K),o(false,H,U,{})):orderlyUi.toast.error(K);}},{isMobile:ce}=orderlyUi.useScreen();return {isSignIn:m,isTrader:t,isLoading:ne,referralInfo:r,onEnterTraderPage:u,code:l,setCode:d,open:p,setOpen:c,onClickConfirm:B,isExist:C,wrongNetwork:f,isMobile:ce}};var pr=()=>{let e=xr();return jsxRuntime.jsx(cr,{...e})};var gr=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-asAnAffiliate",gradient:"primary",r:"2xl",p:6,gap:6,direction:"column",angle:180,width:"100%",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:3,itemAlign:"start",width:"100%",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"between",className:"oui-h-full",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl",children:e.isAffiliate?t("common.affiliate"):t("affiliate.asAffiliate.title")}),jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-text-xs oui-text-base-contrast-54 md:oui-text-sm 2xl:oui-text-base",e.isAffiliate&&"oui-hidden"),children:t("affiliate.asAffiliate.description")})]}),jsxRuntime.jsx("div",{className:"oui-shrink-0",children:jsxRuntime.jsx(Ml,{})})]}),jsxRuntime.jsx(Pl,{...e})]})},Ml=()=>jsxRuntime.jsxs("svg",{width:"72",height:"72",viewBox:"0 0 72 72",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"xl:oui-w-[90px] xl:oui-h-[90px]",children:[jsxRuntime.jsx("path",{d:"M35.997 5.86c-16.569 0-29.944 13.43-30 30-.056 16.545 13.445 30.06 30 30.093s30.03-13.665 30-30.093c-.03-16.57-13.432-30-30-30m0 6c13.255 0 24 10.746 24 24 0 6.75-2.812 12.834-7.297 17.196-2.209-4.78-6.955-8.196-12.39-8.196h-8.626c-5.432 0-10.164 3.375-12.375 8.157-4.485-4.362-7.312-10.407-7.312-17.157 0-13.254 10.745-24 24-24m0 6c-6.628 0-12 5.373-12 12s5.372 12 12 12c6.627 0 12-5.373 12-12s-5.373-12-12-12",fill:"#fff",fillOpacity:".2"}),jsxRuntime.jsx("path",{d:"M72 57c0 8.284-6.716 15-15 15s-15-6.716-15-15 6.716-15 15-15 15 6.716 15 15",fill:"#1828C3"}),jsxRuntime.jsx("path",{d:"M53.624 51.45a4.125 4.125 0 0 0-4.125 4.125c0 2.388 1.36 4.641 3.61 6.703a21 21 0 0 0 2.414 1.875c.287.194.556.37.797.516.147.089.243.154.304.187a.79.79 0 0 0 .75 0c.061-.033.158-.098.305-.187.24-.147.51-.322.797-.516a21 21 0 0 0 2.414-1.875c2.25-2.062 3.61-4.315 3.61-6.703a4.125 4.125 0 0 0-4.126-4.125c-1.294 0-2.557.705-3.351 1.734-.775-1.047-2.034-1.734-3.399-1.734",fill:"#fff",fillOpacity:".98"})]}),Pl=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",itemAlign:"end",children:(()=>{if(e.isAffiliate&&!e.wrongNetwork){let a=e.referralInfo?.referrer_info?.total_referrer_rebate;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",gap:2,children:[jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:[t("affiliate.commission")," ",jsxRuntime.jsx(orderlyUi.Text,{intensity:36,children:"(USDC)"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,children:[jsxRuntime.jsx(J,{}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl",children:orderlyUtils.commifyOptional(a,{fix:2,fallback:"0"})})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,justify:"end",itemAlign:"center",className:"oui-cursor-pointer",onClick:o=>{e.onEnterAffiliatePage?.(e.referralInfo);},children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm md:oui-text-base xl:oui-text-lg",children:t("affiliate.enter")}),jsxRuntime.jsx(nt,{className:"md:oui-w-[18px] md:oui-h-[18px] lg:oui-w-[20px] lg:oui-h-[20px] xl:oui-w-[24px] xl:oui-h-[24px]"})]})]})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(orderlyUi.Tooltip,{content:e.wrongNetwork?t("connector.wrongNetwork.tooltip"):t("affiliate.connectWallet.tooltip"),children:e.isMobile?jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"light",onClick:a=>{!e.isSignIn||e.wrongNetwork?(a.stopPropagation(),a.preventDefault(),orderlyUi.modal.alert({title:t("common.tips"),message:jsxRuntime.jsx(orderlyUi.Text,{intensity:54,children:e.wrongNetwork?t("connector.wrongNetwork.tooltip"):t("affiliate.connectWallet.tooltip")})})):e.becomeAnAffiliate?.();},className:!e.isSignIn||e.wrongNetwork?"oui-bg-white/[.54] oui-text-black/[.36] hover:oui-bg-white/[.54]":void 0,children:t("affiliate.asAffiliate.button")}):jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"light",onClick:e.becomeAnAffiliate,disabled:!e.isSignIn||e.wrongNetwork,children:t("affiliate.asAffiliate.button")})}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",justify:"between",className:"oui-h-full",itemAlign:"end",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base md:oui-text-lg lg:oui-text-xl 2xl:oui-text-2xl",children:t("affiliate.upTo")}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-2xs oui-text-base-contrast-54 md:oui-text-xs 2xl:oui-text-sm",children:t("affiliate.commission")})]})]})})()})};var hr=()=>{let{isAffiliate:e,isLoading:t,referralInfo:r,becomeAnAffiliateUrl:a,setShowHome:o,setTab:n,wrongNetwork:i,disabledConnect:f}=y(),{state:s}=orderlyHooks.useAccount(),x=!f&&(s.status===orderlyTypes.AccountStatusEnum.EnableTrading||s.status===orderlyTypes.AccountStatusEnum.EnableTradingWithoutConnected),m=()=>{window.open(a,"_blank");},u=()=>{n("affiliate"),o(false);},{isMobile:l}=orderlyUi.useScreen();return {isSignIn:x,isAffiliate:e,isLoading:t,referralInfo:r,onEnterAffiliatePage:u,becomeAnAffiliate:m,wrongNetwork:i,isMobile:l}};var br=()=>{let e=hr();return jsxRuntime.jsx(gr,{...e})};var Cr=e=>typeof e.overwrite=="function"?e.overwrite?.(e.state):jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-card",className:"oui-flex oui-w-full oui-flex-col oui-items-stretch oui-gap-6 xl:oui-flex-row xl:oui-gap-[36px]",children:[jsxRuntime.jsx(br,{}),jsxRuntime.jsx(pr,{})]});var wr=()=>{let e=y();return {overwrite:e.overwrite?.ref?.card,state:e}};var yr=()=>{let e=wr();return jsxRuntime.jsx(Cr,{...e})};var ve=()=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-page",className:orderlyUi.cn("oui-h-lvw ","oui-font-semibold"),direction:"column",gap:4,children:[jsxRuntime.jsx(fr,{}),jsxRuntime.jsx(yr,{}),jsxRuntime.jsx(tr,{})]});var Rr=e=>{let{t}=orderlyI18n.useTranslation(),r=()=>{if(e.isAffiliate&&!e.isTrader)return jsxRuntime.jsxs(orderlyUi.Button,{variant:"contained",color:"success",size:"sm",className:"oui-px-2 oui-flex oui-gap-1",style:{position:"absolute",top:"50%",right:"24px",transform:"translateY(-50%)"},onClick:a=>{e.anATrader();},children:[jsxRuntime.jsx(dt,{}),jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.asTrader.title")})]});if(!e.isAffiliate&&e.isTrader)return jsxRuntime.jsxs(orderlyUi.Button,{variant:"contained",color:"primary",size:"sm",className:"oui-px-2 oui-flex oui-gap-1",style:{position:"absolute",top:"50%",right:"24px",transform:"translateY(-50%)"},onClick:a=>{e.anAnAffiliate();},children:[jsxRuntime.jsx(mt,{}),jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.asAffiliate.title")})]})};return e.isLoading?jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-max-w-[960px]",e.classNames?.loadding),children:e.splashPage?.()||jsxRuntime.jsx(ve,{})}):!e.isAffiliate&&!e.isTrader||e.showHome?jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-max-w-[960px]",e?.classNames?.home),children:jsxRuntime.jsx(ve,{})}):jsxRuntime.jsxs(orderlyUi.TabsBase,{id:"oui-affiliate-dashboard-tab",value:e.tab,onValueChange:a=>{e.setTab(a);},className:orderlyUi.cn("oui-w-full",e.classNames?.dashboard),children:[jsxRuntime.jsxs(orderlyUi.TabsList,{className:orderlyUi.cn("oui-px-6 oui-flex oui-flex-row oui-justify-start oui-h-[44px] oui-relative oui-items-end","oui-text-base md:oui-text-lg","oui-rounded-xl oui-bg-base-9","oui-border oui-border-line-6",e.isAffiliate&&e.isTrader&&"oui-justify-center"),children:[e.isAffiliate&&jsxRuntime.jsx(orderlyUi.TabsTrigger,{id:"oui-affiliate-dashboard-tab-affiliate",value:"affiliate",children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,mb:2,children:[jsxRuntime.jsx(mt,{fillOpacity:1,fill:"currentColor",className:e.tab==="affiliate"?"oui-fill-white/[.98]":"oui-fill-white/[.36]"}),jsxRuntime.jsx(orderlyUi.Text,{children:t("common.affiliate")})]})}),e.isTrader&&jsxRuntime.jsx(orderlyUi.TabsTrigger,{id:"oui-affiliate-dashboard-tab-trader",value:"trader",children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,mb:2,children:[jsxRuntime.jsx(dt,{fillOpacity:1,fill:"currentColor",className:e.tab==="trader"?"oui-fill-white/[.98]":"oui-fill-white/[.36]"}),jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.trader")})]})}),r()]}),e.isAffiliate&&jsxRuntime.jsx(orderlyUi.TabsContent,{value:"affiliate",className:"oui-mt-4",children:jsxRuntime.jsx(_e,{})}),e.isTrader&&jsxRuntime.jsx(orderlyUi.TabsContent,{value:"trader",className:"oui-mt-4",children:jsxRuntime.jsx(Le,{})})]})};var Tr=()=>{let{isAffiliate:e,isTrader:t,isLoading:r,becomeAnAffiliateUrl:a,onBecomeAnAffiliate:o,showReferralPage:n,splashPage:i,showHome:f,setShowHome:s,tab:x,setTab:m}=y(),u=react.useMemo(()=>e&&t?x:e&&!t?"affiliate":!e&&t?"trader":"affiliate",[x,e,t]);return react.useEffect(()=>{let c=new URLSearchParams(window.location.search).get("tab");c&&m(c);},[window.location.search]),{setTab:m,tab:u,isAffiliate:e,isTrader:t,isLoading:r,anAnAffiliate:()=>{s(true);},anATrader:()=>{s(true);},splashPage:i,showHome:f,setShowHome:s}};var Sr=e=>{let t=Tr();return jsxRuntime.jsx(Rr,{classNames:e.classNames,...t})};var li=e=>{let{classNames:t={}}=e,{root:r,...a}=t;return jsxRuntime.jsx("div",{id:"oui-affiliate-dashboard-page",className:orderlyUi.cn("oui-w-full oui-tracking-tight",r),children:jsxRuntime.jsx(Sr,{classNames:a})})};var ui=e=>{let{...t}=e;return jsxRuntime.jsx(orderlyUiScaffold.Scaffold,{leftSidebar:jsxRuntime.jsx(Kl,{...t}),children:jsxRuntime.jsx(orderlyUi.Box,{mx:3,my:6,children:e.children})})},Kl=e=>jsxRuntime.jsx(orderlyUi.Box,{p:4,m:3,border:true,borderColor:8,r:"xl",children:jsxRuntime.jsx(orderlyUiScaffold.SideBar,{...e})});var ci=()=>{let[e,t]=react.useState("/"),{t:r}=orderlyI18n.useTranslation();return {items:react.useMemo(()=>[{name:r("common.trading"),href:"/",icon:jsxRuntime.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M4.883 1.5c-.166.01-.393.076-.515.173a2 2 0 0 0-.18.173L.918 6.553a.86.86 0 0 0-.168.475c0 .339.232.543.232.543l7.374 8.633c.005.006.269.301.644.296s.64-.29.644-.296l7.402-8.663s.204-.269.204-.513-.196-.517-.196-.517L13.82 1.848c-.023-.032-.076-.021-.103-.049-.033-.038-.037-.091-.077-.124-.123-.097-.267-.106-.413-.123-.04-.005-.063-.049-.103-.049h-.078zm1.745 1.582h4.744L9 5.795zm-1.675.542 2.294 2.615H3.122zm8.094 0 1.831 2.615h-4.125zM3.328 7.818h4.847v5.672zm6.497 0h4.847c-1.151 1.345-3.422 4.007-4.847 5.672z",fill:"url(#a)"}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"a",x1:"17.25",y1:"9",x2:".75",y2:"9",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{stopColor:"rgb(var(--oui-gradient-brand-end))"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"rgb(var(--oui-gradient-brand-start))"})]})})]})},{name:r("common.affiliate"),href:"/affiliate",icon:jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.625 4.95c0-.746.604-1.35 1.35-1.35h4.05c.746 0 1.35.604 1.35 1.35v4.62L9 12.195 5.625 9.57zm8.624 3.163-.524.407v-.96l.074.05c.193.128.346.302.45.502m-4.42 5.148L14.4 9.705v3.345a1.35 1.35 0 0 1-1.35 1.35h-8.1a1.35 1.35 0 0 1-1.35-1.35V9.705l4.571 3.556c.488.379 1.17.379 1.658 0M4.275 8.52l-.524-.407c.104-.2.257-.374.45-.503l.074-.049zm0-2.581V4.95a2.7 2.7 0 0 1 2.7-2.7h4.05a2.7 2.7 0 0 1 2.7 2.7v.989l.823.548a2.7 2.7 0 0 1 1.202 2.247v4.316a2.7 2.7 0 0 1-2.7 2.7h-8.1a2.7 2.7 0 0 1-2.7-2.7V8.734a2.7 2.7 0 0 1 1.202-2.247zM9 6.089l.111-.118.005-.005a1.08 1.08 0 0 1 1.58.004 1.223 1.223 0 0 1 0 1.668l-1.515 1.62-.004.004c-.1.102-.26.1-.358-.004l-1.516-1.62a1.223 1.223 0 0 1 0-1.668l.004-.004a1.08 1.08 0 0 1 1.58.004z",fill:"#fff",fillOpacity:".54"})})}],[r]),current:e,onItemSelect:o=>{t(o.href);}}};var ts=e=>{let t=ci();return jsxRuntime.jsx(ui,{...t,children:e.children})};
|
|
16
|
+
var __defProp = Object.defineProperty;
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/pages/dashboard/index.tsx
|
|
23
|
+
var dashboard_exports = {};
|
|
24
|
+
__export(dashboard_exports, {
|
|
25
|
+
AffiliatePage: () => AffiliatePage,
|
|
26
|
+
DashboardPage: () => DashboardPage,
|
|
27
|
+
HomePage: () => HomePage,
|
|
28
|
+
TraderPage: () => TraderPage
|
|
29
|
+
});
|
|
30
|
+
var AffiliateIcon = (props) => {
|
|
31
|
+
const { size = 16, className, ...rest } = props;
|
|
32
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
33
|
+
"svg",
|
|
34
|
+
{
|
|
35
|
+
width: size,
|
|
36
|
+
height: size,
|
|
37
|
+
viewBox: "0 0 16 16",
|
|
38
|
+
fill: "#fff",
|
|
39
|
+
fillOpacity: ".98",
|
|
40
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
41
|
+
className: props.className,
|
|
42
|
+
...rest,
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 1.302c-3.683 0-6.655 2.985-6.667 6.667-.013 3.676 2.987 6.68 6.666 6.687s6.674-3.037 6.667-6.687c-.007-3.682-2.985-6.667-6.667-6.667m0 1.333a5.333 5.333 0 0 1 5.333 5.334c0 1.5-.625 2.852-1.622 3.821-.49-1.062-1.545-1.821-2.753-1.821H7.04c-1.207 0-2.259.75-2.75 1.812A5.3 5.3 0 0 1 2.666 7.97a5.333 5.333 0 0 1 5.333-5.334M8 3.97a2.667 2.667 0 1 0 0 5.333A2.667 2.667 0 0 0 8 3.97" }),
|
|
45
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
46
|
+
"path",
|
|
47
|
+
{
|
|
48
|
+
d: "M16 12.667a3.333 3.333 0 1 1-6.667 0 3.333 3.333 0 0 1 6.667 0",
|
|
49
|
+
fill: "#1828C3"
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11.917 11.433a.917.917 0 0 0-.917.917c0 .53.302 1.031.802 1.49a4.6 4.6 0 0 0 .713.53l.068.043c.05.027.117.027.167 0l.068-.042q.08-.05.177-.115c.182-.123.366-.26.536-.416.5-.459.802-.96.802-1.49a.917.917 0 0 0-.917-.917.97.97 0 0 0-.744.386.95.95 0 0 0-.756-.386" })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
var TraderIcon = (props) => {
|
|
58
|
+
const { size = 16, className, ...rest } = props;
|
|
59
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
60
|
+
"svg",
|
|
61
|
+
{
|
|
62
|
+
width: size,
|
|
63
|
+
height: size,
|
|
64
|
+
viewBox: "0 0 16 16",
|
|
65
|
+
fill: "white",
|
|
66
|
+
fillOpacity: "0.36",
|
|
67
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
68
|
+
className: props.className,
|
|
69
|
+
...rest,
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7.99929 1.30212C4.31735 1.30212 1.34509 4.28679 1.33262 7.96878C1.32015 11.6454 4.32042 14.6488 7.99929 14.6561C11.6782 14.6634 14.6726 11.6194 14.666 7.96878C14.6593 4.28679 11.6812 1.30212 7.99929 1.30212ZM7.99929 2.63546C10.9448 2.63546 13.3326 5.02345 13.3326 7.96878C13.3326 9.46878 12.7078 10.8208 11.7112 11.7901C11.2202 10.7281 10.1656 9.96878 8.95762 9.96878C8.71802 9.96878 7.28042 9.96878 7.04095 9.96878C5.83369 9.96878 4.78215 10.7188 4.29095 11.7814C3.29429 10.8121 2.66595 9.46878 2.66595 7.96878C2.66595 5.02345 5.05375 2.63546 7.99929 2.63546ZM7.99929 3.96879C6.52649 3.96879 5.33255 5.16279 5.33262 6.63545C5.33262 8.10812 6.52649 9.30212 7.99929 9.30212C9.47202 9.30212 10.666 8.10812 10.666 6.63545C10.666 5.16279 9.47202 3.96879 7.99929 3.96879Z" }),
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
73
|
+
"path",
|
|
74
|
+
{
|
|
75
|
+
d: "M16 12.6667C16 14.5076 14.5076 16 12.6666 16C10.8257 16 9.33331 14.5076 9.33331 12.6667C9.33331 10.8257 10.8257 9.33333 12.6666 9.33333C14.5076 9.33333 16 10.8257 16 12.6667Z",
|
|
76
|
+
fill: "#005A4F"
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
80
|
+
"path",
|
|
81
|
+
{
|
|
82
|
+
d: "M14.3325 13.3345C14.3325 13.2918 14.3182 13.2473 14.2857 13.2147L13.6658 12.6002L13.4315 12.8345L13.7595 13.1678H11.3325C11.2405 13.1678 11.1658 13.2425 11.1658 13.3345C11.1658 13.4265 11.2405 13.5012 11.3325 13.5012H13.7595L13.4315 13.8345L13.6658 14.0688L14.2857 13.4543C14.3182 13.4217 14.3325 13.3772 14.3325 13.3345ZM14.1658 12.0012C14.1658 11.9092 14.0912 11.8345 13.9992 11.8345H11.572L11.9002 11.5012L11.6658 11.2668L11.046 11.8813C10.981 11.9465 10.981 12.0558 11.046 12.121L11.6658 12.7355L11.9002 12.5012L11.572 12.1678H13.9992C14.0912 12.1678 14.1658 12.0932 14.1658 12.0012Z",
|
|
83
|
+
fill: "white",
|
|
84
|
+
fillOpacity: "0.98"
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
var TabTypes = /* @__PURE__ */ ((TabTypes2) => {
|
|
92
|
+
TabTypes2["affiliate"] = "affiliate";
|
|
93
|
+
TabTypes2["trader"] = "trader";
|
|
94
|
+
return TabTypes2;
|
|
95
|
+
})(TabTypes || {});
|
|
96
|
+
var ReferralContext = react.createContext(
|
|
97
|
+
{}
|
|
98
|
+
);
|
|
99
|
+
var useReferralContext = () => {
|
|
100
|
+
return react.useContext(ReferralContext);
|
|
101
|
+
};
|
|
102
|
+
var ReferralProvider = (props) => {
|
|
103
|
+
const {
|
|
104
|
+
becomeAnAffiliateUrl = "https://orderly.network/",
|
|
105
|
+
learnAffiliateUrl = "https://orderly.network/",
|
|
106
|
+
referralLinkUrl,
|
|
107
|
+
chartConfig,
|
|
108
|
+
overwrite,
|
|
109
|
+
children,
|
|
110
|
+
splashPage,
|
|
111
|
+
onBecomeAnAffiliate,
|
|
112
|
+
bindReferralCodeState,
|
|
113
|
+
onLearnAffiliate,
|
|
114
|
+
showReferralPage
|
|
115
|
+
} = props;
|
|
116
|
+
const { state } = orderlyHooks.useAccount();
|
|
117
|
+
const {
|
|
118
|
+
data,
|
|
119
|
+
mutate: referralInfoMutate,
|
|
120
|
+
isLoading
|
|
121
|
+
} = orderlyHooks.usePrivateQuery("/v1/referral/info", {
|
|
122
|
+
revalidateOnFocus: true,
|
|
123
|
+
errorRetryCount: 3,
|
|
124
|
+
...orderlyHooks.noCacheConfig
|
|
125
|
+
});
|
|
126
|
+
const { data: generateCode, mutate: generateCodeMutate } = orderlyHooks.usePrivateQuery(
|
|
127
|
+
"/v1/referral/auto_referral/progress",
|
|
128
|
+
{
|
|
129
|
+
revalidateOnFocus: true,
|
|
130
|
+
errorRetryCount: 2,
|
|
131
|
+
formatter: (data2) => {
|
|
132
|
+
return {
|
|
133
|
+
code: data2.auto_referral_code,
|
|
134
|
+
requireVolume: data2.required_volume,
|
|
135
|
+
completedVolume: data2.completed_volume
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
const [showHome, setShowHome] = react.useState(isLoading);
|
|
141
|
+
react.useEffect(() => {
|
|
142
|
+
setShowHome(true);
|
|
143
|
+
}, [isLoading]);
|
|
144
|
+
const { data: dailyVolume, mutate: dailyVolumeMutate } = orderlyHooks.useDaily({
|
|
145
|
+
startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1),
|
|
146
|
+
endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 90)
|
|
147
|
+
});
|
|
148
|
+
const { data: volumeStatistics, mutate: volumeStatisticsMutate } = orderlyHooks.usePrivateQuery("/v1/volume/user/stats", {
|
|
149
|
+
revalidateOnFocus: true
|
|
150
|
+
});
|
|
151
|
+
const isAffiliate = react.useMemo(() => {
|
|
152
|
+
return (data?.referrer_info?.referral_codes?.length || 0) > 0;
|
|
153
|
+
}, [data?.referrer_info]);
|
|
154
|
+
const isTrader = react.useMemo(() => {
|
|
155
|
+
return (data?.referee_info?.referer_code?.length || 0) > 0;
|
|
156
|
+
}, [data?.referee_info]);
|
|
157
|
+
const userVolume = react.useMemo(() => {
|
|
158
|
+
const volume = {};
|
|
159
|
+
if (dailyVolume && dailyVolume.length > 0) {
|
|
160
|
+
const now = dateFns.format(/* @__PURE__ */ new Date(), "yyyy-MM-dd");
|
|
161
|
+
const index = dailyVolume.findIndex((item) => item.date === now);
|
|
162
|
+
let oneDayVolume = 0;
|
|
163
|
+
if (index !== -1) {
|
|
164
|
+
oneDayVolume = dailyVolume[index].perp_volume;
|
|
165
|
+
}
|
|
166
|
+
volume["1d_volume"] = oneDayVolume;
|
|
167
|
+
}
|
|
168
|
+
if (volumeStatistics) {
|
|
169
|
+
volume["7d_volume"] = volumeStatistics.perp_volume_last_7_days;
|
|
170
|
+
volume["30d_volume"] = volumeStatistics.perp_volume_last_30_days;
|
|
171
|
+
volume["all_volume"] = volumeStatistics.perp_volume_ltd;
|
|
172
|
+
}
|
|
173
|
+
return volume;
|
|
174
|
+
}, [dailyVolume, volumeStatistics]);
|
|
175
|
+
react.useEffect(() => {
|
|
176
|
+
if (isAffiliate || isTrader) {
|
|
177
|
+
setShowHome(false);
|
|
178
|
+
}
|
|
179
|
+
}, [isAffiliate, isTrader]);
|
|
180
|
+
const memoMutate = orderlyHooks.useMemoizedFn(() => {
|
|
181
|
+
volumeStatisticsMutate();
|
|
182
|
+
dailyVolumeMutate();
|
|
183
|
+
referralInfoMutate();
|
|
184
|
+
generateCodeMutate();
|
|
185
|
+
});
|
|
186
|
+
react.useEffect(() => {
|
|
187
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
188
|
+
const refCode = searchParams.get("ref");
|
|
189
|
+
if (refCode) {
|
|
190
|
+
localStorage.setItem("referral_code", refCode);
|
|
191
|
+
}
|
|
192
|
+
}, []);
|
|
193
|
+
const [tab, setTab] = react.useState(() => {
|
|
194
|
+
const savedTab = localStorage.getItem("orderly_affiliate_dashboard_tab");
|
|
195
|
+
return savedTab || "affiliate" /* affiliate */;
|
|
196
|
+
});
|
|
197
|
+
react.useEffect(() => {
|
|
198
|
+
localStorage.setItem("orderly_affiliate_dashboard_tab", tab);
|
|
199
|
+
}, [tab]);
|
|
200
|
+
const { wrongNetwork, disabledConnect } = orderlyReactApp.useAppContext();
|
|
201
|
+
const lastStete = react.useRef(orderlyTypes.AccountStatusEnum.NotConnected);
|
|
202
|
+
const timerRef = react.useRef(null);
|
|
203
|
+
react.useEffect(() => {
|
|
204
|
+
if (lastStete.current !== state.status) {
|
|
205
|
+
lastStete.current = state.status;
|
|
206
|
+
timerRef.current = setTimeout(() => {
|
|
207
|
+
memoMutate();
|
|
208
|
+
}, 1e3);
|
|
209
|
+
}
|
|
210
|
+
return () => {
|
|
211
|
+
if (timerRef.current) {
|
|
212
|
+
clearTimeout(timerRef.current);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}, [memoMutate, state.status]);
|
|
216
|
+
const memoizedValue = react.useMemo(() => {
|
|
217
|
+
return {
|
|
218
|
+
generateCode,
|
|
219
|
+
showHome,
|
|
220
|
+
referralInfo: data,
|
|
221
|
+
isAffiliate,
|
|
222
|
+
isTrader,
|
|
223
|
+
tab,
|
|
224
|
+
becomeAnAffiliateUrl,
|
|
225
|
+
learnAffiliateUrl,
|
|
226
|
+
referralLinkUrl,
|
|
227
|
+
userVolume,
|
|
228
|
+
dailyVolume,
|
|
229
|
+
chartConfig,
|
|
230
|
+
overwrite,
|
|
231
|
+
isLoading,
|
|
232
|
+
wrongNetwork,
|
|
233
|
+
disabledConnect,
|
|
234
|
+
setShowHome,
|
|
235
|
+
setTab,
|
|
236
|
+
mutate: memoMutate,
|
|
237
|
+
onBecomeAnAffiliate,
|
|
238
|
+
bindReferralCodeState,
|
|
239
|
+
onLearnAffiliate,
|
|
240
|
+
showReferralPage,
|
|
241
|
+
splashPage
|
|
242
|
+
};
|
|
243
|
+
}, [
|
|
244
|
+
becomeAnAffiliateUrl,
|
|
245
|
+
chartConfig,
|
|
246
|
+
dailyVolume,
|
|
247
|
+
data,
|
|
248
|
+
disabledConnect,
|
|
249
|
+
generateCode,
|
|
250
|
+
isAffiliate,
|
|
251
|
+
isLoading,
|
|
252
|
+
isTrader,
|
|
253
|
+
learnAffiliateUrl,
|
|
254
|
+
overwrite,
|
|
255
|
+
referralLinkUrl,
|
|
256
|
+
showHome,
|
|
257
|
+
tab,
|
|
258
|
+
userVolume,
|
|
259
|
+
wrongNetwork,
|
|
260
|
+
onBecomeAnAffiliate,
|
|
261
|
+
bindReferralCodeState,
|
|
262
|
+
onLearnAffiliate,
|
|
263
|
+
showReferralPage,
|
|
264
|
+
splashPage,
|
|
265
|
+
memoMutate
|
|
266
|
+
]);
|
|
267
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReferralContext.Provider, { value: memoizedValue, children });
|
|
268
|
+
};
|
|
269
|
+
var USDCIcon = (props) => {
|
|
270
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
271
|
+
"svg",
|
|
272
|
+
{
|
|
273
|
+
width: "21",
|
|
274
|
+
height: "20",
|
|
275
|
+
viewBox: "0 0 21 20",
|
|
276
|
+
fill: "none",
|
|
277
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
278
|
+
className: props.className,
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#a)", children: [
|
|
281
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
282
|
+
"path",
|
|
283
|
+
{
|
|
284
|
+
d: "M10.5 20c5.542 0 10-4.458 10-10s-4.458-10-10-10S.5 4.458.5 10s4.458 10 10 10",
|
|
285
|
+
fill: "#2775CA"
|
|
286
|
+
}
|
|
287
|
+
),
|
|
288
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
289
|
+
"path",
|
|
290
|
+
{
|
|
291
|
+
d: "M13.5 11.473c0-1.452-.94-1.95-2.82-2.158-1.344-.166-1.613-.498-1.613-1.078s.448-.955 1.343-.955c.806 0 1.254.25 1.478.872.045.124.18.207.313.207h.717c.179 0 .313-.125.313-.29v-.042c-.179-.913-.985-1.618-2.015-1.701v-.996c0-.166-.134-.29-.358-.332h-.671c-.18 0-.314.124-.359.332v.954c-1.343.166-2.194.996-2.194 2.034 0 1.369.896 1.908 2.776 2.116 1.254.207 1.657.456 1.657 1.12s-.627 1.12-1.477 1.12c-1.165 0-1.568-.456-1.702-1.078a.32.32 0 0 0-.313-.25h-.762c-.179 0-.313.125-.313.291v.042c.179 1.037.895 1.784 2.373 1.991v.996c0 .166.134.29.358.332h.672c.18 0 .313-.124.358-.332v-.996c1.344-.207 2.239-1.079 2.239-2.199",
|
|
292
|
+
fill: "#fff",
|
|
293
|
+
fillOpacity: ".98"
|
|
294
|
+
}
|
|
295
|
+
),
|
|
296
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
297
|
+
"path",
|
|
298
|
+
{
|
|
299
|
+
d: "M8.24 16.57c-3.458-1.215-5.23-4.986-3.945-8.324.665-1.821 2.127-3.208 3.944-3.859.178-.086.266-.216.266-.433v-.607c0-.174-.088-.304-.266-.347-.044 0-.133 0-.177.043-4.21 1.3-6.516 5.68-5.186 9.798.798 2.428 2.704 4.292 5.186 5.072.177.087.355 0 .4-.173.043-.043.043-.087.043-.173v-.608c0-.13-.133-.303-.266-.39m4.698-13.527c-.178-.086-.355 0-.4.174-.043.043-.043.086-.043.173v.607c0 .174.133.347.266.434 3.457 1.213 5.23 4.985 3.944 8.323-.664 1.821-2.127 3.209-3.944 3.859-.178.086-.266.216-.266.433v.607c0 .174.088.304.266.347.044 0 .133 0 .177-.043 4.21-1.3 6.515-5.68 5.186-9.798-.798-2.471-2.748-4.335-5.186-5.116",
|
|
300
|
+
fill: "#fff",
|
|
301
|
+
fillOpacity: ".98"
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
] }),
|
|
305
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "a", children: /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#fff", d: "M.5 0h20v20H.5z" }) }) })
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
var Summary = (props) => {
|
|
311
|
+
const { t } = orderlyI18n.useTranslation();
|
|
312
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
313
|
+
orderlyUi.Flex,
|
|
314
|
+
{
|
|
315
|
+
id: "oui-affiliate-affiliate-summary",
|
|
316
|
+
r: "2xl",
|
|
317
|
+
p: 6,
|
|
318
|
+
width: "100%",
|
|
319
|
+
height: "100%",
|
|
320
|
+
gap: 4,
|
|
321
|
+
direction: "column",
|
|
322
|
+
className: "oui-bg-base-9",
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ jsxRuntime.jsx(Title, { ...props }),
|
|
325
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommissionData, { ...props }),
|
|
326
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", width: "100%", gap: 2, children: [
|
|
327
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
328
|
+
Row,
|
|
329
|
+
{
|
|
330
|
+
title: `${t("affiliate.referralVol")} (USDC)`,
|
|
331
|
+
value: props.referralVol,
|
|
332
|
+
dp: 2,
|
|
333
|
+
...props
|
|
334
|
+
}
|
|
335
|
+
),
|
|
336
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
337
|
+
Row,
|
|
338
|
+
{
|
|
339
|
+
title: t("affiliate.referees"),
|
|
340
|
+
value: props.referees,
|
|
341
|
+
dp: 0,
|
|
342
|
+
...props
|
|
343
|
+
}
|
|
344
|
+
),
|
|
345
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
346
|
+
Row,
|
|
347
|
+
{
|
|
348
|
+
title: t("affiliate.summary.refereesTraded"),
|
|
349
|
+
value: props.refereesTades,
|
|
350
|
+
dp: 0,
|
|
351
|
+
...props
|
|
352
|
+
}
|
|
353
|
+
)
|
|
354
|
+
] })
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
};
|
|
359
|
+
var Title = (props) => {
|
|
360
|
+
const { t } = orderlyI18n.useTranslation();
|
|
361
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
362
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-lg", children: t("affiliate.summary") }),
|
|
363
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-min-w-14", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
364
|
+
orderlyUi.Select.options,
|
|
365
|
+
{
|
|
366
|
+
size: "xs",
|
|
367
|
+
value: props.period,
|
|
368
|
+
onValueChange: props.onPeriodChange,
|
|
369
|
+
options: props.periodTypes
|
|
370
|
+
}
|
|
371
|
+
) })
|
|
372
|
+
] });
|
|
373
|
+
};
|
|
374
|
+
var CommissionData = (props) => {
|
|
375
|
+
const { t } = orderlyI18n.useTranslation();
|
|
376
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
377
|
+
orderlyUi.Flex,
|
|
378
|
+
{
|
|
379
|
+
gradient: "primary",
|
|
380
|
+
angle: 180,
|
|
381
|
+
r: "xl",
|
|
382
|
+
py: 4,
|
|
383
|
+
px: 6,
|
|
384
|
+
width: "100%",
|
|
385
|
+
direction: "column",
|
|
386
|
+
gap: 3,
|
|
387
|
+
height: "100%",
|
|
388
|
+
className: "oui-max-h-[104px]",
|
|
389
|
+
children: [
|
|
390
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 54, className: "oui-text-base 2xl:oui-text-lg", children: `${t("affiliate.commission")} (USDC)` }),
|
|
391
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
392
|
+
orderlyUi.Flex,
|
|
393
|
+
{
|
|
394
|
+
direction: "row",
|
|
395
|
+
gap: 3,
|
|
396
|
+
className: "oui-text-xl md:oui-text-2xl xl:oui-text-3xl",
|
|
397
|
+
children: [
|
|
398
|
+
/* @__PURE__ */ jsxRuntime.jsx(USDCIcon, { className: "md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] " }),
|
|
399
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: orderlyUtils.commifyOptional(props.commission, { fix: 2, fallback: "0" }) })
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
)
|
|
403
|
+
]
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
};
|
|
407
|
+
var Row = (props) => {
|
|
408
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
409
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
410
|
+
orderlyUi.Text,
|
|
411
|
+
{
|
|
412
|
+
intensity: 54,
|
|
413
|
+
className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm",
|
|
414
|
+
children: props.title
|
|
415
|
+
}
|
|
416
|
+
),
|
|
417
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-xs md:oui-text-sm xl:oui-text-base", children: orderlyUtils.commifyOptional(props.value, { fix: props.dp, fallback: "0" }) })
|
|
418
|
+
] });
|
|
419
|
+
};
|
|
420
|
+
var useSummaryScript = () => {
|
|
421
|
+
const { t } = orderlyI18n.useTranslation();
|
|
422
|
+
const [period, setPeriod] = react.useState("All");
|
|
423
|
+
const periodTypes = [
|
|
424
|
+
{ label: t("common.all"), value: "All" },
|
|
425
|
+
{ label: t("common.select.1d"), value: "1D" },
|
|
426
|
+
{ label: t("common.select.7d"), value: "7D" },
|
|
427
|
+
{ label: t("common.select.30d"), value: "30D" }
|
|
428
|
+
];
|
|
429
|
+
const { referralInfo } = useReferralContext();
|
|
430
|
+
const commission = react.useMemo(() => {
|
|
431
|
+
if (!referralInfo || !referralInfo.referrer_info) {
|
|
432
|
+
return 0;
|
|
433
|
+
}
|
|
434
|
+
switch (period) {
|
|
435
|
+
case "All":
|
|
436
|
+
return referralInfo.referrer_info.total_referrer_rebate;
|
|
437
|
+
case "1D":
|
|
438
|
+
return referralInfo.referrer_info["1d_referrer_rebate"];
|
|
439
|
+
case "7D":
|
|
440
|
+
return referralInfo.referrer_info["7d_referrer_rebate"];
|
|
441
|
+
case "30D":
|
|
442
|
+
return referralInfo.referrer_info["30d_referrer_rebate"];
|
|
443
|
+
}
|
|
444
|
+
}, [referralInfo, period]);
|
|
445
|
+
const referralVol = react.useMemo(() => {
|
|
446
|
+
if (!referralInfo || !referralInfo.referrer_info) {
|
|
447
|
+
return 0;
|
|
448
|
+
}
|
|
449
|
+
switch (period) {
|
|
450
|
+
case "All":
|
|
451
|
+
return referralInfo.referrer_info.total_referee_volume;
|
|
452
|
+
case "1D":
|
|
453
|
+
return referralInfo.referrer_info["1d_referee_volume"];
|
|
454
|
+
case "7D":
|
|
455
|
+
return referralInfo.referrer_info["7d_referee_volume"];
|
|
456
|
+
case "30D":
|
|
457
|
+
return referralInfo.referrer_info["30d_referee_volume"];
|
|
458
|
+
}
|
|
459
|
+
}, [referralInfo, period]);
|
|
460
|
+
const referees = react.useMemo(() => {
|
|
461
|
+
if (!referralInfo || !referralInfo.referrer_info) {
|
|
462
|
+
return 0;
|
|
463
|
+
}
|
|
464
|
+
switch (period) {
|
|
465
|
+
case "All":
|
|
466
|
+
return referralInfo.referrer_info.total_invites;
|
|
467
|
+
case "1D":
|
|
468
|
+
return referralInfo.referrer_info["1d_invites"];
|
|
469
|
+
case "7D":
|
|
470
|
+
return referralInfo.referrer_info["7d_invites"];
|
|
471
|
+
case "30D":
|
|
472
|
+
return referralInfo.referrer_info["30d_invites"];
|
|
473
|
+
}
|
|
474
|
+
}, [referralInfo, period]);
|
|
475
|
+
const refereesTades = react.useMemo(() => {
|
|
476
|
+
if (!referralInfo || !referralInfo.referrer_info) {
|
|
477
|
+
return 0;
|
|
478
|
+
}
|
|
479
|
+
switch (period) {
|
|
480
|
+
case "All":
|
|
481
|
+
return referralInfo.referrer_info.total_traded;
|
|
482
|
+
case "1D":
|
|
483
|
+
return referralInfo.referrer_info["1d_traded"];
|
|
484
|
+
case "7D":
|
|
485
|
+
return referralInfo.referrer_info["7d_traded"];
|
|
486
|
+
case "30D":
|
|
487
|
+
return referralInfo.referrer_info["30d_traded"];
|
|
488
|
+
}
|
|
489
|
+
}, [referralInfo, period]);
|
|
490
|
+
const onPeriodChange = (item) => {
|
|
491
|
+
setPeriod(item);
|
|
492
|
+
};
|
|
493
|
+
return {
|
|
494
|
+
period,
|
|
495
|
+
periodTypes,
|
|
496
|
+
onPeriodChange,
|
|
497
|
+
commission,
|
|
498
|
+
referralVol,
|
|
499
|
+
referees,
|
|
500
|
+
refereesTades
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
var SummaryWidget = () => {
|
|
504
|
+
const state = useSummaryScript();
|
|
505
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Summary, { ...state });
|
|
506
|
+
};
|
|
507
|
+
var AutoHideText = (props) => {
|
|
508
|
+
const { text, visibleCount } = props;
|
|
509
|
+
const containerRef = react.useRef(null);
|
|
510
|
+
const textRef = react.useRef(null);
|
|
511
|
+
const lastContainerWidth = react.useRef(void 0);
|
|
512
|
+
function getTextWidth(ref, text2) {
|
|
513
|
+
const canvas = document.createElement("canvas");
|
|
514
|
+
const context = canvas.getContext("2d");
|
|
515
|
+
const element = ref;
|
|
516
|
+
if (context && element) {
|
|
517
|
+
let fontStyle = getComputedStyle(element).font;
|
|
518
|
+
if (fontStyle.length === 0) {
|
|
519
|
+
fontStyle = [
|
|
520
|
+
getComputedStyle(element).fontWeight,
|
|
521
|
+
getComputedStyle(element).fontSize,
|
|
522
|
+
getComputedStyle(element).fontFamily
|
|
523
|
+
].join(" ");
|
|
524
|
+
}
|
|
525
|
+
context.font = fontStyle;
|
|
526
|
+
context.letterSpacing = getComputedStyle(element).letterSpacing;
|
|
527
|
+
const width = context.measureText(text2).width;
|
|
528
|
+
return width;
|
|
529
|
+
}
|
|
530
|
+
return void 0;
|
|
531
|
+
}
|
|
532
|
+
const [visibleChars, setVisibleChars] = react.useState(0);
|
|
533
|
+
react.useEffect(() => {
|
|
534
|
+
const calculateVisibleChars = () => {
|
|
535
|
+
if (props.visibleCount !== void 0)
|
|
536
|
+
return;
|
|
537
|
+
if (containerRef.current && textRef.current) {
|
|
538
|
+
const containerWidth = containerRef.current.clientWidth;
|
|
539
|
+
if (containerWidth == lastContainerWidth.current)
|
|
540
|
+
return;
|
|
541
|
+
lastContainerWidth.current = containerWidth;
|
|
542
|
+
const textElement = textRef.current;
|
|
543
|
+
const textContent = text;
|
|
544
|
+
const pWidth = Math.ceil(getTextWidth(textElement, "...") || 0);
|
|
545
|
+
const maxDisplayW = containerWidth - pWidth;
|
|
546
|
+
let count = 0;
|
|
547
|
+
while (count < text.length) {
|
|
548
|
+
let contentW = getTextWidth(textElement, subText(text, count++)) || maxDisplayW;
|
|
549
|
+
if (contentW <= maxDisplayW) {
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
setVisibleChars(textContent.length - count);
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
lastContainerWidth.current = void 0;
|
|
557
|
+
calculateVisibleChars();
|
|
558
|
+
window.addEventListener("resize", calculateVisibleChars);
|
|
559
|
+
return () => {
|
|
560
|
+
lastContainerWidth.current = void 0;
|
|
561
|
+
window.removeEventListener("resize", calculateVisibleChars);
|
|
562
|
+
};
|
|
563
|
+
}, [text, textRef]);
|
|
564
|
+
const truncatedText = react.useMemo(() => {
|
|
565
|
+
if (visibleChars + 1 >= text.length) {
|
|
566
|
+
return text;
|
|
567
|
+
}
|
|
568
|
+
const maxCharacters = visibleCount || visibleChars;
|
|
569
|
+
const startText = text.slice(0, Math.ceil(maxCharacters / 2));
|
|
570
|
+
const endText = text.slice(
|
|
571
|
+
text.length - Math.floor(maxCharacters / 2),
|
|
572
|
+
text.length
|
|
573
|
+
);
|
|
574
|
+
return `${startText}...${endText}`;
|
|
575
|
+
}, [text, visibleCount, visibleChars]);
|
|
576
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: orderlyUi.cn("oui-relative oui-w-full oui-text-end", props.className), children: [
|
|
577
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
578
|
+
"div",
|
|
579
|
+
{
|
|
580
|
+
className: orderlyUi.cn(
|
|
581
|
+
"oui-hidden oui-whitespace-nowrap oui-absolute oui-top-0 oui-bottom-0 oui-right-0 oui-left-0"
|
|
582
|
+
),
|
|
583
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { ref: textRef, children: text })
|
|
584
|
+
}
|
|
585
|
+
),
|
|
586
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: truncatedText })
|
|
587
|
+
] });
|
|
588
|
+
};
|
|
589
|
+
var subText = (text, count) => {
|
|
590
|
+
const start = Math.floor(text.length / 2 - (count > 0 ? count / 2 : 1));
|
|
591
|
+
const first = text.slice(0, start);
|
|
592
|
+
const end = text.slice(start + count);
|
|
593
|
+
return first + end;
|
|
594
|
+
};
|
|
595
|
+
var ReferralLink = (props) => {
|
|
596
|
+
const { t } = orderlyI18n.useTranslation();
|
|
597
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
598
|
+
orderlyUi.Flex,
|
|
599
|
+
{
|
|
600
|
+
id: "oui-affiliate-affiliate-referralLink",
|
|
601
|
+
r: "2xl",
|
|
602
|
+
p: 6,
|
|
603
|
+
width: "100%",
|
|
604
|
+
gap: 4,
|
|
605
|
+
direction: "column",
|
|
606
|
+
className: "oui-bg-base-9",
|
|
607
|
+
children: [
|
|
608
|
+
/* @__PURE__ */ jsxRuntime.jsx(Title2, { ...props }),
|
|
609
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
610
|
+
orderlyUi.Flex,
|
|
611
|
+
{
|
|
612
|
+
width: "100%",
|
|
613
|
+
className: "oui-flex oui-flex-col 3xl:oui-flex-row",
|
|
614
|
+
gap: 4,
|
|
615
|
+
children: [
|
|
616
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-w-full 3xl:oui-w-1/3", children: /* @__PURE__ */ jsxRuntime.jsx(Subtitle, { ...props }) }),
|
|
617
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
618
|
+
orderlyUi.Flex,
|
|
619
|
+
{
|
|
620
|
+
direction: "column",
|
|
621
|
+
width: "100%",
|
|
622
|
+
className: "3xl:oui-w-2/3 3xl:oui-gap-2",
|
|
623
|
+
children: [
|
|
624
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
625
|
+
Input,
|
|
626
|
+
{
|
|
627
|
+
title: t("affiliate.referralCode"),
|
|
628
|
+
value: props.refCode,
|
|
629
|
+
...props
|
|
630
|
+
}
|
|
631
|
+
),
|
|
632
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
633
|
+
Input,
|
|
634
|
+
{
|
|
635
|
+
title: t("affiliate.referralLink"),
|
|
636
|
+
value: props.refLink,
|
|
637
|
+
...props
|
|
638
|
+
}
|
|
639
|
+
)
|
|
640
|
+
]
|
|
641
|
+
}
|
|
642
|
+
)
|
|
643
|
+
]
|
|
644
|
+
}
|
|
645
|
+
)
|
|
646
|
+
]
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
};
|
|
650
|
+
var Title2 = (props) => {
|
|
651
|
+
const { t } = orderlyI18n.useTranslation();
|
|
652
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { direction: "row", justify: "between", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-lg", children: t("affiliate.referralLink") }) });
|
|
653
|
+
};
|
|
654
|
+
var Subtitle = (props) => {
|
|
655
|
+
const { t } = orderlyI18n.useTranslation();
|
|
656
|
+
const item = (title, value, gradient, className, tooltip) => {
|
|
657
|
+
const valueClsName = "oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl";
|
|
658
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", itemAlign: "start", className, children: [
|
|
659
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { direction: "row", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(Alert, { title, tooltip }) }),
|
|
660
|
+
gradient ? /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.gradient, { color: "brand", className: valueClsName, children: value }) : /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: valueClsName, children: value })
|
|
661
|
+
] });
|
|
662
|
+
};
|
|
663
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", width: "100%", children: [
|
|
664
|
+
item(
|
|
665
|
+
t("affiliate.referralLink.earn"),
|
|
666
|
+
props.earn || "-",
|
|
667
|
+
true,
|
|
668
|
+
"oui-flex-1",
|
|
669
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
670
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.gradient, { color: "brand", children: props.earn || "-" }),
|
|
671
|
+
" ",
|
|
672
|
+
t("affiliate.referralLink.earn.tooltip", {
|
|
673
|
+
brokerName: props.brokerName
|
|
674
|
+
})
|
|
675
|
+
] })
|
|
676
|
+
// @ts-ignore
|
|
677
|
+
// <Trans
|
|
678
|
+
// i18nKey="affiliate.referralLink.earn.tooltip"
|
|
679
|
+
// values={{
|
|
680
|
+
// value: props.earn || "-",
|
|
681
|
+
// brokerName: props.brokerName,
|
|
682
|
+
// }}
|
|
683
|
+
// components={[<Text.gradient color="brand" />]}
|
|
684
|
+
// />
|
|
685
|
+
),
|
|
686
|
+
item(
|
|
687
|
+
t("affiliate.referralLink.share"),
|
|
688
|
+
props.share || "-",
|
|
689
|
+
false,
|
|
690
|
+
"oui-flex-1",
|
|
691
|
+
// @ts-ignore
|
|
692
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
693
|
+
orderlyI18n.Trans,
|
|
694
|
+
{
|
|
695
|
+
i18nKey: "affiliate.referralLink.share.tooltip",
|
|
696
|
+
values: {
|
|
697
|
+
value: props.share || "-",
|
|
698
|
+
brokerName: props.brokerName
|
|
699
|
+
},
|
|
700
|
+
components: [/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.gradient, { color: "brand" })]
|
|
701
|
+
}
|
|
702
|
+
)
|
|
703
|
+
)
|
|
704
|
+
] });
|
|
705
|
+
};
|
|
706
|
+
var Input = (props) => {
|
|
707
|
+
const { title, value = "-" } = props;
|
|
708
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
709
|
+
orderlyUi.Flex,
|
|
710
|
+
{
|
|
711
|
+
r: "xl",
|
|
712
|
+
p: 3,
|
|
713
|
+
gap: 4,
|
|
714
|
+
direction: "row",
|
|
715
|
+
width: "100%",
|
|
716
|
+
className: "oui-bg-base-8",
|
|
717
|
+
children: [
|
|
718
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-base-contrast-54 oui-flex-shrink oui-text-2xs md:oui-text-xs xl:oui-text-sm", children: title }),
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
720
|
+
orderlyUi.Flex,
|
|
721
|
+
{
|
|
722
|
+
direction: "row",
|
|
723
|
+
justify: "end",
|
|
724
|
+
gap: 2,
|
|
725
|
+
className: "oui-flex-1 oui-text-xs md:oui-text-sm xl:oui-text-base",
|
|
726
|
+
children: [
|
|
727
|
+
/* @__PURE__ */ jsxRuntime.jsx(AutoHideText, { text: value }),
|
|
728
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
729
|
+
"button",
|
|
730
|
+
{
|
|
731
|
+
className: "oui-cursor-pointer oui-text-sm oui-flex-shrink",
|
|
732
|
+
onClick: () => {
|
|
733
|
+
navigator.clipboard.writeText(value);
|
|
734
|
+
props.onCopy?.(value);
|
|
735
|
+
},
|
|
736
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
737
|
+
orderlyUi.CopyIcon,
|
|
738
|
+
{
|
|
739
|
+
size: 12,
|
|
740
|
+
color: "white",
|
|
741
|
+
className: "oui-w-[13px] oui-h-[13px] md:oui-w-[14px] md:oui-h-[14px] xl:oui-w-4 xl:oui-h-4"
|
|
742
|
+
}
|
|
743
|
+
)
|
|
744
|
+
}
|
|
745
|
+
)
|
|
746
|
+
]
|
|
747
|
+
}
|
|
748
|
+
)
|
|
749
|
+
]
|
|
750
|
+
}
|
|
751
|
+
);
|
|
752
|
+
};
|
|
753
|
+
var Alert = (props) => {
|
|
754
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Tooltip, { content: props.tooltip, className: "oui-max-w-[200px]", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
755
|
+
"div",
|
|
756
|
+
{
|
|
757
|
+
onClick: () => {
|
|
758
|
+
orderlyUi.modal.alert({
|
|
759
|
+
title: props.title,
|
|
760
|
+
message: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-base-contrast/30 oui-space-y-3 oui-text-xs desktop:oui-text-xs", children: props.tooltip })
|
|
761
|
+
});
|
|
762
|
+
},
|
|
763
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", children: [
|
|
764
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
765
|
+
orderlyUi.Text,
|
|
766
|
+
{
|
|
767
|
+
intensity: 54,
|
|
768
|
+
className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm",
|
|
769
|
+
children: props.title
|
|
770
|
+
}
|
|
771
|
+
),
|
|
772
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Divider, { className: "oui-w-full", lineStyle: "dotted", intensity: 16 })
|
|
773
|
+
] })
|
|
774
|
+
}
|
|
775
|
+
) });
|
|
776
|
+
};
|
|
777
|
+
function generateReferralLink(referralLinkUrl, code) {
|
|
778
|
+
return `${referralLinkUrl || window?.location?.origin}?ref=${code}`;
|
|
779
|
+
}
|
|
780
|
+
async function copyText(content) {
|
|
781
|
+
try {
|
|
782
|
+
await navigator.clipboard.writeText(content);
|
|
783
|
+
orderlyUi.toast.success(orderlyI18n.i18n.t("common.copy.copied"));
|
|
784
|
+
} catch (error) {
|
|
785
|
+
orderlyUi.toast.success(orderlyI18n.i18n.t("common.copy.failed"));
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function formatDateTimeToUTC(input) {
|
|
789
|
+
if (input === void 0) {
|
|
790
|
+
return "";
|
|
791
|
+
}
|
|
792
|
+
const date = dateFns.toDate(input);
|
|
793
|
+
const utcDate = toUTCDate(date);
|
|
794
|
+
return dateFns.format(utcDate, "yyyy-MM-dd HH:mm:ss 'UTC'");
|
|
795
|
+
}
|
|
796
|
+
function formatYMDTime(time) {
|
|
797
|
+
if (time === void 0) {
|
|
798
|
+
return void 0;
|
|
799
|
+
}
|
|
800
|
+
const date = dateFns.toDate(time);
|
|
801
|
+
const utcDate = toUTCDate(date);
|
|
802
|
+
return dateFns.format(utcDate, "yyyy-MM-dd");
|
|
803
|
+
}
|
|
804
|
+
function compareDate(d1, d2) {
|
|
805
|
+
const isEqual = d1 && d2 && d1.toISOString().substring(0, 10) === d2.toISOString().substring(0, 10);
|
|
806
|
+
return isEqual;
|
|
807
|
+
}
|
|
808
|
+
function toUTCDate(date) {
|
|
809
|
+
return new Date(date.toUTCString());
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// src/pages/affiliate/referralLink/referralLink.script.tsx
|
|
813
|
+
var useReferralLinkScript = () => {
|
|
814
|
+
const { t } = orderlyI18n.useTranslation();
|
|
815
|
+
const onCopy = (value) => {
|
|
816
|
+
orderlyUi.toast.success(t("common.copy.copied"));
|
|
817
|
+
};
|
|
818
|
+
const { referralInfo, referralLinkUrl, overwrite } = useReferralContext();
|
|
819
|
+
const [pinCodes, setPinCodes] = orderlyHooks.useLocalStorage(
|
|
820
|
+
"orderly_referral_codes",
|
|
821
|
+
[]
|
|
822
|
+
);
|
|
823
|
+
const codes = react.useMemo(() => {
|
|
824
|
+
if (!referralInfo?.referrer_info?.referral_codes)
|
|
825
|
+
return [];
|
|
826
|
+
const referralCodes = [...referralInfo?.referrer_info?.referral_codes];
|
|
827
|
+
const pinedItems = [];
|
|
828
|
+
for (let i = 0; i < pinCodes.length; i++) {
|
|
829
|
+
const code2 = pinCodes[i];
|
|
830
|
+
const index = referralCodes.findIndex((item) => item.code === code2);
|
|
831
|
+
if (index !== -1) {
|
|
832
|
+
pinedItems.push({ ...referralCodes[index] });
|
|
833
|
+
referralCodes.splice(index, 1);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
return [...pinedItems, ...referralCodes];
|
|
837
|
+
}, [referralInfo?.referrer_info?.referral_codes, pinCodes]);
|
|
838
|
+
const firstCode = react.useMemo(() => {
|
|
839
|
+
if (codes.length === 0) {
|
|
840
|
+
return void 0;
|
|
841
|
+
}
|
|
842
|
+
return codes[0];
|
|
843
|
+
}, [codes]);
|
|
844
|
+
const code = react.useMemo(() => {
|
|
845
|
+
return firstCode?.code;
|
|
846
|
+
}, [firstCode]);
|
|
847
|
+
const referralLink = react.useMemo(() => {
|
|
848
|
+
if (!firstCode)
|
|
849
|
+
return "";
|
|
850
|
+
return generateReferralLink(referralLinkUrl, firstCode.code);
|
|
851
|
+
}, [firstCode]);
|
|
852
|
+
const earn = react.useMemo(() => {
|
|
853
|
+
const value = new orderlyUtils.Decimal(firstCode?.referrer_rebate_rate || "0").mul(100).toDecimalPlaces(0, orderlyUtils.Decimal.ROUND_DOWN).toString();
|
|
854
|
+
return `${value}%`;
|
|
855
|
+
}, [firstCode?.referrer_rebate_rate]);
|
|
856
|
+
const share = react.useMemo(() => {
|
|
857
|
+
const value = new orderlyUtils.Decimal(firstCode?.referee_rebate_rate || "0").mul(100).toDecimalPlaces(0, orderlyUtils.Decimal.ROUND_DOWN).toString();
|
|
858
|
+
return `${value}%`;
|
|
859
|
+
}, [firstCode?.referee_rebate_rate]);
|
|
860
|
+
return {
|
|
861
|
+
onCopy,
|
|
862
|
+
refLink: referralLink,
|
|
863
|
+
refCode: code,
|
|
864
|
+
share,
|
|
865
|
+
earn,
|
|
866
|
+
brokerName: overwrite?.brokerName ?? overwrite?.shortBrokerName
|
|
867
|
+
};
|
|
868
|
+
};
|
|
869
|
+
var ReferralLinkWidget = () => {
|
|
870
|
+
const state = useReferralLinkScript();
|
|
871
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReferralLink, { ...state });
|
|
872
|
+
};
|
|
873
|
+
var TitleStatistic = (props) => {
|
|
874
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
875
|
+
orderlyUi.Flex,
|
|
876
|
+
{
|
|
877
|
+
id: "oui-affiliate-affiliate-titleStatistic",
|
|
878
|
+
r: "2xl",
|
|
879
|
+
p: 6,
|
|
880
|
+
width: "100%",
|
|
881
|
+
gap: 4,
|
|
882
|
+
direction: "column",
|
|
883
|
+
className: "oui-bg-base-9",
|
|
884
|
+
children: [
|
|
885
|
+
/* @__PURE__ */ jsxRuntime.jsx(Title3, { ...props }),
|
|
886
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { className: "oui-h-[170px] 2xl:oui-h-[196px] oui-w-full oui-flex oui-flex-row oui-items-stretch", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
887
|
+
orderlyChart.VolBarChart,
|
|
888
|
+
{
|
|
889
|
+
data: props.dataSource || orderlyTypes.EMPTY_LIST,
|
|
890
|
+
colors: { fill: "rgba(0, 180, 158, 1)" },
|
|
891
|
+
className: "oui-w-full oui-flex-1",
|
|
892
|
+
tooltip: {
|
|
893
|
+
rm: orderlyUtils.Decimal.ROUND_DOWN,
|
|
894
|
+
dp: props.volType === "Commission" ? 6 : 2
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
) })
|
|
898
|
+
]
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
};
|
|
902
|
+
var Title3 = (props) => {
|
|
903
|
+
const { t } = orderlyI18n.useTranslation();
|
|
904
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
905
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-lg", children: t("affiliate.statistics") }),
|
|
906
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", gap: 2, className: "oui-min-w-14", children: [
|
|
907
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
908
|
+
orderlyUi.Select.options,
|
|
909
|
+
{
|
|
910
|
+
size: "xs",
|
|
911
|
+
value: props.period,
|
|
912
|
+
onValueChange: props.onPeriodChange,
|
|
913
|
+
options: props.periodTypes
|
|
914
|
+
}
|
|
915
|
+
),
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
917
|
+
orderlyUi.Select.options,
|
|
918
|
+
{
|
|
919
|
+
size: "xs",
|
|
920
|
+
value: props.volType,
|
|
921
|
+
onValueChange: props.onVolTypeChange,
|
|
922
|
+
options: props.volTypes
|
|
923
|
+
}
|
|
924
|
+
)
|
|
925
|
+
] })
|
|
926
|
+
] });
|
|
927
|
+
};
|
|
928
|
+
function fillData(days, origin) {
|
|
929
|
+
const now = Date();
|
|
930
|
+
const result = new Array(days).fill(0).map((_, index) => {
|
|
931
|
+
return {
|
|
932
|
+
date: dateFns.format(dateFns.subDays(now, index + 1), "yyyy-MM-dd"),
|
|
933
|
+
volume: 0,
|
|
934
|
+
opacity: 0
|
|
935
|
+
};
|
|
936
|
+
}).reverse();
|
|
937
|
+
const dataObject = origin?.reduce(
|
|
938
|
+
(acc, curr) => {
|
|
939
|
+
acc[curr.date] = curr;
|
|
940
|
+
return acc;
|
|
941
|
+
},
|
|
942
|
+
{}
|
|
943
|
+
);
|
|
944
|
+
for (let index = 0; index < result.length; index++) {
|
|
945
|
+
const element = result[index];
|
|
946
|
+
const originData = dataObject?.[element.date];
|
|
947
|
+
if (originData) {
|
|
948
|
+
result[index] = { ...originData, opacity: originData.volume > 0 ? 1 : 0 };
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return result;
|
|
952
|
+
}
|
|
953
|
+
var useTitleStatisticScript = () => {
|
|
954
|
+
const { t } = orderlyI18n.useTranslation();
|
|
955
|
+
const [period, setPeriod] = react.useState("7");
|
|
956
|
+
const periodTypes = [
|
|
957
|
+
{ label: t("common.select.7d"), value: "7" },
|
|
958
|
+
{ label: t("common.select.30d"), value: "30" },
|
|
959
|
+
{ label: t("common.select.90d"), value: "90" }
|
|
960
|
+
];
|
|
961
|
+
const onPeriodChange = (item) => {
|
|
962
|
+
setPeriod(item);
|
|
963
|
+
};
|
|
964
|
+
const [volType, setVolType] = react.useState("Commission");
|
|
965
|
+
const volTypes = [
|
|
966
|
+
{ label: t("affiliate.commission"), value: "Commission" },
|
|
967
|
+
{ label: t("affiliate.referralVol"), value: "ref" }
|
|
968
|
+
];
|
|
969
|
+
const onVolTypeChange = (item) => {
|
|
970
|
+
setVolType(item);
|
|
971
|
+
};
|
|
972
|
+
const dateRange = react.useMemo(() => {
|
|
973
|
+
if (period === "7") {
|
|
974
|
+
return {
|
|
975
|
+
startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 7),
|
|
976
|
+
endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
977
|
+
};
|
|
978
|
+
} else if (period === "30") {
|
|
979
|
+
return {
|
|
980
|
+
startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 30),
|
|
981
|
+
endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
982
|
+
};
|
|
983
|
+
} else if (period === "90") {
|
|
984
|
+
return {
|
|
985
|
+
startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
|
|
986
|
+
endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
987
|
+
};
|
|
988
|
+
} else {
|
|
989
|
+
return {
|
|
990
|
+
startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 7),
|
|
991
|
+
endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
}, [period]);
|
|
995
|
+
const [rebateSummary] = orderlyHooks.useReferralRebateSummary({
|
|
996
|
+
startDate: dateFns.format(dateRange.startDate, "yyyy-MM-dd"),
|
|
997
|
+
endDate: dateFns.format(dateRange.endDate, "yyyy-MM-dd"),
|
|
998
|
+
size: Number(period)
|
|
999
|
+
});
|
|
1000
|
+
const dataSource = react.useMemo(() => {
|
|
1001
|
+
return (rebateSummary?.map(
|
|
1002
|
+
(e) => ({
|
|
1003
|
+
date: e.date,
|
|
1004
|
+
volume: volType === "Commission" ? e.referral_rebate : e.volume
|
|
1005
|
+
})
|
|
1006
|
+
) || []).reverse();
|
|
1007
|
+
}, [rebateSummary, volType]);
|
|
1008
|
+
return {
|
|
1009
|
+
period,
|
|
1010
|
+
periodTypes,
|
|
1011
|
+
onPeriodChange,
|
|
1012
|
+
volType,
|
|
1013
|
+
volTypes,
|
|
1014
|
+
onVolTypeChange,
|
|
1015
|
+
dataSource: fillData(Number(period), dataSource)
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
1018
|
+
var TitleStatisticWidget = () => {
|
|
1019
|
+
const state = useTitleStatisticScript();
|
|
1020
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TitleStatistic, { ...state });
|
|
1021
|
+
};
|
|
1022
|
+
var EditIcon = (props) => {
|
|
1023
|
+
const { className, ...rest } = props;
|
|
1024
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1025
|
+
"svg",
|
|
1026
|
+
{
|
|
1027
|
+
width: "12",
|
|
1028
|
+
height: "13",
|
|
1029
|
+
viewBox: "0 0 12 13",
|
|
1030
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1031
|
+
fill: "white",
|
|
1032
|
+
fillOpacity: "0.36",
|
|
1033
|
+
className,
|
|
1034
|
+
...rest,
|
|
1035
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8.49773 1.47656C8.36523 1.47656 8.23223 1.52357 8.13823 1.61707C7.86023 1.89507 6.85973 2.89558 6.63773 3.11808L2.13523 7.62059L1.63473 8.12059C1.56523 8.19059 1.52923 8.28958 1.50973 8.38658L1.00973 10.8881C0.939727 11.2381 1.23773 11.5361 1.58773 11.4666C1.90073 11.4036 3.77673 11.0286 4.08923 10.9661C4.18623 10.9466 4.28523 10.9106 4.35523 10.8411L4.85523 10.3406L9.35773 5.83808C9.58023 5.61608 10.5807 4.61506 10.8587 4.33756C10.9522 4.24356 10.9992 4.11056 10.9992 3.97806C10.9992 3.15956 10.7907 2.57456 10.3582 2.13306C9.92173 1.68756 9.33873 1.47656 8.49773 1.47656ZM8.69473 2.48606C9.14623 2.51256 9.43873 2.61608 9.63923 2.82108C9.84423 3.03008 9.97373 3.32008 10.0017 3.76258C9.72773 4.03608 9.32673 4.43106 8.99823 4.75956C8.60173 4.36306 8.11273 3.87407 7.71623 3.47757C8.04523 3.14907 8.42123 2.75956 8.69473 2.48606ZM6.99723 4.19657L8.27923 5.47858L4.49573 9.26207L3.21373 7.98009L6.99723 4.19657ZM2.49473 8.69908L3.77673 9.98107L3.72973 10.0281C3.39973 10.0941 2.73323 10.2336 2.11923 10.3566L2.44773 8.74608L2.49473 8.69908Z" })
|
|
1036
|
+
}
|
|
1037
|
+
);
|
|
1038
|
+
};
|
|
1039
|
+
var EditCode = (props) => {
|
|
1040
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1041
|
+
EditIcon,
|
|
1042
|
+
{
|
|
1043
|
+
className: " oui-mt-px oui-cursor-pointer oui-fill-base-contrast-36 hover:oui-fill-base-contrast-80",
|
|
1044
|
+
fillOpacity: 1,
|
|
1045
|
+
fill: "currentColor",
|
|
1046
|
+
onClick: props.onClick
|
|
1047
|
+
}
|
|
1048
|
+
) });
|
|
1049
|
+
};
|
|
1050
|
+
var PinBtn = (props) => {
|
|
1051
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1052
|
+
"button",
|
|
1053
|
+
{
|
|
1054
|
+
onClick: (e) => {
|
|
1055
|
+
props?.onClick?.(!props.pinned);
|
|
1056
|
+
},
|
|
1057
|
+
children: props.pinned === false ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1058
|
+
UnPinIcon,
|
|
1059
|
+
{
|
|
1060
|
+
size: props.size,
|
|
1061
|
+
fillOpacity: 1,
|
|
1062
|
+
className: "orderly-fill-primary-darken hover:orderly-fill-primary-darken/80"
|
|
1063
|
+
}
|
|
1064
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1065
|
+
PinnedIcon,
|
|
1066
|
+
{
|
|
1067
|
+
size: props.size,
|
|
1068
|
+
fillOpacity: 1,
|
|
1069
|
+
className: "orderly-fill-base-contrast-36 hover:orderly-fill-base-contrast"
|
|
1070
|
+
}
|
|
1071
|
+
)
|
|
1072
|
+
}
|
|
1073
|
+
);
|
|
1074
|
+
};
|
|
1075
|
+
var PinnedIcon = (props) => {
|
|
1076
|
+
const { size = 12 } = props;
|
|
1077
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1078
|
+
"svg",
|
|
1079
|
+
{
|
|
1080
|
+
width: size,
|
|
1081
|
+
height: size,
|
|
1082
|
+
viewBox: "0 0 16 16",
|
|
1083
|
+
fill: "#608CFF",
|
|
1084
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1085
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208" })
|
|
1086
|
+
}
|
|
1087
|
+
);
|
|
1088
|
+
};
|
|
1089
|
+
var UnPinIcon = (props) => {
|
|
1090
|
+
const { size = 12 } = props;
|
|
1091
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1092
|
+
"svg",
|
|
1093
|
+
{
|
|
1094
|
+
width: size,
|
|
1095
|
+
height: size,
|
|
1096
|
+
viewBox: "0 0 16 16",
|
|
1097
|
+
fill: "#fff",
|
|
1098
|
+
fillOpacity: ".36",
|
|
1099
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1100
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208m.258 1.37c.708.131 1.421.6 1.93 1.108.507.507.94 1.13 1.119 1.944-.636.61-1.026.659-1.662.324a.67.67 0 0 0-.779.116c-1.214 1.213-1.533 2.314-1.533 3.8 0 1.293-.076 1.774-.48 2.207-.113.123-.27.104-.374 0L3.799 7.486a.24.24 0 0 1-.017-.34c.239-.29.769-.514 2.226-.514 1.742.001 2.668-.447 3.812-1.52a.67.67 0 0 0 .125-.77c-.343-.685-.29-1.046.321-1.67" })
|
|
1101
|
+
}
|
|
1102
|
+
);
|
|
1103
|
+
};
|
|
1104
|
+
var ReferralCodes = (props) => {
|
|
1105
|
+
const isTablet = orderlyHooks.useMediaQuery("(max-width: 767px)");
|
|
1106
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1107
|
+
orderlyUi.Flex,
|
|
1108
|
+
{
|
|
1109
|
+
r: "2xl",
|
|
1110
|
+
p: 6,
|
|
1111
|
+
width: "100%",
|
|
1112
|
+
gap: 4,
|
|
1113
|
+
direction: "column",
|
|
1114
|
+
className: "oui-h-full oui-bg-base-9 oui-p-6 oui-tabular-nums",
|
|
1115
|
+
children: [
|
|
1116
|
+
/* @__PURE__ */ jsxRuntime.jsx(Title4, { ...props }),
|
|
1117
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-w-full oui-flex-col 2xl:oui-h-full", children: [
|
|
1118
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Divider, {}),
|
|
1119
|
+
isTablet ? /* @__PURE__ */ jsxRuntime.jsx(MobileLayout, { ...props }) : /* @__PURE__ */ jsxRuntime.jsx(DesktopLayout, { ...props })
|
|
1120
|
+
] })
|
|
1121
|
+
]
|
|
1122
|
+
}
|
|
1123
|
+
);
|
|
1124
|
+
};
|
|
1125
|
+
var Title4 = (props) => {
|
|
1126
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1127
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
1128
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-lg", children: t("affiliate.referralCodes") }),
|
|
1129
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm", children: [
|
|
1130
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-base-contrast-54", children: `${t("affiliate.referralCodes.remaining")}: ` }),
|
|
1131
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-primary-light", children: props.codes?.length || "--" })
|
|
1132
|
+
] })
|
|
1133
|
+
] });
|
|
1134
|
+
};
|
|
1135
|
+
var MobileLayout = (props) => {
|
|
1136
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1137
|
+
orderlyUi.ListView,
|
|
1138
|
+
{
|
|
1139
|
+
dataSource: props.codes,
|
|
1140
|
+
className: "oui-max-h-[240px] oui-w-full",
|
|
1141
|
+
renderItem: (e, index) => {
|
|
1142
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", children: [
|
|
1143
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1144
|
+
MobileCell,
|
|
1145
|
+
{
|
|
1146
|
+
data: e,
|
|
1147
|
+
editRate: props.editRate,
|
|
1148
|
+
copyLink: props.copyLink,
|
|
1149
|
+
copyCode: props.copyCode,
|
|
1150
|
+
setPinCode: props.setPinCode,
|
|
1151
|
+
editCode: props.editCode
|
|
1152
|
+
},
|
|
1153
|
+
index
|
|
1154
|
+
),
|
|
1155
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Divider, { className: "oui-mt-3 oui-w-full" })
|
|
1156
|
+
] });
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
);
|
|
1160
|
+
};
|
|
1161
|
+
var MobileCellItem = (props) => {
|
|
1162
|
+
const { title, copyable, value, align, className, editRate, onCopy } = props;
|
|
1163
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1164
|
+
orderlyUi.Statistic,
|
|
1165
|
+
{
|
|
1166
|
+
id: "oui-affiliate-affiliate-referralCodes",
|
|
1167
|
+
className: orderlyUi.cn("oui-flex-1", className),
|
|
1168
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-2xs oui-text-base-contrast-36", children: title }),
|
|
1169
|
+
align,
|
|
1170
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", gap: 1, children: [
|
|
1171
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1172
|
+
orderlyUi.Text.formatted,
|
|
1173
|
+
{
|
|
1174
|
+
copyable,
|
|
1175
|
+
onCopy: () => {
|
|
1176
|
+
onCopy?.();
|
|
1177
|
+
},
|
|
1178
|
+
className: "oui-mt-[6px] oui-text-sm oui-text-base-contrast-80",
|
|
1179
|
+
children: value
|
|
1180
|
+
}
|
|
1181
|
+
),
|
|
1182
|
+
editRate && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1183
|
+
EditIcon,
|
|
1184
|
+
{
|
|
1185
|
+
className: "oui-mt-px oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",
|
|
1186
|
+
fillOpacity: 1,
|
|
1187
|
+
fill: "currentColor",
|
|
1188
|
+
onClick: () => editRate()
|
|
1189
|
+
}
|
|
1190
|
+
)
|
|
1191
|
+
] })
|
|
1192
|
+
}
|
|
1193
|
+
);
|
|
1194
|
+
};
|
|
1195
|
+
var MobileCell = (props) => {
|
|
1196
|
+
const { data, setPinCode, copyLink, editRate, editCode } = props;
|
|
1197
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1198
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { gap: 3, direction: "column", className: "oui-w-full", children: [
|
|
1199
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1200
|
+
orderlyUi.Flex,
|
|
1201
|
+
{
|
|
1202
|
+
direction: "row",
|
|
1203
|
+
justify: "between",
|
|
1204
|
+
itemAlign: "stretch",
|
|
1205
|
+
width: "100%",
|
|
1206
|
+
children: [
|
|
1207
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1208
|
+
MobileCellItem,
|
|
1209
|
+
{
|
|
1210
|
+
title: t("affiliate.referralCode"),
|
|
1211
|
+
value: data.code,
|
|
1212
|
+
copyable: true,
|
|
1213
|
+
onCopy: () => {
|
|
1214
|
+
props.copyCode?.(data.code);
|
|
1215
|
+
},
|
|
1216
|
+
editRate: () => {
|
|
1217
|
+
editCode(data);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
),
|
|
1221
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1222
|
+
MobileCellItem,
|
|
1223
|
+
{
|
|
1224
|
+
title: t("affiliate.referralCodes.column.you&Referee"),
|
|
1225
|
+
value: getRate(data),
|
|
1226
|
+
align: "end",
|
|
1227
|
+
editRate: () => {
|
|
1228
|
+
editRate(data);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
),
|
|
1232
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1233
|
+
MobileCellItem,
|
|
1234
|
+
{
|
|
1235
|
+
title: t("affiliate.referralCodes.column.referees&Traders"),
|
|
1236
|
+
value: getCount(data),
|
|
1237
|
+
align: "end",
|
|
1238
|
+
className: "oui-hidden md:oui-flex"
|
|
1239
|
+
}
|
|
1240
|
+
)
|
|
1241
|
+
]
|
|
1242
|
+
}
|
|
1243
|
+
),
|
|
1244
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1245
|
+
orderlyUi.Flex,
|
|
1246
|
+
{
|
|
1247
|
+
direction: "row",
|
|
1248
|
+
justify: "between",
|
|
1249
|
+
itemAlign: "stretch",
|
|
1250
|
+
width: "100%",
|
|
1251
|
+
className: "md:oui-hidden",
|
|
1252
|
+
children: [
|
|
1253
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1254
|
+
MobileCellItem,
|
|
1255
|
+
{
|
|
1256
|
+
title: t("affiliate.referees"),
|
|
1257
|
+
value: getCount(data).split("/")?.[0],
|
|
1258
|
+
align: "start"
|
|
1259
|
+
}
|
|
1260
|
+
),
|
|
1261
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1262
|
+
MobileCellItem,
|
|
1263
|
+
{
|
|
1264
|
+
title: t("affiliate.referralCodes.column.traders"),
|
|
1265
|
+
value: getCount(data).split("/")?.[1],
|
|
1266
|
+
align: "end"
|
|
1267
|
+
}
|
|
1268
|
+
)
|
|
1269
|
+
]
|
|
1270
|
+
}
|
|
1271
|
+
),
|
|
1272
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1273
|
+
orderlyUi.Flex,
|
|
1274
|
+
{
|
|
1275
|
+
direction: "row",
|
|
1276
|
+
justify: "between",
|
|
1277
|
+
itemAlign: "stretch",
|
|
1278
|
+
width: "100%",
|
|
1279
|
+
children: [
|
|
1280
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1281
|
+
PinBtn,
|
|
1282
|
+
{
|
|
1283
|
+
pinned: data.isPined || false,
|
|
1284
|
+
onClick: (e) => {
|
|
1285
|
+
setPinCode(data.code, !e);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
),
|
|
1289
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1290
|
+
orderlyUi.Button,
|
|
1291
|
+
{
|
|
1292
|
+
variant: "outlined",
|
|
1293
|
+
size: "xs",
|
|
1294
|
+
className: "oui-px-[20px]",
|
|
1295
|
+
onClick: (e) => {
|
|
1296
|
+
copyLink(data.code);
|
|
1297
|
+
},
|
|
1298
|
+
children: t("affiliate.referralCodes.copyLink")
|
|
1299
|
+
}
|
|
1300
|
+
)
|
|
1301
|
+
]
|
|
1302
|
+
}
|
|
1303
|
+
)
|
|
1304
|
+
] }, data.code);
|
|
1305
|
+
};
|
|
1306
|
+
var DesktopLayout = (props) => {
|
|
1307
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1308
|
+
const moreColumn = orderlyHooks.useMediaQuery("(min-width: 1024px)");
|
|
1309
|
+
const columns = react.useMemo(() => {
|
|
1310
|
+
const cols = [
|
|
1311
|
+
{
|
|
1312
|
+
title: t("affiliate.referralCode"),
|
|
1313
|
+
dataIndex: "code",
|
|
1314
|
+
width: moreColumn ? 115 : 120,
|
|
1315
|
+
className: "!oui-px-0",
|
|
1316
|
+
render: (value, data) => {
|
|
1317
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", itemAlign: "center", gap: 1, children: [
|
|
1318
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1319
|
+
PinBtn,
|
|
1320
|
+
{
|
|
1321
|
+
size: 12,
|
|
1322
|
+
pinned: data.isPined || false,
|
|
1323
|
+
onClick: (e) => {
|
|
1324
|
+
props.setPinCode(data.code, !e);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
),
|
|
1328
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1329
|
+
orderlyUi.Text.formatted,
|
|
1330
|
+
{
|
|
1331
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1332
|
+
data.isAutoGenerated && data.total_invites < 1 && /* @__PURE__ */ jsxRuntime.jsx(EditCode, { onClick: () => props.editCode?.(data) }),
|
|
1333
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1334
|
+
orderlyUi.CopyIcon,
|
|
1335
|
+
{
|
|
1336
|
+
className: "oui-cursor-pointer",
|
|
1337
|
+
size: 12,
|
|
1338
|
+
color: "white",
|
|
1339
|
+
onClick: () => props.copyCode?.(data.code)
|
|
1340
|
+
}
|
|
1341
|
+
)
|
|
1342
|
+
] }),
|
|
1343
|
+
copyable: true,
|
|
1344
|
+
onCopy: () => {
|
|
1345
|
+
props.copyCode?.(data.code);
|
|
1346
|
+
},
|
|
1347
|
+
children: value
|
|
1348
|
+
}
|
|
1349
|
+
)
|
|
1350
|
+
] });
|
|
1351
|
+
}
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
title: t("affiliate.referralCodes.column.you&Referee"),
|
|
1355
|
+
dataIndex: "dffd",
|
|
1356
|
+
width: moreColumn ? 120 : 120,
|
|
1357
|
+
className: "oui-pr-0",
|
|
1358
|
+
render: (value, data) => {
|
|
1359
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", itemAlign: "center", gap: 1, children: [
|
|
1360
|
+
getRate(data),
|
|
1361
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1362
|
+
EditIcon,
|
|
1363
|
+
{
|
|
1364
|
+
className: "oui-mt-[6px] oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",
|
|
1365
|
+
fillOpacity: 1,
|
|
1366
|
+
fill: "currentColor",
|
|
1367
|
+
onClick: (e) => props.editRate?.(data)
|
|
1368
|
+
}
|
|
1369
|
+
)
|
|
1370
|
+
] });
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
];
|
|
1374
|
+
if (moreColumn) {
|
|
1375
|
+
cols.push({
|
|
1376
|
+
title: t("affiliate.referees"),
|
|
1377
|
+
dataIndex: "referee_rebate_rate",
|
|
1378
|
+
width: 65,
|
|
1379
|
+
className: "oui-pr-0",
|
|
1380
|
+
render: (value, data) => getCount(data).split("/")[0]
|
|
1381
|
+
});
|
|
1382
|
+
cols.push({
|
|
1383
|
+
title: t("affiliate.referralCodes.column.traders"),
|
|
1384
|
+
dataIndex: "referrer_rebate_rate",
|
|
1385
|
+
width: 65,
|
|
1386
|
+
className: "oui-pr-0",
|
|
1387
|
+
render: (value, data) => getCount(data).split("/")[1]
|
|
1388
|
+
});
|
|
1389
|
+
} else {
|
|
1390
|
+
cols.push({
|
|
1391
|
+
title: t("affiliate.referralCodes.column.referees&Traders"),
|
|
1392
|
+
dataIndex: "total_invites/total_traded",
|
|
1393
|
+
width: 120,
|
|
1394
|
+
fixed: "left",
|
|
1395
|
+
render: (value, data) => getCount(data)
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
cols.push({
|
|
1399
|
+
dataIndex: "link",
|
|
1400
|
+
align: "right",
|
|
1401
|
+
width: 74,
|
|
1402
|
+
className: "!oui-px-0",
|
|
1403
|
+
render: (value, data) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1404
|
+
orderlyUi.Button,
|
|
1405
|
+
{
|
|
1406
|
+
variant: "outlined",
|
|
1407
|
+
size: "sm",
|
|
1408
|
+
className: "oui-px-5",
|
|
1409
|
+
onClick: (e) => {
|
|
1410
|
+
props?.copyLink?.(data.code);
|
|
1411
|
+
},
|
|
1412
|
+
children: t("affiliate.referralCodes.copyLink")
|
|
1413
|
+
}
|
|
1414
|
+
)
|
|
1415
|
+
});
|
|
1416
|
+
return cols;
|
|
1417
|
+
}, [moreColumn, t]);
|
|
1418
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1419
|
+
orderlyUi.DataTable,
|
|
1420
|
+
{
|
|
1421
|
+
bordered: true,
|
|
1422
|
+
columns,
|
|
1423
|
+
dataSource: props.codes,
|
|
1424
|
+
classNames: {
|
|
1425
|
+
header: "oui-px-0",
|
|
1426
|
+
root: "2xl:oui-flex-1 2xl:oui-max-h-[230px] 3xl:oui-max-h-[300px]"
|
|
1427
|
+
},
|
|
1428
|
+
onRow: (record) => {
|
|
1429
|
+
return {
|
|
1430
|
+
className: "oui-h-[45px]"
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
);
|
|
1435
|
+
};
|
|
1436
|
+
var getRate = (item) => {
|
|
1437
|
+
const refereeRate = new orderlyUtils.Decimal(item.referee_rebate_rate).mul(100).toFixed(1, orderlyUtils.Decimal.ROUND_DOWN).toString();
|
|
1438
|
+
const referralRate = new orderlyUtils.Decimal(item.referrer_rebate_rate).mul(100).toFixed(1, orderlyUtils.Decimal.ROUND_DOWN).toString();
|
|
1439
|
+
return `${referralRate}% / ${refereeRate}%`;
|
|
1440
|
+
};
|
|
1441
|
+
var getCount = (item) => {
|
|
1442
|
+
return `${item.total_invites} / ${item.total_traded}`;
|
|
1443
|
+
};
|
|
1444
|
+
var EditCodeModal = orderlyUi.modal.create((props) => {
|
|
1445
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1446
|
+
const { visible, onOpenChange } = orderlyUi.useModal();
|
|
1447
|
+
const [newCode, setNewCode] = react.useState("");
|
|
1448
|
+
const [filedError, setFiledError] = react.useState({
|
|
1449
|
+
length: false,
|
|
1450
|
+
format: false
|
|
1451
|
+
});
|
|
1452
|
+
const [editCode, { error, isMutating }] = orderlyHooks.useMutation(
|
|
1453
|
+
"/v1/referral/edit_referral_code",
|
|
1454
|
+
"POST"
|
|
1455
|
+
);
|
|
1456
|
+
react.useEffect(() => {
|
|
1457
|
+
setNewCode(props.code.code);
|
|
1458
|
+
}, [props.code]);
|
|
1459
|
+
react.useEffect(() => {
|
|
1460
|
+
const _code = newCode.toUpperCase();
|
|
1461
|
+
const _fieldError = {
|
|
1462
|
+
length: false,
|
|
1463
|
+
format: false
|
|
1464
|
+
};
|
|
1465
|
+
if (_code.length < 4 || _code.length > 10) {
|
|
1466
|
+
_fieldError.length = true;
|
|
1467
|
+
}
|
|
1468
|
+
if (!/^[A-Z0-9]+$/.test(_code)) {
|
|
1469
|
+
_fieldError.format = true;
|
|
1470
|
+
}
|
|
1471
|
+
setFiledError(_fieldError);
|
|
1472
|
+
}, [newCode]);
|
|
1473
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1474
|
+
orderlyUi.SimpleDialog,
|
|
1475
|
+
{
|
|
1476
|
+
classNames: {
|
|
1477
|
+
content: "oui-max-w-[360px]"
|
|
1478
|
+
},
|
|
1479
|
+
title: /* @__PURE__ */ jsxRuntime.jsx("div", { children: t("affiliate.referralCode.editCodeModal.title") }),
|
|
1480
|
+
open: visible,
|
|
1481
|
+
onOpenChange,
|
|
1482
|
+
actions: {
|
|
1483
|
+
primary: {
|
|
1484
|
+
loading: isMutating,
|
|
1485
|
+
disabled: filedError.length || filedError.format,
|
|
1486
|
+
label: t("common.confirm"),
|
|
1487
|
+
onClick: async () => {
|
|
1488
|
+
try {
|
|
1489
|
+
const res = await editCode({
|
|
1490
|
+
current_referral_code: props.code.code,
|
|
1491
|
+
new_referral_code: newCode.toUpperCase()
|
|
1492
|
+
});
|
|
1493
|
+
if (res.success) {
|
|
1494
|
+
orderlyUi.toast.success(
|
|
1495
|
+
t("affiliate.referralCode.editCodeModal.success")
|
|
1496
|
+
);
|
|
1497
|
+
props.successCallback();
|
|
1498
|
+
onOpenChange(false);
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
orderlyUi.toast.error(res.message);
|
|
1502
|
+
} catch (e) {
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
},
|
|
1507
|
+
children: [
|
|
1508
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-mb-6 oui-text-xs oui-text-base-contrast-54", children: t("affiliate.referralCode.editCodeModal.description") }),
|
|
1509
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1510
|
+
orderlyUi.TextField,
|
|
1511
|
+
{
|
|
1512
|
+
placeholder: "",
|
|
1513
|
+
fullWidth: true,
|
|
1514
|
+
label: t("affiliate.referralCode.editCodeModal.label"),
|
|
1515
|
+
onClean: () => {
|
|
1516
|
+
setNewCode("");
|
|
1517
|
+
},
|
|
1518
|
+
value: newCode,
|
|
1519
|
+
onChange: (e) => {
|
|
1520
|
+
const _value = e.target.value.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
1521
|
+
setNewCode(_value);
|
|
1522
|
+
},
|
|
1523
|
+
formatters: [
|
|
1524
|
+
orderlyUi.inputFormatter.createRegexInputFormatter((value) => {
|
|
1525
|
+
return String(value).replace(
|
|
1526
|
+
/[a-z]/g,
|
|
1527
|
+
(char) => char.toUpperCase()
|
|
1528
|
+
);
|
|
1529
|
+
}),
|
|
1530
|
+
orderlyUi.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)
|
|
1531
|
+
],
|
|
1532
|
+
classNames: {
|
|
1533
|
+
label: "oui-text-base-contrast-54 oui-text-xs",
|
|
1534
|
+
input: "placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"
|
|
1535
|
+
},
|
|
1536
|
+
maxLength: 10,
|
|
1537
|
+
minLength: 4,
|
|
1538
|
+
autoComplete: "off",
|
|
1539
|
+
helpText: ""
|
|
1540
|
+
}
|
|
1541
|
+
),
|
|
1542
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1543
|
+
orderlyUi.Flex,
|
|
1544
|
+
{
|
|
1545
|
+
direction: "column",
|
|
1546
|
+
justify: "center",
|
|
1547
|
+
itemAlign: "start",
|
|
1548
|
+
gap: 1,
|
|
1549
|
+
className: "oui-mt-3",
|
|
1550
|
+
children: [
|
|
1551
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1552
|
+
orderlyUi.Text,
|
|
1553
|
+
{
|
|
1554
|
+
className: orderlyUi.cn(
|
|
1555
|
+
"oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs",
|
|
1556
|
+
filedError.length ? "oui-text-danger" : "oui-text-success"
|
|
1557
|
+
),
|
|
1558
|
+
children: t("affiliate.referralCode.editCodeModal.helpText.length")
|
|
1559
|
+
}
|
|
1560
|
+
),
|
|
1561
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1562
|
+
orderlyUi.Text,
|
|
1563
|
+
{
|
|
1564
|
+
className: orderlyUi.cn(
|
|
1565
|
+
"oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs",
|
|
1566
|
+
"oui-text-success"
|
|
1567
|
+
),
|
|
1568
|
+
children: t("affiliate.referralCode.editCodeModal.helpText.format")
|
|
1569
|
+
}
|
|
1570
|
+
)
|
|
1571
|
+
]
|
|
1572
|
+
}
|
|
1573
|
+
)
|
|
1574
|
+
]
|
|
1575
|
+
}
|
|
1576
|
+
);
|
|
1577
|
+
});
|
|
1578
|
+
var EditReferralRate = orderlyUi.modal.create((props) => {
|
|
1579
|
+
const { code, mutate } = props;
|
|
1580
|
+
const { visible, hide, resolve, reject, onOpenChange } = orderlyUi.useModal();
|
|
1581
|
+
const maxRate = new orderlyUtils.Decimal(code.max_rebate_rate).mul(100);
|
|
1582
|
+
const [refereeRebateRate, setRefereeRebateRate] = react.useState(
|
|
1583
|
+
`${new orderlyUtils.Decimal(code.referee_rebate_rate).mul(100)}`
|
|
1584
|
+
);
|
|
1585
|
+
const [referrerRebateRate, setReferrerRebateRate] = react.useState(
|
|
1586
|
+
`${new orderlyUtils.Decimal(code.referrer_rebate_rate).mul(100)}`
|
|
1587
|
+
);
|
|
1588
|
+
const [showError, setShowError] = react.useState(false);
|
|
1589
|
+
const inputRef = react.useRef(null);
|
|
1590
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1591
|
+
react.useEffect(() => {
|
|
1592
|
+
if (inputRef?.current) {
|
|
1593
|
+
inputRef.current.focus();
|
|
1594
|
+
inputRef.current.setSelectionRange(
|
|
1595
|
+
inputRef.current.value.length,
|
|
1596
|
+
inputRef.current.value.length
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
}, [inputRef]);
|
|
1600
|
+
react.useEffect(() => {
|
|
1601
|
+
setRefereeRebateRate(`${new orderlyUtils.Decimal(code.referee_rebate_rate).mul(100)}`);
|
|
1602
|
+
setReferrerRebateRate(`${new orderlyUtils.Decimal(code.referrer_rebate_rate).mul(100)}`);
|
|
1603
|
+
}, [code]);
|
|
1604
|
+
const [editRate, { error, isMutating }] = orderlyHooks.useMutation(
|
|
1605
|
+
"/v1/referral/edit_split",
|
|
1606
|
+
"POST"
|
|
1607
|
+
);
|
|
1608
|
+
const onClickConfirm = async () => {
|
|
1609
|
+
try {
|
|
1610
|
+
const r1 = Number.parseFloat(refereeRebateRate);
|
|
1611
|
+
const r2 = Number.parseFloat(referrerRebateRate);
|
|
1612
|
+
await editRate({
|
|
1613
|
+
referral_code: code.code,
|
|
1614
|
+
referee_rebate_rate: r1 / 100,
|
|
1615
|
+
referrer_rebate_rate: r2 / 100
|
|
1616
|
+
});
|
|
1617
|
+
orderlyUi.toast.success(t("affiliate.referralRate.editRateModal.success"));
|
|
1618
|
+
mutate();
|
|
1619
|
+
hide();
|
|
1620
|
+
} catch (e) {
|
|
1621
|
+
orderlyUi.toast.error(e?.message || e || "");
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1624
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Dialog, { open: visible, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1625
|
+
orderlyUi.DialogContent,
|
|
1626
|
+
{
|
|
1627
|
+
className: "oui-px-6 oui-max-w-[320px] oui-bg-base-8 oui-shadow-[0px_12px_20px_0px_rgba(0,0,0,0.25)]",
|
|
1628
|
+
closable: true,
|
|
1629
|
+
children: [
|
|
1630
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.DialogTitle, { children: [
|
|
1631
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-my-3", children: t("affiliate.referralRate.editRateModal.title") }),
|
|
1632
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Divider, {})
|
|
1633
|
+
] }),
|
|
1634
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-mt-3 oui-h-full oui-flex oui-flex-col oui-justify-end", children: [
|
|
1635
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-xs oui-text-base-contrast-54", children: t("affiliate.referralRate.editRateModal.description") }),
|
|
1636
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-text-base-contrast-80 oui-mt-2 oui-flex", children: [
|
|
1637
|
+
t("affiliate.referralRate.editRateModal.label"),
|
|
1638
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-warning-darken oui-pl-1", children: `${new orderlyUtils.Decimal(
|
|
1639
|
+
code.max_rebate_rate
|
|
1640
|
+
).mul(100).toFixed(0, orderlyUtils.Decimal.ROUND_DOWN)}%` })
|
|
1641
|
+
] }),
|
|
1642
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-2xs oui-mt-6 oui-text-base-contrast-80", children: t("affiliate.referralRate.editRateModal.label.you") }),
|
|
1643
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1644
|
+
orderlyUi.Input,
|
|
1645
|
+
{
|
|
1646
|
+
ref: inputRef,
|
|
1647
|
+
containerClassName: "oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",
|
|
1648
|
+
placeholder: "Enter code",
|
|
1649
|
+
type: "text",
|
|
1650
|
+
inputMode: "decimal",
|
|
1651
|
+
autoComplete: "off",
|
|
1652
|
+
value: referrerRebateRate,
|
|
1653
|
+
onChange: (e) => {
|
|
1654
|
+
const text = orderlyHooks.cleanStringStyle(e.target.value);
|
|
1655
|
+
const rate = Number.parseFloat(text);
|
|
1656
|
+
setReferrerRebateRate(text);
|
|
1657
|
+
if (!Number.isNaN(rate)) {
|
|
1658
|
+
setRefereeRebateRate(
|
|
1659
|
+
`${maxDecimal(new orderlyUtils.Decimal(0), maxRate.sub(rate))}`
|
|
1660
|
+
);
|
|
1661
|
+
setShowError(maxRate.sub(rate) < new orderlyUtils.Decimal(0));
|
|
1662
|
+
} else {
|
|
1663
|
+
setRefereeRebateRate("");
|
|
1664
|
+
setReferrerRebateRate("");
|
|
1665
|
+
}
|
|
1666
|
+
},
|
|
1667
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-px-3 oui-text-base-contrast-54 oui-text-base", children: "%" }),
|
|
1668
|
+
color: showError ? "danger" : void 0
|
|
1669
|
+
}
|
|
1670
|
+
),
|
|
1671
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-2xs oui-mt-6 oui-text-base-contrast-80", children: t("affiliate.referralRate.editRateModal.label.referee") }),
|
|
1672
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1673
|
+
orderlyUi.Input,
|
|
1674
|
+
{
|
|
1675
|
+
containerClassName: "oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",
|
|
1676
|
+
placeholder: "Enter code",
|
|
1677
|
+
type: "text",
|
|
1678
|
+
inputMode: "decimal",
|
|
1679
|
+
autoComplete: "off",
|
|
1680
|
+
autoFocus: false,
|
|
1681
|
+
value: refereeRebateRate,
|
|
1682
|
+
onChange: (e) => {
|
|
1683
|
+
const text = orderlyHooks.cleanStringStyle(e.target.value);
|
|
1684
|
+
const rate = Number.parseFloat(text);
|
|
1685
|
+
setRefereeRebateRate(text);
|
|
1686
|
+
if (!Number.isNaN(rate)) {
|
|
1687
|
+
setReferrerRebateRate(
|
|
1688
|
+
`${maxDecimal(new orderlyUtils.Decimal(0), maxRate.sub(rate))}`
|
|
1689
|
+
);
|
|
1690
|
+
setShowError(maxRate.sub(rate) < new orderlyUtils.Decimal(0));
|
|
1691
|
+
} else {
|
|
1692
|
+
setRefereeRebateRate("");
|
|
1693
|
+
setReferrerRebateRate("");
|
|
1694
|
+
}
|
|
1695
|
+
},
|
|
1696
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-px-3 oui-text-base-contrast-54 oui-text-base", children: "%" }),
|
|
1697
|
+
color: showError ? "danger" : void 0
|
|
1698
|
+
}
|
|
1699
|
+
),
|
|
1700
|
+
showError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-danger oui-text-xs oui-mt-8 oui-text-center oui-px-4", children: t("affiliate.referralRate.editRateModal.helpText.max") }),
|
|
1701
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { width: "100%", justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1702
|
+
orderlyUi.Button,
|
|
1703
|
+
{
|
|
1704
|
+
id: "referral_bind_referral_code_btn",
|
|
1705
|
+
disabled: refereeRebateRate.length === 0 || referrerRebateRate.length === 0 || showError,
|
|
1706
|
+
loading: isMutating,
|
|
1707
|
+
className: orderlyUi.cn(
|
|
1708
|
+
"oui-mt-8 oui-mb-4 oui-w-[154px]",
|
|
1709
|
+
showError && "oui-mt-3"
|
|
1710
|
+
),
|
|
1711
|
+
onClick: (e) => {
|
|
1712
|
+
e.stopPropagation();
|
|
1713
|
+
onClickConfirm();
|
|
1714
|
+
},
|
|
1715
|
+
children: t("common.confirm")
|
|
1716
|
+
}
|
|
1717
|
+
) })
|
|
1718
|
+
] })
|
|
1719
|
+
]
|
|
1720
|
+
}
|
|
1721
|
+
) });
|
|
1722
|
+
});
|
|
1723
|
+
function maxDecimal(a, b) {
|
|
1724
|
+
return a > b ? a : b;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
// src/pages/affiliate/referralCodes/referralCodes.script.tsx
|
|
1728
|
+
var useReferralCodesScript = () => {
|
|
1729
|
+
const { referralInfo, referralLinkUrl, mutate, generateCode } = useReferralContext();
|
|
1730
|
+
const copyLink = (code) => {
|
|
1731
|
+
copyText(generateReferralLink(referralLinkUrl, code));
|
|
1732
|
+
};
|
|
1733
|
+
const copyCode = (code) => {
|
|
1734
|
+
copyText(code);
|
|
1735
|
+
};
|
|
1736
|
+
const editRate = (code) => {
|
|
1737
|
+
orderlyUi.modal.show(EditReferralRate, { code: { ...code }, mutate });
|
|
1738
|
+
};
|
|
1739
|
+
const editCode = (code) => {
|
|
1740
|
+
orderlyUi.modal.show(EditCodeModal, {
|
|
1741
|
+
code: { ...code },
|
|
1742
|
+
successCallback: () => {
|
|
1743
|
+
mutate();
|
|
1744
|
+
}
|
|
1745
|
+
});
|
|
1746
|
+
};
|
|
1747
|
+
const [pinCodes, setPinCodes] = orderlyHooks.useLocalStorage(
|
|
1748
|
+
"orderly_referral_codes",
|
|
1749
|
+
[]
|
|
1750
|
+
);
|
|
1751
|
+
const setPinCode = (code, del) => {
|
|
1752
|
+
if (del) {
|
|
1753
|
+
const index = pinCodes.findIndex((item) => item === code);
|
|
1754
|
+
if (index !== -1) {
|
|
1755
|
+
pinCodes.splice(index, 1);
|
|
1756
|
+
}
|
|
1757
|
+
} else {
|
|
1758
|
+
pinCodes.splice(0, 0, code);
|
|
1759
|
+
}
|
|
1760
|
+
if (pinCodes.length > 6) {
|
|
1761
|
+
pinCodes.splice(pinCodes.length - 1, 1);
|
|
1762
|
+
}
|
|
1763
|
+
setPinCodes([...pinCodes]);
|
|
1764
|
+
};
|
|
1765
|
+
const codes = react.useMemo(() => {
|
|
1766
|
+
if (!referralInfo?.referrer_info?.referral_codes) {
|
|
1767
|
+
return void 0;
|
|
1768
|
+
}
|
|
1769
|
+
const referralCodes = referralInfo?.referrer_info?.referral_codes?.map((item) => {
|
|
1770
|
+
if (generateCode && generateCode.code === item.code) {
|
|
1771
|
+
item.isAutoGenerated = true;
|
|
1772
|
+
}
|
|
1773
|
+
return item;
|
|
1774
|
+
});
|
|
1775
|
+
const pinedItems = [];
|
|
1776
|
+
for (let i = 0; i < pinCodes.length; i++) {
|
|
1777
|
+
const code = pinCodes[i];
|
|
1778
|
+
const index = referralCodes.findIndex((item) => item.code === code);
|
|
1779
|
+
if (index !== -1) {
|
|
1780
|
+
pinedItems.push({ ...referralCodes[index], isPined: true });
|
|
1781
|
+
referralCodes.splice(index, 1);
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
return [...pinedItems, ...referralCodes];
|
|
1785
|
+
}, [referralInfo?.referrer_info?.referral_codes, pinCodes, generateCode]);
|
|
1786
|
+
return {
|
|
1787
|
+
copyCode,
|
|
1788
|
+
copyLink,
|
|
1789
|
+
editRate,
|
|
1790
|
+
editCode,
|
|
1791
|
+
setPinCode,
|
|
1792
|
+
codes
|
|
1793
|
+
};
|
|
1794
|
+
};
|
|
1795
|
+
var ReferralCodesWidget = () => {
|
|
1796
|
+
const state = useReferralCodesScript();
|
|
1797
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReferralCodes, { ...state });
|
|
1798
|
+
};
|
|
1799
|
+
var CommissionAndReferees = (props) => {
|
|
1800
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1801
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1802
|
+
orderlyUi.Flex,
|
|
1803
|
+
{
|
|
1804
|
+
id: "oui-affiliate-affiliate-commissionAndReferees",
|
|
1805
|
+
r: "2xl",
|
|
1806
|
+
p: 6,
|
|
1807
|
+
width: "100%",
|
|
1808
|
+
gap: 4,
|
|
1809
|
+
direction: "column",
|
|
1810
|
+
className: "oui-bg-base-9 oui-tabular-nums",
|
|
1811
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Tabs, { defaultValue: "account", className: "oui-w-full", variant: "contained", children: [
|
|
1812
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.TabPanel, { value: "account", title: t("affiliate.commission"), children: /* @__PURE__ */ jsxRuntime.jsx(CommissionList, { ...props }) }),
|
|
1813
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.TabPanel, { value: "password", title: t("affiliate.myReferees"), children: /* @__PURE__ */ jsxRuntime.jsx(RefereesList, { ...props }) })
|
|
1814
|
+
] })
|
|
1815
|
+
}
|
|
1816
|
+
);
|
|
1817
|
+
};
|
|
1818
|
+
var MobileCellItem2 = (props) => {
|
|
1819
|
+
const { title, value, align, className, rule, formatString, prefix } = props;
|
|
1820
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1821
|
+
orderlyUi.Statistic,
|
|
1822
|
+
{
|
|
1823
|
+
className: orderlyUi.cn("oui-flex-1", className),
|
|
1824
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-base-contrast-36 oui-text-2xs", children: title }),
|
|
1825
|
+
align,
|
|
1826
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1827
|
+
orderlyUi.Text.formatted,
|
|
1828
|
+
{
|
|
1829
|
+
rule: rule || "",
|
|
1830
|
+
formatString,
|
|
1831
|
+
prefix,
|
|
1832
|
+
className: "oui-text-base-contrast-80 oui-text-sm oui-mt-[6px]",
|
|
1833
|
+
children: value
|
|
1834
|
+
}
|
|
1835
|
+
)
|
|
1836
|
+
}
|
|
1837
|
+
);
|
|
1838
|
+
};
|
|
1839
|
+
var CommissionList = (props) => {
|
|
1840
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1841
|
+
const isLG = orderlyHooks.useMediaQuery("(max-width: 767px)");
|
|
1842
|
+
const columns = react.useMemo(() => {
|
|
1843
|
+
const cols = [
|
|
1844
|
+
{
|
|
1845
|
+
title: `${t("affiliate.commission")} (USDC)`,
|
|
1846
|
+
dataIndex: "referral_rebate",
|
|
1847
|
+
render: (value) => /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: orderlyUtils.commifyOptional(value, {
|
|
1848
|
+
fix: 6,
|
|
1849
|
+
fallback: "0",
|
|
1850
|
+
padEnd: true,
|
|
1851
|
+
prefix: "$"
|
|
1852
|
+
}) }),
|
|
1853
|
+
width: 216
|
|
1854
|
+
},
|
|
1855
|
+
{
|
|
1856
|
+
title: `${t("affiliate.referralVol")} (USDC)`,
|
|
1857
|
+
dataIndex: "volume",
|
|
1858
|
+
render: (value) => /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: orderlyUtils.commifyOptional(value, {
|
|
1859
|
+
fix: 2,
|
|
1860
|
+
fallback: "0",
|
|
1861
|
+
padEnd: true,
|
|
1862
|
+
prefix: "$"
|
|
1863
|
+
}) }),
|
|
1864
|
+
width: 216
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
title: t("affiliate.commission.column.activeUsers"),
|
|
1868
|
+
dataIndex: "daily_traded_referral",
|
|
1869
|
+
render: (value) => /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: value }),
|
|
1870
|
+
width: 216
|
|
1871
|
+
},
|
|
1872
|
+
{
|
|
1873
|
+
title: t("common.date"),
|
|
1874
|
+
dataIndex: "date",
|
|
1875
|
+
render: (value) => formatYMDTime(value),
|
|
1876
|
+
width: 216
|
|
1877
|
+
}
|
|
1878
|
+
];
|
|
1879
|
+
return cols;
|
|
1880
|
+
}, [t]);
|
|
1881
|
+
const body = react.useMemo(() => {
|
|
1882
|
+
if (isLG) {
|
|
1883
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1884
|
+
orderlyUi.ListView,
|
|
1885
|
+
{
|
|
1886
|
+
className: "oui-max-h-[200px] oui-w-full",
|
|
1887
|
+
dataSource: props.commission.data,
|
|
1888
|
+
loadMore: props.commission.loadMore,
|
|
1889
|
+
isLoading: props.commission.isLoading,
|
|
1890
|
+
renderItem: (e) => {
|
|
1891
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1892
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", width: "100%", children: [
|
|
1893
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1894
|
+
MobileCellItem2,
|
|
1895
|
+
{
|
|
1896
|
+
title: t("affiliate.commission"),
|
|
1897
|
+
value: orderlyUtils.commifyOptional(e.referral_rebate, {
|
|
1898
|
+
fix: 6,
|
|
1899
|
+
fallback: "0",
|
|
1900
|
+
padEnd: true
|
|
1901
|
+
}),
|
|
1902
|
+
prefix: "$"
|
|
1903
|
+
}
|
|
1904
|
+
),
|
|
1905
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1906
|
+
MobileCellItem2,
|
|
1907
|
+
{
|
|
1908
|
+
title: t("affiliate.referralVol"),
|
|
1909
|
+
value: orderlyUtils.commifyOptional(e.volume, {
|
|
1910
|
+
fix: 2,
|
|
1911
|
+
fallback: "0",
|
|
1912
|
+
padEnd: true
|
|
1913
|
+
}),
|
|
1914
|
+
prefix: "$"
|
|
1915
|
+
}
|
|
1916
|
+
),
|
|
1917
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1918
|
+
MobileCellItem2,
|
|
1919
|
+
{
|
|
1920
|
+
title: t("affiliate.commission.column.activeUsers"),
|
|
1921
|
+
value: e.daily_traded_referral
|
|
1922
|
+
}
|
|
1923
|
+
),
|
|
1924
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1925
|
+
MobileCellItem2,
|
|
1926
|
+
{
|
|
1927
|
+
title: t("common.date"),
|
|
1928
|
+
value: e.date,
|
|
1929
|
+
rule: "date",
|
|
1930
|
+
formatString: "yyyy-MM-dd",
|
|
1931
|
+
align: "end"
|
|
1932
|
+
}
|
|
1933
|
+
)
|
|
1934
|
+
] }),
|
|
1935
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Divider, { className: "oui-mt-3 oui-w-full" })
|
|
1936
|
+
] });
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
);
|
|
1940
|
+
}
|
|
1941
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1942
|
+
orderlyUiConnector.AuthGuardDataTable,
|
|
1943
|
+
{
|
|
1944
|
+
bordered: true,
|
|
1945
|
+
columns,
|
|
1946
|
+
loading: props.commission.isLoading,
|
|
1947
|
+
ignoreLoadingCheck: true,
|
|
1948
|
+
dataSource: props.commission.data,
|
|
1949
|
+
pagination: props.commission.pagination,
|
|
1950
|
+
onRow: (record) => {
|
|
1951
|
+
return {
|
|
1952
|
+
className: "oui-h-[41px]"
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
);
|
|
1957
|
+
}, [isLG, props.commission]);
|
|
1958
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1959
|
+
orderlyUi.Flex,
|
|
1960
|
+
{
|
|
1961
|
+
direction: "column",
|
|
1962
|
+
width: "100%",
|
|
1963
|
+
justify: "start",
|
|
1964
|
+
itemAlign: "start",
|
|
1965
|
+
children: [
|
|
1966
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1967
|
+
DateFiler,
|
|
1968
|
+
{
|
|
1969
|
+
value: props.commission.dateRange,
|
|
1970
|
+
setValue: props.commission.setDateRange
|
|
1971
|
+
}
|
|
1972
|
+
),
|
|
1973
|
+
body
|
|
1974
|
+
]
|
|
1975
|
+
}
|
|
1976
|
+
);
|
|
1977
|
+
};
|
|
1978
|
+
var RefereesList = (props) => {
|
|
1979
|
+
const { t } = orderlyI18n.useTranslation();
|
|
1980
|
+
const isLG = orderlyHooks.useMediaQuery("(max-width: 767px)");
|
|
1981
|
+
const columns = react.useMemo(() => {
|
|
1982
|
+
const cols = [
|
|
1983
|
+
{
|
|
1984
|
+
title: t("affiliate.referees.column.refereeAddress"),
|
|
1985
|
+
dataIndex: "user_address",
|
|
1986
|
+
render: (value) => /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.formatted, { rule: "address", children: value }),
|
|
1987
|
+
className: "oui-w-1/5"
|
|
1988
|
+
},
|
|
1989
|
+
{
|
|
1990
|
+
title: t("affiliate.referralCode"),
|
|
1991
|
+
dataIndex: "referral_code",
|
|
1992
|
+
// render: (value) => value,
|
|
1993
|
+
className: "oui-w-1/5"
|
|
1994
|
+
},
|
|
1995
|
+
{
|
|
1996
|
+
title: `${t("affiliate.referees.column.totalCommission")} (USDC)`,
|
|
1997
|
+
dataIndex: "referral_rebate",
|
|
1998
|
+
render: (value) => /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: orderlyUtils.commifyOptional(value, { fix: 6, prefix: "$", padEnd: true }) }),
|
|
1999
|
+
className: "oui-w-1/5"
|
|
2000
|
+
},
|
|
2001
|
+
{
|
|
2002
|
+
title: `${t("affiliate.referees.column.totalVol")} (USDC)`,
|
|
2003
|
+
dataIndex: "volume",
|
|
2004
|
+
render: (value) => /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: orderlyUtils.commifyOptional(value, { fix: 2, prefix: "$", padEnd: true }) }),
|
|
2005
|
+
className: "oui-w-1/5"
|
|
2006
|
+
},
|
|
2007
|
+
{
|
|
2008
|
+
title: t("affiliate.referees.column.invitationTime"),
|
|
2009
|
+
dataIndex: "code_binding_time",
|
|
2010
|
+
render: (value) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2011
|
+
orderlyUi.Text.formatted,
|
|
2012
|
+
{
|
|
2013
|
+
rule: "date",
|
|
2014
|
+
formatString: "yyyy-MM-dd",
|
|
2015
|
+
children: value
|
|
2016
|
+
}
|
|
2017
|
+
),
|
|
2018
|
+
className: "oui-w-1/5"
|
|
2019
|
+
}
|
|
2020
|
+
];
|
|
2021
|
+
return cols;
|
|
2022
|
+
}, [t]);
|
|
2023
|
+
const body = react.useMemo(() => {
|
|
2024
|
+
if (isLG) {
|
|
2025
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2026
|
+
orderlyUi.ListView,
|
|
2027
|
+
{
|
|
2028
|
+
className: "oui-w-full oui-max-h-[200px]",
|
|
2029
|
+
dataSource: props.referees.data,
|
|
2030
|
+
loadMore: props.referees.loadMore,
|
|
2031
|
+
isLoading: props.referees.isLoading,
|
|
2032
|
+
renderItem: (e, index) => {
|
|
2033
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2034
|
+
orderlyUi.Flex,
|
|
2035
|
+
{
|
|
2036
|
+
direction: "column",
|
|
2037
|
+
gap: 3,
|
|
2038
|
+
className: "oui-border-b-2 oui-border-line-6 oui-pb-3",
|
|
2039
|
+
children: [
|
|
2040
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", width: "100%", children: [
|
|
2041
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2042
|
+
MobileCellItem2,
|
|
2043
|
+
{
|
|
2044
|
+
title: t("affiliate.referralCode"),
|
|
2045
|
+
value: e.referral_code
|
|
2046
|
+
}
|
|
2047
|
+
),
|
|
2048
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2049
|
+
MobileCellItem2,
|
|
2050
|
+
{
|
|
2051
|
+
title: `${t(
|
|
2052
|
+
"affiliate.referees.column.totalCommission"
|
|
2053
|
+
)} (USDC)`,
|
|
2054
|
+
value: orderlyUtils.commifyOptional(e.referral_rebate, {
|
|
2055
|
+
fix: 6,
|
|
2056
|
+
prefix: "$",
|
|
2057
|
+
padEnd: true
|
|
2058
|
+
}),
|
|
2059
|
+
className: "oui-min-w-[102px]"
|
|
2060
|
+
}
|
|
2061
|
+
),
|
|
2062
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2063
|
+
MobileCellItem2,
|
|
2064
|
+
{
|
|
2065
|
+
title: t("affiliate.referees.column.totalVol"),
|
|
2066
|
+
value: orderlyUtils.commifyOptional(e.volume, {
|
|
2067
|
+
fix: 2,
|
|
2068
|
+
prefix: "$",
|
|
2069
|
+
padEnd: true
|
|
2070
|
+
}),
|
|
2071
|
+
align: "end"
|
|
2072
|
+
}
|
|
2073
|
+
)
|
|
2074
|
+
] }),
|
|
2075
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", pt: 3, gap: 3, width: "100%", children: [
|
|
2076
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2077
|
+
MobileCellItem2,
|
|
2078
|
+
{
|
|
2079
|
+
title: t("affiliate.referees.column.refereeAddress"),
|
|
2080
|
+
value: e.user_address,
|
|
2081
|
+
rule: "address"
|
|
2082
|
+
}
|
|
2083
|
+
),
|
|
2084
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2085
|
+
MobileCellItem2,
|
|
2086
|
+
{
|
|
2087
|
+
title: t("affiliate.referees.column.invitationTime"),
|
|
2088
|
+
value: e.code_binding_time,
|
|
2089
|
+
align: "end",
|
|
2090
|
+
rule: "date",
|
|
2091
|
+
formatString: "yyyy-MM-dd"
|
|
2092
|
+
}
|
|
2093
|
+
)
|
|
2094
|
+
] })
|
|
2095
|
+
]
|
|
2096
|
+
},
|
|
2097
|
+
index
|
|
2098
|
+
);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2104
|
+
orderlyUiConnector.AuthGuardDataTable,
|
|
2105
|
+
{
|
|
2106
|
+
bordered: true,
|
|
2107
|
+
loading: props.referees.isLoading,
|
|
2108
|
+
ignoreLoadingCheck: true,
|
|
2109
|
+
columns,
|
|
2110
|
+
dataSource: props.referees.data,
|
|
2111
|
+
pagination: props.referees.pagination,
|
|
2112
|
+
onRow: (record) => {
|
|
2113
|
+
return {
|
|
2114
|
+
className: "oui-h-[41px]"
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
);
|
|
2119
|
+
}, [isLG, props.referees]);
|
|
2120
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2121
|
+
orderlyUi.Flex,
|
|
2122
|
+
{
|
|
2123
|
+
direction: "column",
|
|
2124
|
+
width: "100%",
|
|
2125
|
+
justify: "start",
|
|
2126
|
+
itemAlign: "start",
|
|
2127
|
+
children: body
|
|
2128
|
+
}
|
|
2129
|
+
);
|
|
2130
|
+
};
|
|
2131
|
+
var DateFiler = (props) => {
|
|
2132
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { width: "100%", height: 49, className: "oui-border-b oui-border-line-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2133
|
+
orderlyUi.DatePicker.range,
|
|
2134
|
+
{
|
|
2135
|
+
size: "xs",
|
|
2136
|
+
value: props.value,
|
|
2137
|
+
onChange: (range) => {
|
|
2138
|
+
props.setValue(range);
|
|
2139
|
+
},
|
|
2140
|
+
max: 90,
|
|
2141
|
+
disabled: {
|
|
2142
|
+
after: /* @__PURE__ */ new Date()
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
) }) });
|
|
2146
|
+
};
|
|
2147
|
+
var useCommissionAndRefereesScript = () => {
|
|
2148
|
+
const commission = useCommissionDataScript();
|
|
2149
|
+
const referees = useRefereesDataScript();
|
|
2150
|
+
return {
|
|
2151
|
+
commission,
|
|
2152
|
+
referees
|
|
2153
|
+
};
|
|
2154
|
+
};
|
|
2155
|
+
var useCommissionDataScript = () => {
|
|
2156
|
+
const [commissionRange, setCommissionRange] = react.useState(
|
|
2157
|
+
{
|
|
2158
|
+
from: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
|
|
2159
|
+
to: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
2160
|
+
}
|
|
2161
|
+
);
|
|
2162
|
+
const isLG = orderlyHooks.useMediaQuery("(max-width: 767px)");
|
|
2163
|
+
const { page, pageSize, setPage, parsePagination } = orderlyUi.usePagination();
|
|
2164
|
+
const [commissionData, { refresh, isLoading, loadMore, meta }] = orderlyHooks.useReferralRebateSummary({
|
|
2165
|
+
startDate: commissionRange?.from !== void 0 ? dateFns.format(commissionRange.from, "yyyy-MM-dd") : void 0,
|
|
2166
|
+
endDate: commissionRange?.to !== void 0 ? dateFns.format(commissionRange.to, "yyyy-MM-dd") : void 0,
|
|
2167
|
+
size: pageSize,
|
|
2168
|
+
page: !isLG ? page : void 0
|
|
2169
|
+
});
|
|
2170
|
+
react.useEffect(() => {
|
|
2171
|
+
refresh();
|
|
2172
|
+
}, [commissionRange]);
|
|
2173
|
+
const pagination = react.useMemo(
|
|
2174
|
+
() => parsePagination(meta),
|
|
2175
|
+
[parsePagination, meta]
|
|
2176
|
+
);
|
|
2177
|
+
react.useEffect(() => {
|
|
2178
|
+
setPage(1);
|
|
2179
|
+
}, [commissionRange]);
|
|
2180
|
+
return {
|
|
2181
|
+
data: commissionData || void 0,
|
|
2182
|
+
pagination,
|
|
2183
|
+
dateRange: commissionRange,
|
|
2184
|
+
setDateRange: setCommissionRange,
|
|
2185
|
+
isLoading,
|
|
2186
|
+
loadMore
|
|
2187
|
+
};
|
|
2188
|
+
};
|
|
2189
|
+
var useRefereesDataScript = () => {
|
|
2190
|
+
const [commissionRange, setCommissionRange] = react.useState(
|
|
2191
|
+
{
|
|
2192
|
+
from: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
|
|
2193
|
+
to: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
2194
|
+
}
|
|
2195
|
+
);
|
|
2196
|
+
const isLG = orderlyHooks.useMediaQuery("(max-width: 767px)");
|
|
2197
|
+
const { page, pageSize, setPage, parsePagination } = orderlyUi.usePagination();
|
|
2198
|
+
const [commissionData, { refresh, isLoading, loadMore, meta }] = orderlyHooks.useRefereeInfo({
|
|
2199
|
+
startDate: commissionRange?.from !== void 0 ? dateFns.format(commissionRange.from, "yyyy-MM-dd") : void 0,
|
|
2200
|
+
endDate: commissionRange?.to !== void 0 ? dateFns.format(commissionRange.to, "yyyy-MM-dd") : void 0,
|
|
2201
|
+
size: pageSize,
|
|
2202
|
+
page: !isLG ? page : void 0,
|
|
2203
|
+
sort: "descending_code_binding_time"
|
|
2204
|
+
});
|
|
2205
|
+
react.useEffect(() => {
|
|
2206
|
+
refresh();
|
|
2207
|
+
}, [commissionRange]);
|
|
2208
|
+
const pagination = react.useMemo(
|
|
2209
|
+
() => parsePagination(meta),
|
|
2210
|
+
[parsePagination, meta]
|
|
2211
|
+
);
|
|
2212
|
+
react.useEffect(() => {
|
|
2213
|
+
setPage(1);
|
|
2214
|
+
}, [commissionRange]);
|
|
2215
|
+
return {
|
|
2216
|
+
data: commissionData || void 0,
|
|
2217
|
+
pagination,
|
|
2218
|
+
dateRange: commissionRange,
|
|
2219
|
+
setDateRange: setCommissionRange,
|
|
2220
|
+
isLoading,
|
|
2221
|
+
loadMore
|
|
2222
|
+
};
|
|
2223
|
+
};
|
|
2224
|
+
var CommissionAndRefereesWidget = () => {
|
|
2225
|
+
const state = useCommissionAndRefereesScript();
|
|
2226
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CommissionAndReferees, { ...state });
|
|
2227
|
+
};
|
|
2228
|
+
var AffiliatePage = () => {
|
|
2229
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2230
|
+
orderlyUi.Flex,
|
|
2231
|
+
{
|
|
2232
|
+
id: "oui-affiliate-affiliate-page",
|
|
2233
|
+
className: orderlyUi.cn(
|
|
2234
|
+
"oui-h-lvw",
|
|
2235
|
+
// padding
|
|
2236
|
+
// "oui-p-4 lg:oui-p-6 xl:oui-p-3",
|
|
2237
|
+
"oui-font-semibold"
|
|
2238
|
+
),
|
|
2239
|
+
direction: "column",
|
|
2240
|
+
gap: 4,
|
|
2241
|
+
children: [
|
|
2242
|
+
/* @__PURE__ */ jsxRuntime.jsx(Layout, {}),
|
|
2243
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommissionAndRefereesWidget, {})
|
|
2244
|
+
]
|
|
2245
|
+
}
|
|
2246
|
+
);
|
|
2247
|
+
};
|
|
2248
|
+
var Layout = () => {
|
|
2249
|
+
const is2XL = orderlyHooks.useMediaQuery("(max-width: 1279px)");
|
|
2250
|
+
if (is2XL) {
|
|
2251
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Layout1024, {});
|
|
2252
|
+
}
|
|
2253
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Layout1280, {});
|
|
2254
|
+
};
|
|
2255
|
+
var Layout1024 = () => {
|
|
2256
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2257
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col xl:oui-flex-row oui-gap-4 oui-w-full", children: [
|
|
2258
|
+
/* @__PURE__ */ jsxRuntime.jsx(SummaryWidget, {}),
|
|
2259
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReferralLinkWidget, {})
|
|
2260
|
+
] }),
|
|
2261
|
+
/* @__PURE__ */ jsxRuntime.jsx(TitleStatisticWidget, {}),
|
|
2262
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReferralCodesWidget, {})
|
|
2263
|
+
] });
|
|
2264
|
+
};
|
|
2265
|
+
var Layout1280 = () => {
|
|
2266
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", itemAlign: "stretch", gap: 4, children: [
|
|
2267
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", gap: 4, className: "oui-flex-1 oui-w-1/2", children: [
|
|
2268
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex-1 oui-h-full oui-w-full", children: /* @__PURE__ */ jsxRuntime.jsx(SummaryWidget, {}) }),
|
|
2269
|
+
/* @__PURE__ */ jsxRuntime.jsx(TitleStatisticWidget, {})
|
|
2270
|
+
] }),
|
|
2271
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", gap: 4, className: "oui-w-1/2", children: [
|
|
2272
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReferralLinkWidget, {}),
|
|
2273
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(ReferralCodesWidget, {}) })
|
|
2274
|
+
] })
|
|
2275
|
+
] });
|
|
2276
|
+
};
|
|
2277
|
+
var BecomeAffiliate = (props) => {
|
|
2278
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2279
|
+
const { generateCode } = useReferralContext();
|
|
2280
|
+
const applyText = react.useMemo(() => {
|
|
2281
|
+
if (!generateCode) {
|
|
2282
|
+
return {
|
|
2283
|
+
title: t("affiliate.process.step1.title"),
|
|
2284
|
+
desc: t("affiliate.process.step1.description")
|
|
2285
|
+
};
|
|
2286
|
+
}
|
|
2287
|
+
if (generateCode.requireVolume > 0) {
|
|
2288
|
+
return {
|
|
2289
|
+
title: t("affiliate.process.step1.volumeGt0.title", {
|
|
2290
|
+
requireVolume: generateCode.requireVolume
|
|
2291
|
+
}),
|
|
2292
|
+
desc: t("affiliate.process.step1.volumeGt0.description", {
|
|
2293
|
+
volume: orderlyUtils.commify(generateCode.completedVolume ?? 0, 2),
|
|
2294
|
+
requireVolume: orderlyUtils.commify(generateCode.requireVolume)
|
|
2295
|
+
})
|
|
2296
|
+
};
|
|
2297
|
+
}
|
|
2298
|
+
return {
|
|
2299
|
+
title: t("affiliate.process.step1.volumeEq0.title"),
|
|
2300
|
+
desc: t("affiliate.process.step1.volumeEq0.description")
|
|
2301
|
+
};
|
|
2302
|
+
}, [generateCode, t]);
|
|
2303
|
+
if (typeof props.overwrite === "function") {
|
|
2304
|
+
return props.overwrite?.(props.state);
|
|
2305
|
+
}
|
|
2306
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2307
|
+
orderlyUi.Flex,
|
|
2308
|
+
{
|
|
2309
|
+
id: "oui-affiliate-home-becomeAffiliate",
|
|
2310
|
+
direction: "column",
|
|
2311
|
+
gap: 6,
|
|
2312
|
+
p: 6,
|
|
2313
|
+
itemAlign: "center",
|
|
2314
|
+
r: "2xl",
|
|
2315
|
+
className: "oui-bg-base-9",
|
|
2316
|
+
width: "100%",
|
|
2317
|
+
children: [
|
|
2318
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: t("affiliate.process.title") }),
|
|
2319
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { className: "oui-flex oui-flex-col oui-gap-3 lg:oui-w-full lg:oui-flex-row lg:oui-items-stretch", children: [
|
|
2320
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2321
|
+
Item,
|
|
2322
|
+
{
|
|
2323
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ApplyIcon, {}),
|
|
2324
|
+
title: applyText.title,
|
|
2325
|
+
content: applyText.desc
|
|
2326
|
+
}
|
|
2327
|
+
),
|
|
2328
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ArrowDownIcon, {}) }),
|
|
2329
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2330
|
+
Item,
|
|
2331
|
+
{
|
|
2332
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ShareIcon, {}),
|
|
2333
|
+
title: t("affiliate.process.step2.title"),
|
|
2334
|
+
content: t("affiliate.process.step2.description")
|
|
2335
|
+
}
|
|
2336
|
+
),
|
|
2337
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ArrowDownIcon, {}) }),
|
|
2338
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2339
|
+
Item,
|
|
2340
|
+
{
|
|
2341
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(EarnIcon, {}),
|
|
2342
|
+
title: t("affiliate.process.step3.title"),
|
|
2343
|
+
content: t("affiliate.process.step3.description")
|
|
2344
|
+
}
|
|
2345
|
+
)
|
|
2346
|
+
] })
|
|
2347
|
+
]
|
|
2348
|
+
}
|
|
2349
|
+
);
|
|
2350
|
+
};
|
|
2351
|
+
var Item = (props) => {
|
|
2352
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2353
|
+
orderlyUi.Flex,
|
|
2354
|
+
{
|
|
2355
|
+
className: orderlyUi.cn(
|
|
2356
|
+
"oui-flex oui-flex-row oui-gap-3",
|
|
2357
|
+
"lg:oui-flex-1 lg:oui-flex-col lg:oui-gap-[6px]"
|
|
2358
|
+
),
|
|
2359
|
+
width: "100%",
|
|
2360
|
+
children: [
|
|
2361
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink-0", children: props.icon }),
|
|
2362
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2363
|
+
orderlyUi.Flex,
|
|
2364
|
+
{
|
|
2365
|
+
className: orderlyUi.cn(
|
|
2366
|
+
"oui-flex oui-flex-col oui-items-start oui-h-full oui-justify-between",
|
|
2367
|
+
// lg
|
|
2368
|
+
"lg:oui-items-center lg:oui-justify-start"
|
|
2369
|
+
),
|
|
2370
|
+
children: [
|
|
2371
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-sm md:oui-text-base 2xl:oui-text-lg lg:oui-text-center", children: props.title }),
|
|
2372
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-2xs oui-text-base-contrast-36 lg:oui-text-center", children: props.content })
|
|
2373
|
+
]
|
|
2374
|
+
}
|
|
2375
|
+
)
|
|
2376
|
+
]
|
|
2377
|
+
}
|
|
2378
|
+
);
|
|
2379
|
+
};
|
|
2380
|
+
var ApplyIcon = () => {
|
|
2381
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2382
|
+
"svg",
|
|
2383
|
+
{
|
|
2384
|
+
width: "48",
|
|
2385
|
+
height: "48",
|
|
2386
|
+
viewBox: "0 0 48 48",
|
|
2387
|
+
fill: "none",
|
|
2388
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2389
|
+
className: "lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",
|
|
2390
|
+
children: [
|
|
2391
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2392
|
+
"path",
|
|
2393
|
+
{
|
|
2394
|
+
fillRule: "evenodd",
|
|
2395
|
+
clipRule: "evenodd",
|
|
2396
|
+
d: "M24.941 5.4h-6.682a.6.6 0 0 0-.593.509l-.462 3a.6.6 0 0 0 .593.691h7.606a.6.6 0 0 0 .593-.691l-.462-3a.6.6 0 0 0-.593-.509m-6.682-1.8a2.4 2.4 0 0 0-2.372 2.035l-.462 3a2.4 2.4 0 0 0 2.372 2.765h7.606a2.4 2.4 0 0 0 2.372-2.765l-.462-3A2.4 2.4 0 0 0 24.941 3.6z",
|
|
2397
|
+
fill: "#fff",
|
|
2398
|
+
fillOpacity: ".36"
|
|
2399
|
+
}
|
|
2400
|
+
),
|
|
2401
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2402
|
+
"path",
|
|
2403
|
+
{
|
|
2404
|
+
d: "M32.721 28.2c.924-1.6 3.233-1.6 4.157 0l7.275 12.6c.924 1.6-.231 3.6-2.079 3.6H27.525c-1.848 0-3.002-2-2.078-3.6z",
|
|
2405
|
+
fill: "#335FFC"
|
|
2406
|
+
}
|
|
2407
|
+
),
|
|
2408
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2409
|
+
"path",
|
|
2410
|
+
{
|
|
2411
|
+
d: "M33.492 38.12H31.56c-.252 0-.426-.276-.336-.535l1.92-5.53a.4.4 0 0 1 .132-.185.34.34 0 0 1 .204-.07h3.24c.255 0 .43.284.333.544l-1.118 3.011h2.104c.31 0 .475.4.27.656l-5.158 6.453c-.251.313-.716.041-.619-.362z",
|
|
2412
|
+
fill: "#fff",
|
|
2413
|
+
fillOpacity: ".98"
|
|
2414
|
+
}
|
|
2415
|
+
),
|
|
2416
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2417
|
+
"path",
|
|
2418
|
+
{
|
|
2419
|
+
fillRule: "evenodd",
|
|
2420
|
+
clipRule: "evenodd",
|
|
2421
|
+
d: "M14.4 16.8v2.4h2.4v-2.4zM13.2 15a.6.6 0 0 0-.6.6v4.8a.6.6 0 0 0 .6.6H18a.6.6 0 0 0 .6-.6v-4.8a.6.6 0 0 0-.6-.6z",
|
|
2422
|
+
fill: "#fff",
|
|
2423
|
+
fillOpacity: ".36"
|
|
2424
|
+
}
|
|
2425
|
+
),
|
|
2426
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2427
|
+
"path",
|
|
2428
|
+
{
|
|
2429
|
+
d: "M20.4 16.2a.6.6 0 0 1 .6-.6h2.4a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H21a.6.6 0 0 1-.6-.6zm0 3a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6zm-7.8 5.4a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6z",
|
|
2430
|
+
fill: "#fff",
|
|
2431
|
+
fillOpacity: ".36"
|
|
2432
|
+
}
|
|
2433
|
+
),
|
|
2434
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2435
|
+
"path",
|
|
2436
|
+
{
|
|
2437
|
+
fillRule: "evenodd",
|
|
2438
|
+
clipRule: "evenodd",
|
|
2439
|
+
d: "M15.739 6.6H10.2A2.4 2.4 0 0 0 7.8 9v30a2.4 2.4 0 0 0 2.4 2.4h13.84l1.014-1.8H10.2a.6.6 0 0 1-.6-.6V9a.6.6 0 0 1 .6-.6h5.262zm12 1.8H33a.6.6 0 0 1 .6.6v16.47a2.8 2.8 0 0 1 1.8-.205V9A2.4 2.4 0 0 0 33 6.6h-5.538z",
|
|
2440
|
+
fill: "#fff",
|
|
2441
|
+
fillOpacity: ".36"
|
|
2442
|
+
}
|
|
2443
|
+
)
|
|
2444
|
+
]
|
|
2445
|
+
}
|
|
2446
|
+
);
|
|
2447
|
+
};
|
|
2448
|
+
var ShareIcon = () => {
|
|
2449
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2450
|
+
"svg",
|
|
2451
|
+
{
|
|
2452
|
+
width: "48",
|
|
2453
|
+
height: "48",
|
|
2454
|
+
viewBox: "0 0 48 48",
|
|
2455
|
+
fill: "none",
|
|
2456
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2457
|
+
className: "lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",
|
|
2458
|
+
children: [
|
|
2459
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M24 33a9 9 0 1 1-18 0 9 9 0 0 1 18 0", fill: "#335FFC" }),
|
|
2460
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2461
|
+
"path",
|
|
2462
|
+
{
|
|
2463
|
+
fillRule: "evenodd",
|
|
2464
|
+
clipRule: "evenodd",
|
|
2465
|
+
d: "M15 32.4a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0 1.8a3.6 3.6 0 1 0 0-7.2 3.6 3.6 0 0 0 0 7.2m-6.578 4.942A4.8 4.8 0 0 1 13.2 34.8h3.6a4.8 4.8 0 0 1 4.778 4.342 9 9 0 0 1-1.778 1.473V39.6a3 3 0 0 0-3-3h-3.6a3 3 0 0 0-3 3v1.015a9 9 0 0 1-1.778-1.473",
|
|
2466
|
+
fill: "#fff",
|
|
2467
|
+
fillOpacity: ".98"
|
|
2468
|
+
}
|
|
2469
|
+
),
|
|
2470
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2471
|
+
"path",
|
|
2472
|
+
{
|
|
2473
|
+
fillRule: "evenodd",
|
|
2474
|
+
clipRule: "evenodd",
|
|
2475
|
+
d: "M16.2 12a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0m1.8 0c0 1.37-.459 2.632-1.231 3.642l2.308 2.308a7.76 7.76 0 0 1 4.023-1.7v-.764A3.602 3.602 0 0 1 24 8.4a3.6 3.6 0 0 1 .9 7.087v.764c1.48.17 2.833.754 3.942 1.633l2.326-2.326a6 6 0 1 1 1.273 1.273l-2.326 2.326a7.76 7.76 0 0 1 1.634 3.943h.764a3.602 3.602 0 0 1 7.087.9 3.6 3.6 0 0 1-7.087.9h-.764a7.76 7.76 0 0 1-1.699 4.023l2.308 2.308a6 6 0 1 1-1.25 1.295l-2.347-2.347a7.8 7.8 0 0 1-3.05 1.433 11 11 0 0 0-.377-1.76 6 6 0 1 0-7.185-7.185q-.855-.261-1.76-.379a7.8 7.8 0 0 1 1.432-3.049l-2.347-2.347A6 6 0 1 1 18 12m7.8 0a1.8 1.8 0 1 1-3.6 0 1.8 1.8 0 0 1 3.6 0M36 25.8a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0-9.6a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4M40.2 36a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0",
|
|
2476
|
+
fill: "#fff",
|
|
2477
|
+
fillOpacity: ".36"
|
|
2478
|
+
}
|
|
2479
|
+
)
|
|
2480
|
+
]
|
|
2481
|
+
}
|
|
2482
|
+
);
|
|
2483
|
+
};
|
|
2484
|
+
var EarnIcon = () => {
|
|
2485
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2486
|
+
"svg",
|
|
2487
|
+
{
|
|
2488
|
+
width: "48",
|
|
2489
|
+
height: "48",
|
|
2490
|
+
viewBox: "0 0 48 48",
|
|
2491
|
+
fill: "none",
|
|
2492
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2493
|
+
className: "lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",
|
|
2494
|
+
children: [
|
|
2495
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2496
|
+
"path",
|
|
2497
|
+
{
|
|
2498
|
+
fillRule: "evenodd",
|
|
2499
|
+
clipRule: "evenodd",
|
|
2500
|
+
d: "M24 24a2.4 2.4 0 1 0 0-4.8 2.4 2.4 0 0 0 0 4.8m0 1.8a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4",
|
|
2501
|
+
fill: "#fff",
|
|
2502
|
+
fillOpacity: ".36"
|
|
2503
|
+
}
|
|
2504
|
+
),
|
|
2505
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M45 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0", fill: "#335FFC" }),
|
|
2506
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2507
|
+
"path",
|
|
2508
|
+
{
|
|
2509
|
+
fillRule: "evenodd",
|
|
2510
|
+
clipRule: "evenodd",
|
|
2511
|
+
d: "M35.1 6.6a.9.9 0 1 1 1.8 0v.437A3 3 0 0 1 39 9.9h-1.8a1.2 1.2 0 1 0-1.2 1.2 3 3 0 0 1 .9 5.863v.437a.9.9 0 0 1-1.8 0v-.437A3 3 0 0 1 33 14.1h1.8a1.2 1.2 0 1 0 1.2-1.2 3 3 0 0 1-.9-5.863z",
|
|
2512
|
+
fill: "#fff",
|
|
2513
|
+
fillOpacity: ".98"
|
|
2514
|
+
}
|
|
2515
|
+
),
|
|
2516
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2517
|
+
"path",
|
|
2518
|
+
{
|
|
2519
|
+
fillRule: "evenodd",
|
|
2520
|
+
clipRule: "evenodd",
|
|
2521
|
+
d: "M40.2 23.7a.9.9 0 0 1 1.8 0v.6q0 .045-.004.086c-.197 9.351-7.525 16.948-16.765 17.573l1.205 1.205a.9.9 0 1 1-1.272 1.272l-2.7-2.7a.9.9 0 0 1 0-1.272l2.7-2.7a.9.9 0 1 1 1.272 1.272l-1.11 1.11c8.325-.674 14.87-7.642 14.874-16.14zM21.564 4.836a.9.9 0 1 1 1.272-1.272l2.7 2.7a.9.9 0 0 1 0 1.272l-2.7 2.7a.9.9 0 1 1-1.272-1.272l1.11-1.11C14.347 8.528 7.8 15.5 7.8 24v.3a.9.9 0 1 1-1.8 0v-.6l.004-.086C6.201 14.263 13.53 6.666 22.77 6.042z",
|
|
2522
|
+
fill: "#fff",
|
|
2523
|
+
fillOpacity: ".36"
|
|
2524
|
+
}
|
|
2525
|
+
),
|
|
2526
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2527
|
+
"path",
|
|
2528
|
+
{
|
|
2529
|
+
fillRule: "evenodd",
|
|
2530
|
+
clipRule: "evenodd",
|
|
2531
|
+
d: "M24 11.4q.615 0 1.213.058a11 11 0 0 0 .061 1.816Q24.647 13.2 24 13.2c-5.965 0-10.8 4.835-10.8 10.8 0 2.898 1.142 5.53 3 7.47a4.8 4.8 0 0 1 4.8-4.79h6a4.8 4.8 0 0 1 4.8 4.789c1.858-1.94 3-4.572 3-7.47q0-.647-.074-1.274a11 11 0 0 0 1.816.06q.057.6.058 1.214c0 6.959-5.641 12.6-12.6 12.6S11.4 30.959 11.4 24 17.041 11.4 24 11.4m6 21.581v-1.5a3 3 0 0 0-3-3h-6a3 3 0 0 0-3 3v1.5a10.75 10.75 0 0 0 6 1.819c2.22 0 4.284-.67 6-1.819",
|
|
2532
|
+
fill: "#fff",
|
|
2533
|
+
fillOpacity: ".36"
|
|
2534
|
+
}
|
|
2535
|
+
)
|
|
2536
|
+
]
|
|
2537
|
+
}
|
|
2538
|
+
);
|
|
2539
|
+
};
|
|
2540
|
+
var ArrowDownIcon = () => {
|
|
2541
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2542
|
+
"svg",
|
|
2543
|
+
{
|
|
2544
|
+
width: "17",
|
|
2545
|
+
height: "16",
|
|
2546
|
+
viewBox: "0 0 17 16",
|
|
2547
|
+
fill: "none",
|
|
2548
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2549
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2550
|
+
"path",
|
|
2551
|
+
{
|
|
2552
|
+
d: "M8.5048 4.00806C8.8728 4.00806 9.1708 4.30626 9.1708 4.67406C9.1708 4.99259 9.1708 8.71739 9.1708 9.71072L11.1688 7.73339L12.1055 8.67005L8.98346 11.8127C8.85346 11.9434 8.6788 12.0081 8.50413 12.0081C8.33013 12.0081 8.15612 11.9427 8.02612 11.8127L4.90413 8.67005L5.8408 7.73339L7.83881 9.71072C7.83881 8.71739 7.83881 4.99259 7.83881 4.67406C7.83881 4.30626 8.1368 4.00806 8.5048 4.00806Z",
|
|
2553
|
+
fill: "#608CFF"
|
|
2554
|
+
}
|
|
2555
|
+
)
|
|
2556
|
+
}
|
|
2557
|
+
);
|
|
2558
|
+
};
|
|
2559
|
+
|
|
2560
|
+
// src/pages/home/becomeAffiliate/becomeAffiliate.script.tsx
|
|
2561
|
+
var useBecomeAffiliateScript = () => {
|
|
2562
|
+
const state = useReferralContext();
|
|
2563
|
+
return {
|
|
2564
|
+
overwrite: state.overwrite?.ref?.step,
|
|
2565
|
+
state
|
|
2566
|
+
};
|
|
2567
|
+
};
|
|
2568
|
+
var BecomeAffiliateWidget = () => {
|
|
2569
|
+
const state = useBecomeAffiliateScript();
|
|
2570
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BecomeAffiliate, { ...state });
|
|
2571
|
+
};
|
|
2572
|
+
var Title5 = () => {
|
|
2573
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2574
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2575
|
+
"div",
|
|
2576
|
+
{
|
|
2577
|
+
id: "oui-affiliate-home-title",
|
|
2578
|
+
className: "oui-text-center oui-text-3xl oui-font-bold md:oui-text-3xl lg:oui-text-4xl xl:oui-text-5xl",
|
|
2579
|
+
children: t("affiliate.page.title")
|
|
2580
|
+
}
|
|
2581
|
+
);
|
|
2582
|
+
};
|
|
2583
|
+
var TitleWidget = () => {
|
|
2584
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Title5, {});
|
|
2585
|
+
};
|
|
2586
|
+
var Subtitle2 = (props) => {
|
|
2587
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2588
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2589
|
+
orderlyUi.Flex,
|
|
2590
|
+
{
|
|
2591
|
+
id: "oui-affiliate-home-subtitle",
|
|
2592
|
+
direction: "column",
|
|
2593
|
+
className: "oui-text-sm md:oui-text-base xl:oui-text-lg oui-text-base-contrast-80 oui-text-center",
|
|
2594
|
+
gap: 3,
|
|
2595
|
+
children: [
|
|
2596
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: t("affiliate.page.subTitle") }),
|
|
2597
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2598
|
+
orderlyUi.Flex,
|
|
2599
|
+
{
|
|
2600
|
+
direction: "row",
|
|
2601
|
+
gap: 1,
|
|
2602
|
+
className: "oui-text-primary-light oui-fill-primary-light hover:oui-text-primary-darken oui-cursor-pointer oui-text-2xs md:oui-text-xs xl:oui-text-sm",
|
|
2603
|
+
onClick: (e) => {
|
|
2604
|
+
if (props.onLearnAffiliate) {
|
|
2605
|
+
props.onLearnAffiliate?.();
|
|
2606
|
+
} else if (props.learnAffiliateUrl) {
|
|
2607
|
+
window.open(props.learnAffiliateUrl, "_blank");
|
|
2608
|
+
}
|
|
2609
|
+
},
|
|
2610
|
+
children: [
|
|
2611
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: t("affiliate.page.learnMore") }),
|
|
2612
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2613
|
+
"svg",
|
|
2614
|
+
{
|
|
2615
|
+
width: "16",
|
|
2616
|
+
height: "16",
|
|
2617
|
+
viewBox: "0 0 16 16",
|
|
2618
|
+
fill: "currentColor",
|
|
2619
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2620
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4.008 7.995c0-.368.298-.666.666-.666H9.71L7.733 5.331l.937-.936 3.143 3.122c.13.13.195.304.195.479a.67.67 0 0 1-.195.478L8.67 11.596l-.937-.937 1.978-1.998H4.674a.666.666 0 0 1-.666-.666" })
|
|
2621
|
+
}
|
|
2622
|
+
)
|
|
2623
|
+
]
|
|
2624
|
+
}
|
|
2625
|
+
)
|
|
2626
|
+
]
|
|
2627
|
+
}
|
|
2628
|
+
);
|
|
2629
|
+
};
|
|
2630
|
+
|
|
2631
|
+
// src/pages/home/subtitle/subtitle.script.tsx
|
|
2632
|
+
var useSubtitleScript = () => {
|
|
2633
|
+
const state = useReferralContext();
|
|
2634
|
+
const { onLearnAffiliate, learnAffiliateUrl } = state;
|
|
2635
|
+
return {
|
|
2636
|
+
onLearnAffiliate,
|
|
2637
|
+
learnAffiliateUrl
|
|
2638
|
+
};
|
|
2639
|
+
};
|
|
2640
|
+
var SubtitleWidget = () => {
|
|
2641
|
+
const state = useSubtitleScript();
|
|
2642
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Subtitle2, { ...state });
|
|
2643
|
+
};
|
|
2644
|
+
var Top = (props) => {
|
|
2645
|
+
if (props.overwriteTop !== void 0) {
|
|
2646
|
+
return props.overwriteTop?.(props.state);
|
|
2647
|
+
}
|
|
2648
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { id: "oui-affiliate-home-top", direction: "column", gap: 6, children: [
|
|
2649
|
+
/* @__PURE__ */ jsxRuntime.jsx(TitleWidget, {}),
|
|
2650
|
+
/* @__PURE__ */ jsxRuntime.jsx(SubtitleWidget, {})
|
|
2651
|
+
] });
|
|
2652
|
+
};
|
|
2653
|
+
|
|
2654
|
+
// src/pages/home/top/top.script.tsx
|
|
2655
|
+
var useTopScript = () => {
|
|
2656
|
+
const state = useReferralContext();
|
|
2657
|
+
return {
|
|
2658
|
+
overwriteTop: state.overwrite?.ref?.top,
|
|
2659
|
+
state
|
|
2660
|
+
};
|
|
2661
|
+
};
|
|
2662
|
+
var TopWidget = () => {
|
|
2663
|
+
const state = useTopScript();
|
|
2664
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Top, { ...state });
|
|
2665
|
+
};
|
|
2666
|
+
var ArrowRightIcon = (props) => {
|
|
2667
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2668
|
+
"svg",
|
|
2669
|
+
{
|
|
2670
|
+
width: "16",
|
|
2671
|
+
height: "16",
|
|
2672
|
+
viewBox: "0 0 16 16",
|
|
2673
|
+
fill: "white",
|
|
2674
|
+
fillOpacity: "0.98",
|
|
2675
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2676
|
+
className: props.className,
|
|
2677
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4.00806 7.9952C4.00806 7.6272 4.30626 7.3292 4.67406 7.3292C4.99259 7.3292 8.71739 7.3292 9.71072 7.3292L7.73339 5.3312L8.67005 4.39453L11.8127 7.51654C11.9434 7.64654 12.0081 7.8212 12.0081 7.99587C12.0081 8.16987 11.9427 8.34388 11.8127 8.47388L8.67005 11.5959L7.73339 10.6592L9.71072 8.66119C8.71739 8.66119 4.99259 8.66119 4.67406 8.66119C4.30626 8.66119 4.00806 8.3632 4.00806 7.9952Z" })
|
|
2678
|
+
}
|
|
2679
|
+
);
|
|
2680
|
+
};
|
|
2681
|
+
var AsTrader = (props) => {
|
|
2682
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2683
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2684
|
+
orderlyUi.Flex,
|
|
2685
|
+
{
|
|
2686
|
+
id: "oui-affiliate-home-asTrader",
|
|
2687
|
+
gradient: "success",
|
|
2688
|
+
r: "2xl",
|
|
2689
|
+
p: 6,
|
|
2690
|
+
gap: 6,
|
|
2691
|
+
direction: "column",
|
|
2692
|
+
angle: 180,
|
|
2693
|
+
width: "100%",
|
|
2694
|
+
justify: "between",
|
|
2695
|
+
children: [
|
|
2696
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2697
|
+
orderlyUi.Flex,
|
|
2698
|
+
{
|
|
2699
|
+
height: 80,
|
|
2700
|
+
direction: "row",
|
|
2701
|
+
gap: 3,
|
|
2702
|
+
itemAlign: "start",
|
|
2703
|
+
width: "100%",
|
|
2704
|
+
justify: "between",
|
|
2705
|
+
children: [
|
|
2706
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2707
|
+
orderlyUi.Flex,
|
|
2708
|
+
{
|
|
2709
|
+
direction: "column",
|
|
2710
|
+
itemAlign: "start",
|
|
2711
|
+
justify: "between",
|
|
2712
|
+
className: "oui-h-full",
|
|
2713
|
+
children: [
|
|
2714
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl", children: props.isTrader ? t("affiliate.trader") : t("affiliate.asTrader.title") }),
|
|
2715
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2716
|
+
orderlyUi.Text,
|
|
2717
|
+
{
|
|
2718
|
+
className: orderlyUi.cn(
|
|
2719
|
+
"oui-text-xs oui-text-base-contrast-54 md:oui-text-sm 2xl:oui-text-base",
|
|
2720
|
+
props.isTrader && "oui-hidden"
|
|
2721
|
+
),
|
|
2722
|
+
children: t("affiliate.asTrader.description")
|
|
2723
|
+
}
|
|
2724
|
+
)
|
|
2725
|
+
]
|
|
2726
|
+
}
|
|
2727
|
+
),
|
|
2728
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, {}) })
|
|
2729
|
+
]
|
|
2730
|
+
}
|
|
2731
|
+
),
|
|
2732
|
+
/* @__PURE__ */ jsxRuntime.jsx(Bottom, { ...props })
|
|
2733
|
+
]
|
|
2734
|
+
}
|
|
2735
|
+
);
|
|
2736
|
+
};
|
|
2737
|
+
var Icon = () => {
|
|
2738
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2739
|
+
"svg",
|
|
2740
|
+
{
|
|
2741
|
+
width: "72",
|
|
2742
|
+
height: "72",
|
|
2743
|
+
viewBox: "0 0 90 90",
|
|
2744
|
+
fill: "none",
|
|
2745
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2746
|
+
className: "xl:oui-size-[90px] ",
|
|
2747
|
+
children: [
|
|
2748
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2749
|
+
"path",
|
|
2750
|
+
{
|
|
2751
|
+
d: "M44.996 7.324c-20.71 0-37.43 16.79-37.5 37.5-.07 20.682 16.806 37.575 37.5 37.617 20.694.04 37.537-17.082 37.5-37.617-.037-20.71-16.79-37.5-37.5-37.5m0 7.5c16.569 0 30 13.433 30 30 0 8.438-3.514 16.043-9.12 21.495-2.762-5.973-8.694-10.245-15.49-10.245h-10.78c-6.791 0-12.706 4.22-15.47 10.197-5.606-5.453-9.14-13.01-9.14-21.447 0-16.567 13.431-30 30-30m0 7.5c-8.284 0-15 6.717-15 15s6.716 15 15 15 15-6.716 15-15-6.716-15-15-15",
|
|
2752
|
+
fill: "#fff",
|
|
2753
|
+
fillOpacity: ".2"
|
|
2754
|
+
}
|
|
2755
|
+
),
|
|
2756
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2757
|
+
"path",
|
|
2758
|
+
{
|
|
2759
|
+
d: "M90 71.25C90 81.605 81.605 90 71.25 90S52.5 81.605 52.5 71.25 60.895 52.5 71.25 52.5 90 60.895 90 71.25",
|
|
2760
|
+
fill: "#005A4F"
|
|
2761
|
+
}
|
|
2762
|
+
),
|
|
2763
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2764
|
+
"path",
|
|
2765
|
+
{
|
|
2766
|
+
d: "M80.62 75.007c0-.24-.08-.49-.263-.675l-3.487-3.456-1.318 1.318 1.845 1.875H63.745a.938.938 0 0 0 0 1.875h13.652l-1.845 1.875 1.318 1.318 3.487-3.456a.95.95 0 0 0 .263-.674m-.937-7.5a.94.94 0 0 0-.938-.938H65.093l1.846-1.875-1.319-1.318-3.486 3.456a.966.966 0 0 0 0 1.349l3.486 3.456 1.319-1.318-1.846-1.875h13.652c.518 0 .938-.42.938-.937",
|
|
2767
|
+
fill: "#fff",
|
|
2768
|
+
fillOpacity: ".98"
|
|
2769
|
+
}
|
|
2770
|
+
)
|
|
2771
|
+
]
|
|
2772
|
+
}
|
|
2773
|
+
);
|
|
2774
|
+
};
|
|
2775
|
+
var Bottom = (props) => {
|
|
2776
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2777
|
+
const content = () => {
|
|
2778
|
+
if (props.isTrader && !props.wrongNetwork) {
|
|
2779
|
+
const totalReferrerRebate = props.referralInfo?.referee_info?.total_referee_rebate;
|
|
2780
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2781
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", itemAlign: "start", gap: 2, children: [
|
|
2782
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Text, { className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm", children: [
|
|
2783
|
+
t("affiliate.commission"),
|
|
2784
|
+
" ",
|
|
2785
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 36, children: "(USDC)" })
|
|
2786
|
+
] }),
|
|
2787
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", gap: 1, children: [
|
|
2788
|
+
/* @__PURE__ */ jsxRuntime.jsx(USDCIcon, {}),
|
|
2789
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl", children: orderlyUtils.commifyOptional(totalReferrerRebate, {
|
|
2790
|
+
fix: 2,
|
|
2791
|
+
fallback: "0"
|
|
2792
|
+
}) })
|
|
2793
|
+
] })
|
|
2794
|
+
] }),
|
|
2795
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2796
|
+
orderlyUi.Flex,
|
|
2797
|
+
{
|
|
2798
|
+
direction: "row",
|
|
2799
|
+
gap: 1,
|
|
2800
|
+
justify: "end",
|
|
2801
|
+
itemAlign: "center",
|
|
2802
|
+
className: "oui-cursor-pointer",
|
|
2803
|
+
onClick: props?.onEnterTraderPage,
|
|
2804
|
+
children: [
|
|
2805
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-sm md:oui-text-base xl:oui-text-lg", children: t("affiliate.enter") }),
|
|
2806
|
+
/* @__PURE__ */ jsxRuntime.jsx(ArrowRightIcon, { className: "md:oui-size-[18px] lg:oui-size-[20px] xl:oui-size-[24px]" })
|
|
2807
|
+
]
|
|
2808
|
+
}
|
|
2809
|
+
)
|
|
2810
|
+
] });
|
|
2811
|
+
}
|
|
2812
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EntryCode, { ...props });
|
|
2813
|
+
};
|
|
2814
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2815
|
+
orderlyUi.Flex,
|
|
2816
|
+
{
|
|
2817
|
+
direction: "row",
|
|
2818
|
+
justify: "between",
|
|
2819
|
+
width: "100%",
|
|
2820
|
+
itemAlign: "end",
|
|
2821
|
+
children: content()
|
|
2822
|
+
}
|
|
2823
|
+
);
|
|
2824
|
+
};
|
|
2825
|
+
var EntryCode = (props) => {
|
|
2826
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2827
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Dialog, { open: props.open, onOpenChange: props.setOpen, children: [
|
|
2828
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.DialogTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Button, { variant: "contained", color: "light", children: t("affiliate.asTrader.button") }) }),
|
|
2829
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.DialogContent, { className: "oui-w-[320px] oui-font-semibold", children: [
|
|
2830
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.DialogTitle, { children: t("affiliate.referralCode.dialog.title") }) }),
|
|
2831
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Divider, {}),
|
|
2832
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.DialogBody, { children: [
|
|
2833
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", intensity: 54, children: t("affiliate.referralCode.dialog.description") }),
|
|
2834
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2835
|
+
orderlyUi.TextField,
|
|
2836
|
+
{
|
|
2837
|
+
className: "oui-mt-4 oui-w-full",
|
|
2838
|
+
placeholder: t("affiliate.referralCode"),
|
|
2839
|
+
value: props.code,
|
|
2840
|
+
onChange: (e) => {
|
|
2841
|
+
const _value = e.target.value.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
2842
|
+
props.setCode(_value);
|
|
2843
|
+
},
|
|
2844
|
+
formatters: [
|
|
2845
|
+
orderlyUi.inputFormatter.createRegexInputFormatter(
|
|
2846
|
+
(value) => {
|
|
2847
|
+
return String(value).replace(
|
|
2848
|
+
/[a-z]/g,
|
|
2849
|
+
(char) => char.toUpperCase()
|
|
2850
|
+
);
|
|
2851
|
+
}
|
|
2852
|
+
),
|
|
2853
|
+
orderlyUi.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)
|
|
2854
|
+
],
|
|
2855
|
+
onClean: () => {
|
|
2856
|
+
props.setCode("");
|
|
2857
|
+
},
|
|
2858
|
+
label: t("affiliate.referralCode.label"),
|
|
2859
|
+
classNames: {
|
|
2860
|
+
label: "oui-text-2xs oui-text-base-contrast-54"
|
|
2861
|
+
},
|
|
2862
|
+
helpText: !props.isExist && !props.isLoading && props.code.length > 0 ? t("affiliate.referralCode.notExist") : void 0,
|
|
2863
|
+
color: !props.isExist && !props.isLoading && props.code.length > 0 ? "danger" : void 0
|
|
2864
|
+
}
|
|
2865
|
+
),
|
|
2866
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", gapY: 3, mt: 6, children: [
|
|
2867
|
+
props.warningMessage && /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "2xs", className: "oui-text-warning-darken", children: props.warningMessage }),
|
|
2868
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUiConnector.AuthGuard, { buttonProps: { size: "md", fullWidth: true }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2869
|
+
orderlyUi.Button,
|
|
2870
|
+
{
|
|
2871
|
+
variant: "contained",
|
|
2872
|
+
color: "primary",
|
|
2873
|
+
size: "md",
|
|
2874
|
+
className: "oui-px-[40px]",
|
|
2875
|
+
fullWidth: true,
|
|
2876
|
+
disabled: props.code.length < 4 || !props.isExist,
|
|
2877
|
+
onClick: (e) => {
|
|
2878
|
+
e.stopPropagation();
|
|
2879
|
+
props.onClickConfirm();
|
|
2880
|
+
},
|
|
2881
|
+
children: t("common.confirm")
|
|
2882
|
+
}
|
|
2883
|
+
) })
|
|
2884
|
+
] })
|
|
2885
|
+
] })
|
|
2886
|
+
] })
|
|
2887
|
+
] });
|
|
2888
|
+
};
|
|
2889
|
+
var useAsTraderScript = () => {
|
|
2890
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2891
|
+
const {
|
|
2892
|
+
isTrader,
|
|
2893
|
+
referralInfo,
|
|
2894
|
+
setShowHome,
|
|
2895
|
+
bindReferralCodeState,
|
|
2896
|
+
setTab,
|
|
2897
|
+
mutate
|
|
2898
|
+
} = useReferralContext();
|
|
2899
|
+
const { wrongNetwork, disabledConnect } = orderlyReactApp.useAppContext();
|
|
2900
|
+
const { state } = orderlyHooks.useAccount();
|
|
2901
|
+
const onEnterTraderPage = () => {
|
|
2902
|
+
setTab("trader" /* trader */);
|
|
2903
|
+
setShowHome(false);
|
|
2904
|
+
};
|
|
2905
|
+
const [code, setCode] = react.useState("");
|
|
2906
|
+
const [open, setOpen] = react.useState(false);
|
|
2907
|
+
const {
|
|
2908
|
+
isExist,
|
|
2909
|
+
error: checkCodeError,
|
|
2910
|
+
isLoading
|
|
2911
|
+
} = orderlyHooks.useCheckReferralCode(code);
|
|
2912
|
+
const hide = () => {
|
|
2913
|
+
setOpen(false);
|
|
2914
|
+
};
|
|
2915
|
+
const [bindCode, { error, isMutating }] = orderlyHooks.useMutation(
|
|
2916
|
+
"/v1/referral/bind",
|
|
2917
|
+
"POST"
|
|
2918
|
+
);
|
|
2919
|
+
const onClickConfirm = async () => {
|
|
2920
|
+
try {
|
|
2921
|
+
await bindCode({ referral_code: code });
|
|
2922
|
+
orderlyUi.toast.success(t("affiliate.referralCode.bound"));
|
|
2923
|
+
mutate();
|
|
2924
|
+
if (bindReferralCodeState) {
|
|
2925
|
+
bindReferralCodeState(true, null, hide, { tab: 1 });
|
|
2926
|
+
} else {
|
|
2927
|
+
hide();
|
|
2928
|
+
}
|
|
2929
|
+
} catch (e) {
|
|
2930
|
+
let errorText = `${e}`;
|
|
2931
|
+
if ("message" in e) {
|
|
2932
|
+
errorText = e.message;
|
|
2933
|
+
}
|
|
2934
|
+
if ("referral code not exist" === errorText) {
|
|
2935
|
+
errorText = t("affiliate.referralCode.notExist");
|
|
2936
|
+
}
|
|
2937
|
+
if (bindReferralCodeState) {
|
|
2938
|
+
orderlyUi.toast.error(errorText);
|
|
2939
|
+
bindReferralCodeState(false, e, hide, {});
|
|
2940
|
+
} else {
|
|
2941
|
+
orderlyUi.toast.error(errorText);
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
};
|
|
2945
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
2946
|
+
const authStatus = orderlyUiConnector.useAuthStatus();
|
|
2947
|
+
const warningMessage = react.useMemo(() => {
|
|
2948
|
+
const message = {
|
|
2949
|
+
[orderlyUiConnector.AuthStatusEnum.ConnectWallet]: t("affiliate.connectWallet.tooltip"),
|
|
2950
|
+
[orderlyUiConnector.AuthStatusEnum.CreateAccount]: t("affiliate.createAccount.tooltip"),
|
|
2951
|
+
[orderlyUiConnector.AuthStatusEnum.WrongNetwork]: t("connector.wrongNetwork.tooltip")
|
|
2952
|
+
};
|
|
2953
|
+
return message[authStatus];
|
|
2954
|
+
}, [authStatus]);
|
|
2955
|
+
return {
|
|
2956
|
+
isTrader,
|
|
2957
|
+
isLoading,
|
|
2958
|
+
referralInfo,
|
|
2959
|
+
onEnterTraderPage,
|
|
2960
|
+
code,
|
|
2961
|
+
setCode,
|
|
2962
|
+
open,
|
|
2963
|
+
setOpen,
|
|
2964
|
+
onClickConfirm,
|
|
2965
|
+
isExist,
|
|
2966
|
+
wrongNetwork,
|
|
2967
|
+
isMobile,
|
|
2968
|
+
warningMessage
|
|
2969
|
+
};
|
|
2970
|
+
};
|
|
2971
|
+
var AsTraderWidget = () => {
|
|
2972
|
+
const state = useAsTraderScript();
|
|
2973
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AsTrader, { ...state });
|
|
2974
|
+
};
|
|
2975
|
+
var AsAnAffiliate = (props) => {
|
|
2976
|
+
const { t } = orderlyI18n.useTranslation();
|
|
2977
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2978
|
+
orderlyUi.Flex,
|
|
2979
|
+
{
|
|
2980
|
+
id: "oui-affiliate-home-asAnAffiliate",
|
|
2981
|
+
gradient: "primary",
|
|
2982
|
+
r: "2xl",
|
|
2983
|
+
p: 6,
|
|
2984
|
+
gap: 6,
|
|
2985
|
+
direction: "column",
|
|
2986
|
+
angle: 180,
|
|
2987
|
+
width: "100%",
|
|
2988
|
+
justify: "between",
|
|
2989
|
+
children: [
|
|
2990
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2991
|
+
orderlyUi.Flex,
|
|
2992
|
+
{
|
|
2993
|
+
direction: "row",
|
|
2994
|
+
gap: 3,
|
|
2995
|
+
itemAlign: "start",
|
|
2996
|
+
width: "100%",
|
|
2997
|
+
justify: "between",
|
|
2998
|
+
children: [
|
|
2999
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3000
|
+
orderlyUi.Flex,
|
|
3001
|
+
{
|
|
3002
|
+
direction: "column",
|
|
3003
|
+
itemAlign: "start",
|
|
3004
|
+
justify: "between",
|
|
3005
|
+
className: "oui-h-full",
|
|
3006
|
+
children: [
|
|
3007
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl", children: props.isAffiliate ? t("common.affiliate") : t("affiliate.asAffiliate.title") }),
|
|
3008
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3009
|
+
orderlyUi.Text,
|
|
3010
|
+
{
|
|
3011
|
+
className: orderlyUi.cn(
|
|
3012
|
+
"oui-text-xs oui-text-base-contrast-54 md:oui-text-sm 2xl:oui-text-base",
|
|
3013
|
+
props.isAffiliate && "oui-hidden"
|
|
3014
|
+
),
|
|
3015
|
+
children: t("affiliate.asAffiliate.description")
|
|
3016
|
+
}
|
|
3017
|
+
)
|
|
3018
|
+
]
|
|
3019
|
+
}
|
|
3020
|
+
),
|
|
3021
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(Icon2, {}) })
|
|
3022
|
+
]
|
|
3023
|
+
}
|
|
3024
|
+
),
|
|
3025
|
+
/* @__PURE__ */ jsxRuntime.jsx(Bottom2, { ...props })
|
|
3026
|
+
]
|
|
3027
|
+
}
|
|
3028
|
+
);
|
|
3029
|
+
};
|
|
3030
|
+
var Icon2 = () => {
|
|
3031
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3032
|
+
"svg",
|
|
3033
|
+
{
|
|
3034
|
+
width: "72",
|
|
3035
|
+
height: "72",
|
|
3036
|
+
viewBox: "0 0 72 72",
|
|
3037
|
+
fill: "none",
|
|
3038
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3039
|
+
className: "xl:oui-size-[90px]",
|
|
3040
|
+
children: [
|
|
3041
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3042
|
+
"path",
|
|
3043
|
+
{
|
|
3044
|
+
d: "M35.997 5.86c-16.569 0-29.944 13.43-30 30-.056 16.545 13.445 30.06 30 30.093s30.03-13.665 30-30.093c-.03-16.57-13.432-30-30-30m0 6c13.255 0 24 10.746 24 24 0 6.75-2.812 12.834-7.297 17.196-2.209-4.78-6.955-8.196-12.39-8.196h-8.626c-5.432 0-10.164 3.375-12.375 8.157-4.485-4.362-7.312-10.407-7.312-17.157 0-13.254 10.745-24 24-24m0 6c-6.628 0-12 5.373-12 12s5.372 12 12 12c6.627 0 12-5.373 12-12s-5.373-12-12-12",
|
|
3045
|
+
fill: "#fff",
|
|
3046
|
+
fillOpacity: ".2"
|
|
3047
|
+
}
|
|
3048
|
+
),
|
|
3049
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3050
|
+
"path",
|
|
3051
|
+
{
|
|
3052
|
+
d: "M72 57c0 8.284-6.716 15-15 15s-15-6.716-15-15 6.716-15 15-15 15 6.716 15 15",
|
|
3053
|
+
fill: "#1828C3"
|
|
3054
|
+
}
|
|
3055
|
+
),
|
|
3056
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3057
|
+
"path",
|
|
3058
|
+
{
|
|
3059
|
+
d: "M53.624 51.45a4.125 4.125 0 0 0-4.125 4.125c0 2.388 1.36 4.641 3.61 6.703a21 21 0 0 0 2.414 1.875c.287.194.556.37.797.516.147.089.243.154.304.187a.79.79 0 0 0 .75 0c.061-.033.158-.098.305-.187.24-.147.51-.322.797-.516a21 21 0 0 0 2.414-1.875c2.25-2.062 3.61-4.315 3.61-6.703a4.125 4.125 0 0 0-4.126-4.125c-1.294 0-2.557.705-3.351 1.734-.775-1.047-2.034-1.734-3.399-1.734",
|
|
3060
|
+
fill: "#fff",
|
|
3061
|
+
fillOpacity: ".98"
|
|
3062
|
+
}
|
|
3063
|
+
)
|
|
3064
|
+
]
|
|
3065
|
+
}
|
|
3066
|
+
);
|
|
3067
|
+
};
|
|
3068
|
+
var Bottom2 = (props) => {
|
|
3069
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3070
|
+
const content = () => {
|
|
3071
|
+
if (props.isAffiliate && !props.wrongNetwork) {
|
|
3072
|
+
const totalReferrerRebate = props.referralInfo?.referrer_info?.total_referrer_rebate;
|
|
3073
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3074
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", itemAlign: "start", gap: 2, children: [
|
|
3075
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Text, { className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm", children: [
|
|
3076
|
+
t("affiliate.commission"),
|
|
3077
|
+
" ",
|
|
3078
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 36, children: "(USDC)" })
|
|
3079
|
+
] }),
|
|
3080
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", gap: 1, children: [
|
|
3081
|
+
/* @__PURE__ */ jsxRuntime.jsx(USDCIcon, {}),
|
|
3082
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl", children: orderlyUtils.commifyOptional(totalReferrerRebate, {
|
|
3083
|
+
fix: 2,
|
|
3084
|
+
fallback: "0"
|
|
3085
|
+
}) })
|
|
3086
|
+
] })
|
|
3087
|
+
] }),
|
|
3088
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3089
|
+
orderlyUi.Flex,
|
|
3090
|
+
{
|
|
3091
|
+
direction: "row",
|
|
3092
|
+
gap: 1,
|
|
3093
|
+
justify: "end",
|
|
3094
|
+
itemAlign: "center",
|
|
3095
|
+
className: "oui-cursor-pointer",
|
|
3096
|
+
onClick: props.onEnterAffiliatePage,
|
|
3097
|
+
children: [
|
|
3098
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-sm md:oui-text-base xl:oui-text-lg", children: t("affiliate.enter") }),
|
|
3099
|
+
/* @__PURE__ */ jsxRuntime.jsx(ArrowRightIcon, { className: "md:oui-size-[18px] lg:oui-size-[20px] xl:oui-size-[24px]" })
|
|
3100
|
+
]
|
|
3101
|
+
}
|
|
3102
|
+
)
|
|
3103
|
+
] });
|
|
3104
|
+
}
|
|
3105
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3106
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3107
|
+
orderlyUi.Button,
|
|
3108
|
+
{
|
|
3109
|
+
variant: "contained",
|
|
3110
|
+
color: "light",
|
|
3111
|
+
onClick: props.becomeAnAffiliate,
|
|
3112
|
+
children: t("affiliate.asAffiliate.button")
|
|
3113
|
+
}
|
|
3114
|
+
),
|
|
3115
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3116
|
+
orderlyUi.Flex,
|
|
3117
|
+
{
|
|
3118
|
+
direction: "column",
|
|
3119
|
+
justify: "between",
|
|
3120
|
+
className: "oui-h-full",
|
|
3121
|
+
itemAlign: "end",
|
|
3122
|
+
children: [
|
|
3123
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-base md:oui-text-lg lg:oui-text-xl 2xl:oui-text-2xl", children: t("affiliate.upTo") }),
|
|
3124
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-2xs oui-text-base-contrast-54 md:oui-text-xs 2xl:oui-text-sm", children: t("affiliate.commission") })
|
|
3125
|
+
]
|
|
3126
|
+
}
|
|
3127
|
+
)
|
|
3128
|
+
] });
|
|
3129
|
+
};
|
|
3130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3131
|
+
orderlyUi.Flex,
|
|
3132
|
+
{
|
|
3133
|
+
direction: "row",
|
|
3134
|
+
justify: "between",
|
|
3135
|
+
width: "100%",
|
|
3136
|
+
itemAlign: "end",
|
|
3137
|
+
children: content()
|
|
3138
|
+
}
|
|
3139
|
+
);
|
|
3140
|
+
};
|
|
3141
|
+
var useAsAnAffiliateScript = () => {
|
|
3142
|
+
const {
|
|
3143
|
+
isAffiliate,
|
|
3144
|
+
isLoading,
|
|
3145
|
+
referralInfo,
|
|
3146
|
+
becomeAnAffiliateUrl,
|
|
3147
|
+
setShowHome,
|
|
3148
|
+
setTab
|
|
3149
|
+
} = useReferralContext();
|
|
3150
|
+
const { wrongNetwork } = orderlyReactApp.useAppContext();
|
|
3151
|
+
const becomeAnAffiliate = () => {
|
|
3152
|
+
window.open(becomeAnAffiliateUrl, "_blank");
|
|
3153
|
+
};
|
|
3154
|
+
const onEnterAffiliatePage = () => {
|
|
3155
|
+
setTab("affiliate" /* affiliate */);
|
|
3156
|
+
setShowHome(false);
|
|
3157
|
+
};
|
|
3158
|
+
const { isMobile } = orderlyUi.useScreen();
|
|
3159
|
+
return {
|
|
3160
|
+
isAffiliate,
|
|
3161
|
+
isLoading,
|
|
3162
|
+
referralInfo,
|
|
3163
|
+
onEnterAffiliatePage,
|
|
3164
|
+
becomeAnAffiliate,
|
|
3165
|
+
wrongNetwork,
|
|
3166
|
+
isMobile
|
|
3167
|
+
};
|
|
3168
|
+
};
|
|
3169
|
+
var AsAnAffiliateWidget = () => {
|
|
3170
|
+
const state = useAsAnAffiliateScript();
|
|
3171
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AsAnAffiliate, { ...state });
|
|
3172
|
+
};
|
|
3173
|
+
var Card = (props) => {
|
|
3174
|
+
if (typeof props.overwrite === "function") {
|
|
3175
|
+
return props.overwrite?.(props.state);
|
|
3176
|
+
}
|
|
3177
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3178
|
+
orderlyUi.Flex,
|
|
3179
|
+
{
|
|
3180
|
+
id: "oui-affiliate-home-card",
|
|
3181
|
+
className: "oui-flex oui-w-full oui-flex-col oui-items-stretch oui-gap-6 xl:oui-flex-row xl:oui-gap-[36px]",
|
|
3182
|
+
children: [
|
|
3183
|
+
/* @__PURE__ */ jsxRuntime.jsx(AsAnAffiliateWidget, {}),
|
|
3184
|
+
/* @__PURE__ */ jsxRuntime.jsx(AsTraderWidget, {})
|
|
3185
|
+
]
|
|
3186
|
+
}
|
|
3187
|
+
);
|
|
3188
|
+
};
|
|
3189
|
+
|
|
3190
|
+
// src/pages/home/card/card.script.tsx
|
|
3191
|
+
var useCardScript = () => {
|
|
3192
|
+
const state = useReferralContext();
|
|
3193
|
+
return {
|
|
3194
|
+
overwrite: state.overwrite?.ref?.card,
|
|
3195
|
+
state
|
|
3196
|
+
};
|
|
3197
|
+
};
|
|
3198
|
+
var CardWidget = () => {
|
|
3199
|
+
const state = useCardScript();
|
|
3200
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Card, { ...state });
|
|
3201
|
+
};
|
|
3202
|
+
var HomePage = () => {
|
|
3203
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3204
|
+
orderlyUi.Flex,
|
|
3205
|
+
{
|
|
3206
|
+
id: "oui-affiliate-home-page",
|
|
3207
|
+
className: orderlyUi.cn(
|
|
3208
|
+
"oui-h-lvw ",
|
|
3209
|
+
// padding
|
|
3210
|
+
// "oui-p-4 lg:oui-p-6 xl:oui-p-3",
|
|
3211
|
+
"oui-font-semibold"
|
|
3212
|
+
),
|
|
3213
|
+
direction: "column",
|
|
3214
|
+
gap: 4,
|
|
3215
|
+
children: [
|
|
3216
|
+
/* @__PURE__ */ jsxRuntime.jsx(TopWidget, {}),
|
|
3217
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardWidget, {}),
|
|
3218
|
+
/* @__PURE__ */ jsxRuntime.jsx(BecomeAffiliateWidget, {})
|
|
3219
|
+
]
|
|
3220
|
+
}
|
|
3221
|
+
);
|
|
3222
|
+
};
|
|
3223
|
+
var Summary2 = (props) => {
|
|
3224
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3225
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3226
|
+
orderlyUi.Flex,
|
|
3227
|
+
{
|
|
3228
|
+
id: "oui-affiliate-trader-summary",
|
|
3229
|
+
r: "2xl",
|
|
3230
|
+
p: 6,
|
|
3231
|
+
width: "100%",
|
|
3232
|
+
height: "100%",
|
|
3233
|
+
gap: 4,
|
|
3234
|
+
direction: "column",
|
|
3235
|
+
className: "oui-bg-base-9 xl:oui-flex-1",
|
|
3236
|
+
children: [
|
|
3237
|
+
/* @__PURE__ */ jsxRuntime.jsx(Title6, { ...props }),
|
|
3238
|
+
/* @__PURE__ */ jsxRuntime.jsx(Rebate, { className: "md:oui-hidden", ...props }),
|
|
3239
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", gap: 3, width: "100%", className: "md:oui-mt-3", children: [
|
|
3240
|
+
/* @__PURE__ */ jsxRuntime.jsx(SummaryFilter, { ...props }),
|
|
3241
|
+
/* @__PURE__ */ jsxRuntime.jsx(CommissionData2, { ...props })
|
|
3242
|
+
] }),
|
|
3243
|
+
/* @__PURE__ */ jsxRuntime.jsx(Row2, { title: `${t("affiliate.trader.tradingVol")} (USDC)`, ...props })
|
|
3244
|
+
]
|
|
3245
|
+
}
|
|
3246
|
+
);
|
|
3247
|
+
};
|
|
3248
|
+
var Title6 = (props) => {
|
|
3249
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3250
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", width: "100%", gap: 3, children: [
|
|
3251
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", gap: 3, className: "oui-flex-1", children: [
|
|
3252
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-lg", children: t("affiliate.trader.yourReferrer") }),
|
|
3253
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3254
|
+
orderlyUi.Button,
|
|
3255
|
+
{
|
|
3256
|
+
color: "secondary",
|
|
3257
|
+
size: "sm",
|
|
3258
|
+
className: "oui-text-primary-light oui-text-2xs md:oui-text-xs 2xl:oui-text-sm oui-bg-base-6",
|
|
3259
|
+
children: props.code
|
|
3260
|
+
}
|
|
3261
|
+
)
|
|
3262
|
+
] }),
|
|
3263
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3264
|
+
Rebate,
|
|
3265
|
+
{
|
|
3266
|
+
className: "oui-hidden md:oui-flex md:oui-flex-shrink md:oui-w-fit",
|
|
3267
|
+
...props
|
|
3268
|
+
}
|
|
3269
|
+
)
|
|
3270
|
+
] });
|
|
3271
|
+
};
|
|
3272
|
+
var Rebate = (props) => {
|
|
3273
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3274
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", width: "100%", gap: 2, className: props.className, children: [
|
|
3275
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3276
|
+
orderlyUi.Text,
|
|
3277
|
+
{
|
|
3278
|
+
intensity: 54,
|
|
3279
|
+
className: "oui-text-sm md:oui-text-base 2xl:oui-text-lg",
|
|
3280
|
+
children: `${t("affiliate.trader.rebate")}:`
|
|
3281
|
+
}
|
|
3282
|
+
),
|
|
3283
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3284
|
+
orderlyUi.Text.gradient,
|
|
3285
|
+
{
|
|
3286
|
+
color: "brand",
|
|
3287
|
+
className: "oui-text-lg md:oui-text-xl 2xl:oui-text-2xl",
|
|
3288
|
+
children: props.rebateText
|
|
3289
|
+
}
|
|
3290
|
+
)
|
|
3291
|
+
] });
|
|
3292
|
+
};
|
|
3293
|
+
var SummaryFilter = (props) => {
|
|
3294
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3295
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", width: "100%", justify: "between", gap: 3, children: [
|
|
3296
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-sm", children: t("affiliate.summary") }),
|
|
3297
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3298
|
+
orderlyUi.Select.options,
|
|
3299
|
+
{
|
|
3300
|
+
size: "xs",
|
|
3301
|
+
value: props.period,
|
|
3302
|
+
onValueChange: props.onPeriodChange,
|
|
3303
|
+
options: props.periodTypes
|
|
3304
|
+
}
|
|
3305
|
+
) })
|
|
3306
|
+
] });
|
|
3307
|
+
};
|
|
3308
|
+
var CommissionData2 = (props) => {
|
|
3309
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3310
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3311
|
+
orderlyUi.Flex,
|
|
3312
|
+
{
|
|
3313
|
+
gradient: "success",
|
|
3314
|
+
angle: 180,
|
|
3315
|
+
r: "xl",
|
|
3316
|
+
py: 4,
|
|
3317
|
+
px: 6,
|
|
3318
|
+
width: "100%",
|
|
3319
|
+
direction: "column",
|
|
3320
|
+
gap: 3,
|
|
3321
|
+
children: [
|
|
3322
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 54, className: "oui-text-base 2xl:oui-text-lg", children: `${t("affiliate.trader.rebates")} (USDC)` }),
|
|
3323
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3324
|
+
orderlyUi.Flex,
|
|
3325
|
+
{
|
|
3326
|
+
direction: "row",
|
|
3327
|
+
gap: 3,
|
|
3328
|
+
className: "oui-text-xl md:oui-text-2xl xl:oui-text-3xl",
|
|
3329
|
+
children: [
|
|
3330
|
+
/* @__PURE__ */ jsxRuntime.jsx(USDCIcon, { className: "md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] " }),
|
|
3331
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: orderlyUtils.commifyOptional(props.rebates, { fix: 2, fallback: "0" }) })
|
|
3332
|
+
]
|
|
3333
|
+
}
|
|
3334
|
+
)
|
|
3335
|
+
]
|
|
3336
|
+
}
|
|
3337
|
+
);
|
|
3338
|
+
};
|
|
3339
|
+
var Row2 = (props) => {
|
|
3340
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
3341
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3342
|
+
orderlyUi.Text,
|
|
3343
|
+
{
|
|
3344
|
+
intensity: 54,
|
|
3345
|
+
className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm",
|
|
3346
|
+
children: props.title
|
|
3347
|
+
}
|
|
3348
|
+
),
|
|
3349
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-xs md:oui-text-sm xl:oui-text-base", children: orderlyUtils.commifyOptional(props.vol, { fix: 2, fallback: "0" }) })
|
|
3350
|
+
] });
|
|
3351
|
+
};
|
|
3352
|
+
var useSummaryScript2 = () => {
|
|
3353
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3354
|
+
const [period, setPeriod] = react.useState("All");
|
|
3355
|
+
const periodTypes = [
|
|
3356
|
+
{ label: t("common.all"), value: "All" },
|
|
3357
|
+
{ label: t("common.select.1d"), value: "1D" },
|
|
3358
|
+
{ label: t("common.select.7d"), value: "7D" },
|
|
3359
|
+
{ label: t("common.select.30d"), value: "30D" }
|
|
3360
|
+
];
|
|
3361
|
+
const { referralInfo, userVolume } = useReferralContext();
|
|
3362
|
+
const rebates = react.useMemo(() => {
|
|
3363
|
+
if (!referralInfo)
|
|
3364
|
+
return 0;
|
|
3365
|
+
switch (period) {
|
|
3366
|
+
case "All":
|
|
3367
|
+
return referralInfo.referee_info.total_referee_rebate;
|
|
3368
|
+
case "1D":
|
|
3369
|
+
return referralInfo.referee_info["1d_referee_rebate"];
|
|
3370
|
+
case "7D":
|
|
3371
|
+
return referralInfo.referee_info["7d_referee_rebate"];
|
|
3372
|
+
case "30D":
|
|
3373
|
+
return referralInfo.referee_info["30d_referee_rebate"];
|
|
3374
|
+
}
|
|
3375
|
+
}, [referralInfo, period]);
|
|
3376
|
+
const vol = react.useMemo(() => {
|
|
3377
|
+
if (!userVolume)
|
|
3378
|
+
return void 0;
|
|
3379
|
+
switch (period) {
|
|
3380
|
+
case "All":
|
|
3381
|
+
return userVolume.all_volume;
|
|
3382
|
+
case "1D":
|
|
3383
|
+
return userVolume["1d_volume"];
|
|
3384
|
+
case "7D":
|
|
3385
|
+
return userVolume["7d_volume"];
|
|
3386
|
+
case "30D":
|
|
3387
|
+
return userVolume["30d_volume"];
|
|
3388
|
+
}
|
|
3389
|
+
}, [userVolume, period]);
|
|
3390
|
+
const code = referralInfo?.referee_info?.referer_code;
|
|
3391
|
+
const rebate = referralInfo?.referee_info?.referee_rebate_rate;
|
|
3392
|
+
const rebateText = react.useMemo(() => {
|
|
3393
|
+
if (!!rebate) {
|
|
3394
|
+
return new orderlyUtils.Decimal(rebate).mul(100).toDecimalPlaces(2, orderlyUtils.Decimal.ROUND_DOWN).toString() + "%";
|
|
3395
|
+
}
|
|
3396
|
+
return "-";
|
|
3397
|
+
}, [rebate]);
|
|
3398
|
+
const onPeriodChange = (item) => {
|
|
3399
|
+
setPeriod(item);
|
|
3400
|
+
};
|
|
3401
|
+
return {
|
|
3402
|
+
period,
|
|
3403
|
+
periodTypes,
|
|
3404
|
+
onPeriodChange,
|
|
3405
|
+
rebates,
|
|
3406
|
+
vol,
|
|
3407
|
+
rebateText,
|
|
3408
|
+
code
|
|
3409
|
+
};
|
|
3410
|
+
};
|
|
3411
|
+
var SummaryWidget2 = () => {
|
|
3412
|
+
const state = useSummaryScript2();
|
|
3413
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Summary2, { ...state });
|
|
3414
|
+
};
|
|
3415
|
+
var TitleStatistic2 = (props) => {
|
|
3416
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3417
|
+
orderlyUi.Flex,
|
|
3418
|
+
{
|
|
3419
|
+
id: "oui-affiliate-trader-titleStatistic",
|
|
3420
|
+
r: "2xl",
|
|
3421
|
+
p: 6,
|
|
3422
|
+
width: "100%",
|
|
3423
|
+
gap: 4,
|
|
3424
|
+
direction: "column",
|
|
3425
|
+
className: "oui-bg-base-9 xl:oui-flex-1",
|
|
3426
|
+
children: [
|
|
3427
|
+
/* @__PURE__ */ jsxRuntime.jsx(Title7, { ...props }),
|
|
3428
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { className: "oui-min-h-[170px] oui-h-full oui-w-full oui-flex oui-flex-row oui-items-stretch", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3429
|
+
orderlyChart.VolBarChart,
|
|
3430
|
+
{
|
|
3431
|
+
data: props.dataSource,
|
|
3432
|
+
colors: { fill: "rgba(0, 180, 158, 1)" },
|
|
3433
|
+
className: "oui-w-full oui-flex-1",
|
|
3434
|
+
tooltip: {
|
|
3435
|
+
rm: orderlyUtils.Decimal.ROUND_DOWN,
|
|
3436
|
+
dp: props.volType === "volume" ? 2 : 6
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
) })
|
|
3440
|
+
]
|
|
3441
|
+
}
|
|
3442
|
+
);
|
|
3443
|
+
};
|
|
3444
|
+
var Title7 = (props) => {
|
|
3445
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3446
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
3447
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-lg", children: t("affiliate.statistics") }),
|
|
3448
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", gap: 2, className: "oui-min-w-14", children: [
|
|
3449
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3450
|
+
orderlyUi.Select.options,
|
|
3451
|
+
{
|
|
3452
|
+
size: "xs",
|
|
3453
|
+
value: props.period,
|
|
3454
|
+
onValueChange: props.onPeriodChange,
|
|
3455
|
+
options: props.periodTypes
|
|
3456
|
+
}
|
|
3457
|
+
),
|
|
3458
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3459
|
+
orderlyUi.Select.options,
|
|
3460
|
+
{
|
|
3461
|
+
size: "xs",
|
|
3462
|
+
value: props.volType,
|
|
3463
|
+
onValueChange: props.onVolTypeChange,
|
|
3464
|
+
options: props.volTypes
|
|
3465
|
+
}
|
|
3466
|
+
)
|
|
3467
|
+
] })
|
|
3468
|
+
] });
|
|
3469
|
+
};
|
|
3470
|
+
var useTitleStatisticScript2 = () => {
|
|
3471
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3472
|
+
const [period, setPeriod] = react.useState("7");
|
|
3473
|
+
const periodTypes = [
|
|
3474
|
+
{ label: t("common.select.7d"), value: "7" },
|
|
3475
|
+
{ label: t("common.select.30d"), value: "30" },
|
|
3476
|
+
{ label: t("common.select.90d"), value: "90" }
|
|
3477
|
+
];
|
|
3478
|
+
const onPeriodChange = (item) => {
|
|
3479
|
+
setPeriod(item);
|
|
3480
|
+
};
|
|
3481
|
+
const [volType, setVolType] = react.useState("rebate");
|
|
3482
|
+
const volTypes = [
|
|
3483
|
+
{ label: t("affiliate.trader.rebate"), value: "rebate" },
|
|
3484
|
+
{ label: t("common.volume"), value: "volume" }
|
|
3485
|
+
];
|
|
3486
|
+
const onVolTypeChange = (item) => {
|
|
3487
|
+
setVolType(item);
|
|
3488
|
+
};
|
|
3489
|
+
const dateRange = react.useMemo(() => {
|
|
3490
|
+
if (period === "7") {
|
|
3491
|
+
return {
|
|
3492
|
+
startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 7),
|
|
3493
|
+
endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
3494
|
+
};
|
|
3495
|
+
} else if (period === "30") {
|
|
3496
|
+
return {
|
|
3497
|
+
startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 30),
|
|
3498
|
+
endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
3499
|
+
};
|
|
3500
|
+
} else if (period === "90") {
|
|
3501
|
+
return {
|
|
3502
|
+
startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
|
|
3503
|
+
endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
3504
|
+
};
|
|
3505
|
+
} else {
|
|
3506
|
+
return {
|
|
3507
|
+
startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 7),
|
|
3508
|
+
endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
3509
|
+
};
|
|
3510
|
+
}
|
|
3511
|
+
}, [period]);
|
|
3512
|
+
const { data: distributionData, mutate } = orderlyHooks.useRefereeRebateSummary(dateRange);
|
|
3513
|
+
const { dailyVolume, chartConfig } = useReferralContext();
|
|
3514
|
+
const dataSource = react.useMemo(() => {
|
|
3515
|
+
if (volType === "rebate") {
|
|
3516
|
+
const newData = distributionData || [];
|
|
3517
|
+
return newData.map((e) => ({
|
|
3518
|
+
date: e.date,
|
|
3519
|
+
volume: e.referee_rebate
|
|
3520
|
+
})).reverse();
|
|
3521
|
+
} else if (volType === "volume") {
|
|
3522
|
+
return dailyVolume?.filter((e) => {
|
|
3523
|
+
return e.date > dateFns.format(dateFns.subDays(Date(), Number(period) + 1), "yyyy-MM-dd");
|
|
3524
|
+
}).map((e) => ({
|
|
3525
|
+
date: e.date,
|
|
3526
|
+
volume: e.perp_volume
|
|
3527
|
+
})) || [];
|
|
3528
|
+
} else {
|
|
3529
|
+
return [];
|
|
3530
|
+
}
|
|
3531
|
+
}, [distributionData, dailyVolume, volType]);
|
|
3532
|
+
return {
|
|
3533
|
+
period,
|
|
3534
|
+
periodTypes,
|
|
3535
|
+
onPeriodChange,
|
|
3536
|
+
volType,
|
|
3537
|
+
volTypes,
|
|
3538
|
+
onVolTypeChange,
|
|
3539
|
+
dataSource: fillData(Number(period), dataSource)
|
|
3540
|
+
};
|
|
3541
|
+
};
|
|
3542
|
+
var TitleStatisticWidget2 = () => {
|
|
3543
|
+
const state = useTitleStatisticScript2();
|
|
3544
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TitleStatistic2, { ...state });
|
|
3545
|
+
};
|
|
3546
|
+
var Rebates = (props) => {
|
|
3547
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3548
|
+
orderlyUi.Flex,
|
|
3549
|
+
{
|
|
3550
|
+
id: "oui-affiliate-trader-rebates",
|
|
3551
|
+
r: "2xl",
|
|
3552
|
+
p: 6,
|
|
3553
|
+
width: "100%",
|
|
3554
|
+
gap: 4,
|
|
3555
|
+
direction: "column",
|
|
3556
|
+
className: "oui-bg-base-9 oui-tabular-nums",
|
|
3557
|
+
children: [
|
|
3558
|
+
/* @__PURE__ */ jsxRuntime.jsx(Title8, { ...props }),
|
|
3559
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3560
|
+
orderlyUi.Flex,
|
|
3561
|
+
{
|
|
3562
|
+
width: "100%",
|
|
3563
|
+
className: "oui-border-y-2 oui-border-line-6",
|
|
3564
|
+
height: 49,
|
|
3565
|
+
direction: "row",
|
|
3566
|
+
itemAlign: "center",
|
|
3567
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3568
|
+
orderlyUi.DatePicker.range,
|
|
3569
|
+
{
|
|
3570
|
+
size: "xs",
|
|
3571
|
+
value: props.dateRange,
|
|
3572
|
+
onChange: (range) => {
|
|
3573
|
+
props.setDateRange(range);
|
|
3574
|
+
},
|
|
3575
|
+
max: 90,
|
|
3576
|
+
disabled: {
|
|
3577
|
+
after: /* @__PURE__ */ new Date()
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
) })
|
|
3581
|
+
}
|
|
3582
|
+
),
|
|
3583
|
+
/* @__PURE__ */ jsxRuntime.jsx(List, { ...props })
|
|
3584
|
+
]
|
|
3585
|
+
}
|
|
3586
|
+
);
|
|
3587
|
+
};
|
|
3588
|
+
var Title8 = (props) => {
|
|
3589
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3590
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", justify: "between", width: "100%", children: [
|
|
3591
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-lg", children: t("affiliate.trader.myRebates") }),
|
|
3592
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { intensity: 36, className: "oui-text-2xs", children: props.displayDate })
|
|
3593
|
+
] });
|
|
3594
|
+
};
|
|
3595
|
+
var List = (props) => {
|
|
3596
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3597
|
+
const layout767 = orderlyHooks.useMediaQuery("(max-width: 767px)");
|
|
3598
|
+
const columns = [
|
|
3599
|
+
{
|
|
3600
|
+
title: `${t("affiliate.trader.rebates")} (USDC)`,
|
|
3601
|
+
dataIndex: "referee_rebate",
|
|
3602
|
+
render: (value) => /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: orderlyUtils.commifyOptional(value, {
|
|
3603
|
+
fix: 6,
|
|
3604
|
+
fallback: "0",
|
|
3605
|
+
padEnd: true,
|
|
3606
|
+
prefix: "$"
|
|
3607
|
+
}) }),
|
|
3608
|
+
width: 127
|
|
3609
|
+
},
|
|
3610
|
+
{
|
|
3611
|
+
title: `${t("affiliate.trader.tradingVol")} (USDC)`,
|
|
3612
|
+
dataIndex: "vol",
|
|
3613
|
+
render: (value) => orderlyUtils.commifyOptional(value, {
|
|
3614
|
+
fix: 2,
|
|
3615
|
+
fallback: "0",
|
|
3616
|
+
padEnd: true,
|
|
3617
|
+
prefix: "$"
|
|
3618
|
+
}),
|
|
3619
|
+
width: 127
|
|
3620
|
+
},
|
|
3621
|
+
{
|
|
3622
|
+
title: t("common.date"),
|
|
3623
|
+
dataIndex: "date",
|
|
3624
|
+
render: (value) => /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.formatted, { formatString: "yyyy-MM-dd", children: value }),
|
|
3625
|
+
width: 127
|
|
3626
|
+
}
|
|
3627
|
+
];
|
|
3628
|
+
if (layout767) {
|
|
3629
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3630
|
+
orderlyUi.ListView,
|
|
3631
|
+
{
|
|
3632
|
+
dataSource: props.dataSource,
|
|
3633
|
+
className: "oui-h-[197px] oui-w-full",
|
|
3634
|
+
renderItem: (item, index) => {
|
|
3635
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Cell, { item });
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
);
|
|
3639
|
+
}
|
|
3640
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3641
|
+
orderlyUiConnector.AuthGuardDataTable,
|
|
3642
|
+
{
|
|
3643
|
+
bordered: true,
|
|
3644
|
+
loading: props.isLoading,
|
|
3645
|
+
columns,
|
|
3646
|
+
dataSource: props.dataSource,
|
|
3647
|
+
ignoreLoadingCheck: true,
|
|
3648
|
+
onRow: (record) => {
|
|
3649
|
+
return {
|
|
3650
|
+
className: "oui-h-[41px]"
|
|
3651
|
+
};
|
|
3652
|
+
},
|
|
3653
|
+
pagination: props.pagination,
|
|
3654
|
+
manualPagination: false
|
|
3655
|
+
}
|
|
3656
|
+
);
|
|
3657
|
+
};
|
|
3658
|
+
var Cell = (props) => {
|
|
3659
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3660
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "column", width: "100%", children: [
|
|
3661
|
+
/* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { width: "100%", gap: 1, children: [
|
|
3662
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3663
|
+
orderlyUi.Statistic,
|
|
3664
|
+
{
|
|
3665
|
+
label: `${t("affiliate.trader.rebates")} (USDC)`,
|
|
3666
|
+
className: "oui-text-xs oui-text-base-contrast-54 oui-flex-1 oui-min-w-[105px]",
|
|
3667
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", intensity: 80, children: orderlyUtils.commifyOptional(props.item.referee_rebate, {
|
|
3668
|
+
fix: 6,
|
|
3669
|
+
fallback: "0",
|
|
3670
|
+
padEnd: true,
|
|
3671
|
+
prefix: "$"
|
|
3672
|
+
}) })
|
|
3673
|
+
}
|
|
3674
|
+
),
|
|
3675
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3676
|
+
orderlyUi.Statistic,
|
|
3677
|
+
{
|
|
3678
|
+
label: `${t("affiliate.trader.tradingVol")} (USDC)`,
|
|
3679
|
+
className: "oui-text-xs oui-text-base-contrast-54 oui-flex-shrink",
|
|
3680
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { size: "sm", intensity: 80, children: orderlyUtils.commifyOptional(props.item.vol, {
|
|
3681
|
+
fix: 2,
|
|
3682
|
+
fallback: "0",
|
|
3683
|
+
padEnd: true,
|
|
3684
|
+
prefix: "$"
|
|
3685
|
+
}) })
|
|
3686
|
+
}
|
|
3687
|
+
),
|
|
3688
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3689
|
+
orderlyUi.Statistic,
|
|
3690
|
+
{
|
|
3691
|
+
label: t("common.date"),
|
|
3692
|
+
className: "oui-text-xs oui-text-base-contrast-54 oui-flex-1",
|
|
3693
|
+
align: "end",
|
|
3694
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text.formatted, { size: "sm", intensity: 80, formatString: "yyyy-MM-dd", children: props.item.date })
|
|
3695
|
+
}
|
|
3696
|
+
)
|
|
3697
|
+
] }),
|
|
3698
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Divider, { className: "oui-w-full oui-mt-3" })
|
|
3699
|
+
] });
|
|
3700
|
+
};
|
|
3701
|
+
var useRebatesScript = () => {
|
|
3702
|
+
const [dateRange, setDateRange] = react.useState({
|
|
3703
|
+
from: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
|
|
3704
|
+
to: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
|
|
3705
|
+
});
|
|
3706
|
+
const {
|
|
3707
|
+
data: distributionData,
|
|
3708
|
+
mutate,
|
|
3709
|
+
isLoading
|
|
3710
|
+
} = orderlyHooks.useRefereeRebateSummary({
|
|
3711
|
+
startDate: dateRange?.from,
|
|
3712
|
+
endDate: dateRange?.to
|
|
3713
|
+
});
|
|
3714
|
+
const { data: dailyVolume, mutate: dailyVolumeMutate } = orderlyHooks.useDaily({
|
|
3715
|
+
startDate: dateRange?.to,
|
|
3716
|
+
endDate: dateRange?.from
|
|
3717
|
+
});
|
|
3718
|
+
const dataSource = react.useMemo(() => {
|
|
3719
|
+
if (typeof distributionData === "undefined")
|
|
3720
|
+
return [];
|
|
3721
|
+
return distributionData.map((item) => {
|
|
3722
|
+
const createdTime = item.date;
|
|
3723
|
+
const volume = dailyVolume?.filter((item2) => {
|
|
3724
|
+
return compareDate(dateFns.toDate(createdTime), dateFns.toDate(item2.date));
|
|
3725
|
+
})?.[0];
|
|
3726
|
+
if (volume) {
|
|
3727
|
+
return { ...item, vol: volume.perp_volume };
|
|
3728
|
+
}
|
|
3729
|
+
return item;
|
|
3730
|
+
});
|
|
3731
|
+
}, [distributionData, dailyVolume]);
|
|
3732
|
+
let displayDate = void 0;
|
|
3733
|
+
if ((dataSource?.length || 0) > 0) {
|
|
3734
|
+
displayDate = formatDateTimeToUTC(dataSource?.[0].date);
|
|
3735
|
+
}
|
|
3736
|
+
const { pagination, setPage } = orderlyUi.usePagination();
|
|
3737
|
+
react.useEffect(() => {
|
|
3738
|
+
setPage(1);
|
|
3739
|
+
}, [dateRange]);
|
|
3740
|
+
return {
|
|
3741
|
+
dateRange,
|
|
3742
|
+
setDateRange,
|
|
3743
|
+
displayDate,
|
|
3744
|
+
dataSource,
|
|
3745
|
+
// meta,
|
|
3746
|
+
// onPageChange,
|
|
3747
|
+
// onPageSizeChange,
|
|
3748
|
+
pagination,
|
|
3749
|
+
isLoading
|
|
3750
|
+
};
|
|
3751
|
+
};
|
|
3752
|
+
var RebatesWidget = () => {
|
|
3753
|
+
const state = useRebatesScript();
|
|
3754
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Rebates, { ...state });
|
|
3755
|
+
};
|
|
3756
|
+
var TraderPage = () => {
|
|
3757
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3758
|
+
orderlyUi.Flex,
|
|
3759
|
+
{
|
|
3760
|
+
id: "oui-affiliate-trader-page",
|
|
3761
|
+
className: orderlyUi.cn(
|
|
3762
|
+
"oui-h-lvw oui-w-full",
|
|
3763
|
+
// padding
|
|
3764
|
+
// "oui-p-4 lg:oui-p-6 xl:oui-p-3",
|
|
3765
|
+
"oui-font-semibold"
|
|
3766
|
+
),
|
|
3767
|
+
direction: "column",
|
|
3768
|
+
gap: 4,
|
|
3769
|
+
children: [
|
|
3770
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3771
|
+
orderlyUi.Flex,
|
|
3772
|
+
{
|
|
3773
|
+
width: "100%",
|
|
3774
|
+
gap: 4,
|
|
3775
|
+
className: "oui-flex oui-flex-col xl:oui-flex-row xl:oui-items-stretch",
|
|
3776
|
+
children: [
|
|
3777
|
+
/* @__PURE__ */ jsxRuntime.jsx(SummaryWidget2, {}),
|
|
3778
|
+
/* @__PURE__ */ jsxRuntime.jsx(TitleStatisticWidget2, {})
|
|
3779
|
+
]
|
|
3780
|
+
}
|
|
3781
|
+
),
|
|
3782
|
+
/* @__PURE__ */ jsxRuntime.jsx(RebatesWidget, {})
|
|
3783
|
+
]
|
|
3784
|
+
}
|
|
3785
|
+
);
|
|
3786
|
+
};
|
|
3787
|
+
var Tab = (props) => {
|
|
3788
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3789
|
+
const extendNode = () => {
|
|
3790
|
+
if (props.isAffiliate && !props.isTrader) {
|
|
3791
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3792
|
+
orderlyUi.Button,
|
|
3793
|
+
{
|
|
3794
|
+
variant: "contained",
|
|
3795
|
+
color: "success",
|
|
3796
|
+
size: "sm",
|
|
3797
|
+
className: "oui-px-2 oui-flex oui-gap-1",
|
|
3798
|
+
style: {
|
|
3799
|
+
position: "absolute",
|
|
3800
|
+
top: "50%",
|
|
3801
|
+
right: "24px",
|
|
3802
|
+
transform: "translateY(-50%)"
|
|
3803
|
+
},
|
|
3804
|
+
onClick: (e) => {
|
|
3805
|
+
props.anATrader();
|
|
3806
|
+
},
|
|
3807
|
+
children: [
|
|
3808
|
+
/* @__PURE__ */ jsxRuntime.jsx(TraderIcon, {}),
|
|
3809
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: t("affiliate.asTrader.title") })
|
|
3810
|
+
]
|
|
3811
|
+
}
|
|
3812
|
+
);
|
|
3813
|
+
}
|
|
3814
|
+
if (!props.isAffiliate && props.isTrader) {
|
|
3815
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3816
|
+
orderlyUi.Button,
|
|
3817
|
+
{
|
|
3818
|
+
variant: "contained",
|
|
3819
|
+
color: "primary",
|
|
3820
|
+
size: "sm",
|
|
3821
|
+
className: "oui-px-2 oui-flex oui-gap-1",
|
|
3822
|
+
style: {
|
|
3823
|
+
position: "absolute",
|
|
3824
|
+
top: "50%",
|
|
3825
|
+
right: "24px",
|
|
3826
|
+
transform: "translateY(-50%)"
|
|
3827
|
+
},
|
|
3828
|
+
onClick: (e) => {
|
|
3829
|
+
props.anAnAffiliate();
|
|
3830
|
+
},
|
|
3831
|
+
children: [
|
|
3832
|
+
/* @__PURE__ */ jsxRuntime.jsx(AffiliateIcon, {}),
|
|
3833
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: t("affiliate.asAffiliate.title") })
|
|
3834
|
+
]
|
|
3835
|
+
}
|
|
3836
|
+
);
|
|
3837
|
+
}
|
|
3838
|
+
return void 0;
|
|
3839
|
+
};
|
|
3840
|
+
if (props.isLoading) {
|
|
3841
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: orderlyUi.cn("oui-max-w-[960px]", props.classNames?.loadding), children: props.splashPage?.() || /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) });
|
|
3842
|
+
}
|
|
3843
|
+
if (!props.isAffiliate && !props.isTrader || props.showHome) {
|
|
3844
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: orderlyUi.cn("oui-max-w-[960px]", props?.classNames?.home), children: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) });
|
|
3845
|
+
}
|
|
3846
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3847
|
+
orderlyUi.TabsBase,
|
|
3848
|
+
{
|
|
3849
|
+
id: "oui-affiliate-dashboard-tab",
|
|
3850
|
+
value: props.tab,
|
|
3851
|
+
onValueChange: (e) => {
|
|
3852
|
+
props.setTab(e);
|
|
3853
|
+
},
|
|
3854
|
+
className: orderlyUi.cn("oui-w-full", props.classNames?.dashboard),
|
|
3855
|
+
children: [
|
|
3856
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3857
|
+
orderlyUi.TabsList,
|
|
3858
|
+
{
|
|
3859
|
+
className: orderlyUi.cn(
|
|
3860
|
+
"oui-px-6 oui-flex oui-flex-row oui-justify-start oui-h-[44px] oui-relative oui-items-end",
|
|
3861
|
+
"oui-text-base md:oui-text-lg",
|
|
3862
|
+
"oui-rounded-xl oui-bg-base-9",
|
|
3863
|
+
"oui-border oui-border-line-6",
|
|
3864
|
+
props.isAffiliate && props.isTrader && "oui-justify-center"
|
|
3865
|
+
),
|
|
3866
|
+
children: [
|
|
3867
|
+
props.isAffiliate && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3868
|
+
orderlyUi.TabsTrigger,
|
|
3869
|
+
{
|
|
3870
|
+
id: "oui-affiliate-dashboard-tab-affiliate",
|
|
3871
|
+
value: "affiliate" /* affiliate */,
|
|
3872
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", gap: 1, mb: 2, children: [
|
|
3873
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3874
|
+
AffiliateIcon,
|
|
3875
|
+
{
|
|
3876
|
+
fillOpacity: 1,
|
|
3877
|
+
fill: "currentColor",
|
|
3878
|
+
className: props.tab === "affiliate" /* affiliate */ ? "oui-fill-white/[.98]" : "oui-fill-white/[.36]"
|
|
3879
|
+
}
|
|
3880
|
+
),
|
|
3881
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: t("common.affiliate") })
|
|
3882
|
+
] })
|
|
3883
|
+
}
|
|
3884
|
+
),
|
|
3885
|
+
props.isTrader && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3886
|
+
orderlyUi.TabsTrigger,
|
|
3887
|
+
{
|
|
3888
|
+
id: "oui-affiliate-dashboard-tab-trader",
|
|
3889
|
+
value: "trader" /* trader */,
|
|
3890
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { direction: "row", gap: 1, mb: 2, children: [
|
|
3891
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3892
|
+
TraderIcon,
|
|
3893
|
+
{
|
|
3894
|
+
fillOpacity: 1,
|
|
3895
|
+
fill: "currentColor",
|
|
3896
|
+
className: props.tab === "trader" /* trader */ ? "oui-fill-white/[.98]" : "oui-fill-white/[.36]"
|
|
3897
|
+
}
|
|
3898
|
+
),
|
|
3899
|
+
/* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { children: t("affiliate.trader") })
|
|
3900
|
+
] })
|
|
3901
|
+
}
|
|
3902
|
+
),
|
|
3903
|
+
extendNode()
|
|
3904
|
+
]
|
|
3905
|
+
}
|
|
3906
|
+
),
|
|
3907
|
+
props.isAffiliate && /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.TabsContent, { value: "affiliate" /* affiliate */, className: "oui-mt-4", children: /* @__PURE__ */ jsxRuntime.jsx(AffiliatePage, {}) }),
|
|
3908
|
+
props.isTrader && /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.TabsContent, { value: "trader" /* trader */, className: "oui-mt-4", children: /* @__PURE__ */ jsxRuntime.jsx(TraderPage, {}) })
|
|
3909
|
+
]
|
|
3910
|
+
}
|
|
3911
|
+
);
|
|
3912
|
+
};
|
|
3913
|
+
var useTabScript = () => {
|
|
3914
|
+
const {
|
|
3915
|
+
isAffiliate,
|
|
3916
|
+
isTrader,
|
|
3917
|
+
isLoading,
|
|
3918
|
+
splashPage,
|
|
3919
|
+
showHome,
|
|
3920
|
+
setShowHome,
|
|
3921
|
+
tab,
|
|
3922
|
+
setTab
|
|
3923
|
+
} = useReferralContext();
|
|
3924
|
+
const tableValue = react.useMemo(() => {
|
|
3925
|
+
if (isAffiliate && isTrader) {
|
|
3926
|
+
return tab;
|
|
3927
|
+
} else if (isAffiliate && !isTrader) {
|
|
3928
|
+
return "affiliate" /* affiliate */;
|
|
3929
|
+
} else if (!isAffiliate && isTrader) {
|
|
3930
|
+
return "trader" /* trader */;
|
|
3931
|
+
} else {
|
|
3932
|
+
return "affiliate" /* affiliate */;
|
|
3933
|
+
}
|
|
3934
|
+
}, [tab, isAffiliate, isTrader]);
|
|
3935
|
+
react.useEffect(() => {
|
|
3936
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
3937
|
+
const tab2 = searchParams.get("tab");
|
|
3938
|
+
if (tab2) {
|
|
3939
|
+
setTab(tab2);
|
|
3940
|
+
}
|
|
3941
|
+
}, [window.location.search]);
|
|
3942
|
+
const anAnAffiliate = () => {
|
|
3943
|
+
setShowHome(true);
|
|
3944
|
+
};
|
|
3945
|
+
const anATrader = () => {
|
|
3946
|
+
setShowHome(true);
|
|
3947
|
+
};
|
|
3948
|
+
return {
|
|
3949
|
+
setTab,
|
|
3950
|
+
tab: tableValue,
|
|
3951
|
+
isAffiliate,
|
|
3952
|
+
isTrader,
|
|
3953
|
+
isLoading,
|
|
3954
|
+
anAnAffiliate,
|
|
3955
|
+
anATrader,
|
|
3956
|
+
splashPage,
|
|
3957
|
+
showHome,
|
|
3958
|
+
setShowHome
|
|
3959
|
+
// tab: TabTypes.affiliate,
|
|
3960
|
+
// isAffiliate: false,
|
|
3961
|
+
// isTrader: false,
|
|
3962
|
+
// isLoading: false,
|
|
3963
|
+
};
|
|
3964
|
+
};
|
|
3965
|
+
var TabWidget = (props) => {
|
|
3966
|
+
const state = useTabScript();
|
|
3967
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tab, { classNames: props.classNames, ...state });
|
|
3968
|
+
};
|
|
3969
|
+
var DashboardPage = (props) => {
|
|
3970
|
+
const { classNames = {} } = props;
|
|
3971
|
+
const { root, ...rest } = classNames;
|
|
3972
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { id: "oui-affiliate-dashboard-page", className: orderlyUi.cn("oui-w-full oui-tracking-tight", root), children: /* @__PURE__ */ jsxRuntime.jsx(TabWidget, { classNames: rest }) });
|
|
3973
|
+
};
|
|
3974
|
+
var AffiliateLayout = (props) => {
|
|
3975
|
+
const { ...rest } = props;
|
|
3976
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUiScaffold.Scaffold, { leftSidebar: /* @__PURE__ */ jsxRuntime.jsx(LeftSidebar, { ...rest }), children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { mx: 3, my: 6, children: props.children }) });
|
|
3977
|
+
};
|
|
3978
|
+
var LeftSidebar = (props) => {
|
|
3979
|
+
return /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { p: 4, m: 3, border: true, borderColor: 8, r: "xl", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUiScaffold.SideBar, { ...props }) });
|
|
3980
|
+
};
|
|
3981
|
+
var useLayoutBuilder = () => {
|
|
3982
|
+
const [current, setCurrent] = react.useState("/");
|
|
3983
|
+
const { t } = orderlyI18n.useTranslation();
|
|
3984
|
+
const items = react.useMemo(() => {
|
|
3985
|
+
return [
|
|
3986
|
+
{
|
|
3987
|
+
name: t("common.trading"),
|
|
3988
|
+
href: "/",
|
|
3989
|
+
icon: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3990
|
+
"svg",
|
|
3991
|
+
{
|
|
3992
|
+
width: "18",
|
|
3993
|
+
height: "18",
|
|
3994
|
+
viewBox: "0 0 18 18",
|
|
3995
|
+
fill: "none",
|
|
3996
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3997
|
+
children: [
|
|
3998
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3999
|
+
"path",
|
|
4000
|
+
{
|
|
4001
|
+
d: "M4.883 1.5c-.166.01-.393.076-.515.173a2 2 0 0 0-.18.173L.918 6.553a.86.86 0 0 0-.168.475c0 .339.232.543.232.543l7.374 8.633c.005.006.269.301.644.296s.64-.29.644-.296l7.402-8.663s.204-.269.204-.513-.196-.517-.196-.517L13.82 1.848c-.023-.032-.076-.021-.103-.049-.033-.038-.037-.091-.077-.124-.123-.097-.267-.106-.413-.123-.04-.005-.063-.049-.103-.049h-.078zm1.745 1.582h4.744L9 5.795zm-1.675.542 2.294 2.615H3.122zm8.094 0 1.831 2.615h-4.125zM3.328 7.818h4.847v5.672zm6.497 0h4.847c-1.151 1.345-3.422 4.007-4.847 5.672z",
|
|
4002
|
+
fill: "url(#a)"
|
|
4003
|
+
}
|
|
4004
|
+
),
|
|
4005
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4006
|
+
"linearGradient",
|
|
4007
|
+
{
|
|
4008
|
+
id: "a",
|
|
4009
|
+
x1: "17.25",
|
|
4010
|
+
y1: "9",
|
|
4011
|
+
x2: ".75",
|
|
4012
|
+
y2: "9",
|
|
4013
|
+
gradientUnits: "userSpaceOnUse",
|
|
4014
|
+
children: [
|
|
4015
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "rgb(var(--oui-gradient-brand-end))" }),
|
|
4016
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4017
|
+
"stop",
|
|
4018
|
+
{
|
|
4019
|
+
offset: "1",
|
|
4020
|
+
stopColor: "rgb(var(--oui-gradient-brand-start))"
|
|
4021
|
+
}
|
|
4022
|
+
)
|
|
4023
|
+
]
|
|
4024
|
+
}
|
|
4025
|
+
) })
|
|
4026
|
+
]
|
|
4027
|
+
}
|
|
4028
|
+
)
|
|
4029
|
+
},
|
|
4030
|
+
{
|
|
4031
|
+
name: t("common.affiliate"),
|
|
4032
|
+
href: "/affiliate",
|
|
4033
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4034
|
+
"svg",
|
|
4035
|
+
{
|
|
4036
|
+
width: "18",
|
|
4037
|
+
height: "18",
|
|
4038
|
+
viewBox: "0 0 18 18",
|
|
4039
|
+
fill: "none",
|
|
4040
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4041
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4042
|
+
"path",
|
|
4043
|
+
{
|
|
4044
|
+
fillRule: "evenodd",
|
|
4045
|
+
clipRule: "evenodd",
|
|
4046
|
+
d: "M5.625 4.95c0-.746.604-1.35 1.35-1.35h4.05c.746 0 1.35.604 1.35 1.35v4.62L9 12.195 5.625 9.57zm8.624 3.163-.524.407v-.96l.074.05c.193.128.346.302.45.502m-4.42 5.148L14.4 9.705v3.345a1.35 1.35 0 0 1-1.35 1.35h-8.1a1.35 1.35 0 0 1-1.35-1.35V9.705l4.571 3.556c.488.379 1.17.379 1.658 0M4.275 8.52l-.524-.407c.104-.2.257-.374.45-.503l.074-.049zm0-2.581V4.95a2.7 2.7 0 0 1 2.7-2.7h4.05a2.7 2.7 0 0 1 2.7 2.7v.989l.823.548a2.7 2.7 0 0 1 1.202 2.247v4.316a2.7 2.7 0 0 1-2.7 2.7h-8.1a2.7 2.7 0 0 1-2.7-2.7V8.734a2.7 2.7 0 0 1 1.202-2.247zM9 6.089l.111-.118.005-.005a1.08 1.08 0 0 1 1.58.004 1.223 1.223 0 0 1 0 1.668l-1.515 1.62-.004.004c-.1.102-.26.1-.358-.004l-1.516-1.62a1.223 1.223 0 0 1 0-1.668l.004-.004a1.08 1.08 0 0 1 1.58.004z",
|
|
4047
|
+
fill: "#fff",
|
|
4048
|
+
fillOpacity: ".54"
|
|
4049
|
+
}
|
|
4050
|
+
)
|
|
4051
|
+
}
|
|
4052
|
+
)
|
|
4053
|
+
}
|
|
4054
|
+
];
|
|
4055
|
+
}, [t]);
|
|
4056
|
+
return {
|
|
4057
|
+
items,
|
|
4058
|
+
current,
|
|
4059
|
+
// open: sideOpen,
|
|
4060
|
+
// onOpenChange(open) {
|
|
4061
|
+
// setSideOpen(open);
|
|
4062
|
+
// },
|
|
4063
|
+
onItemSelect: (item) => {
|
|
4064
|
+
setCurrent(item.href);
|
|
4065
|
+
}
|
|
4066
|
+
};
|
|
4067
|
+
};
|
|
4068
|
+
var AffiliateLayoutWidget = (props) => {
|
|
4069
|
+
const state = useLayoutBuilder();
|
|
4070
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AffiliateLayout, { ...state, children: props.children });
|
|
4071
|
+
};
|
|
17
4072
|
|
|
18
|
-
exports.AffiliateLayoutWidget =
|
|
19
|
-
exports.Dashboard =
|
|
20
|
-
exports.ReferralContext =
|
|
21
|
-
exports.ReferralProvider =
|
|
22
|
-
exports.TabTypes =
|
|
23
|
-
exports.useReferralContext =
|
|
4073
|
+
exports.AffiliateLayoutWidget = AffiliateLayoutWidget;
|
|
4074
|
+
exports.Dashboard = dashboard_exports;
|
|
4075
|
+
exports.ReferralContext = ReferralContext;
|
|
4076
|
+
exports.ReferralProvider = ReferralProvider;
|
|
4077
|
+
exports.TabTypes = TabTypes;
|
|
4078
|
+
exports.useReferralContext = useReferralContext;
|
|
24
4079
|
//# sourceMappingURL=out.js.map
|
|
25
4080
|
//# sourceMappingURL=index.js.map
|