1import{r as l,u as ae,f as te,j as e,n as T,T as t,L as re,h as le,a as z,z as i}from"./index-BHrSnVe9.js";import{D as ne}from"./DashboardLayout-LhULSQSe.js";import{Q as ie}from"./index-DYOU6VW8.js";import{c as oe}from"./index-CLRZAOI-.js";const pe=()=>{const[w,N]=l.useState(!0),[o,P]=l.useState(null),[m,H]=l.useState(null),[B,F]=l.useState(!0),[M,p]=l.useState(!1),[c,Q]=l.useState({}),[R,k]=l.useState(""),[h,U]=l.useState(""),[q,O]=l.useState(""),[u,ce]=l.useState(!1),[Y,g]=l.useState(!1),[S,_]=l.useState([]),[K,V]=l.useState(null),[G,b]=l.useState(1),[L,C]=l.useState(!1),[j,I]=l.useState(!1),D=l.useRef(null),{t:a,i18n:J}=ae("MyReferrals"),d=J.language;a("programInformation.points",{returnObjects:!0});const E=a("howItWorks.howItWorksSteps",{returnObjects:!0}),X="ref",x=te(s=>s.auth.token);l.useEffect(()=>{(async()=>{try{const[r,n]=await Promise.all([le.get("/data/config.json"),fetch("/assets/animation/lightPanda.json").then(f=>f.json())]);O(r.data.BASE_REFERRAL_URL),P(r.data.BRAND_ID),H(n)}catch(r){console.error("Failed to load initial data",r)}})()},[]);const $=async()=>{try{N(!0),p(!1);const s=await z.post("/customer/referralInfo",{brand_id:o,lang:d},{headers:{Authorization:`Bearer ${x}`}});if(s.data?.success){const r=s.data.data;if(Q(r),r?.customer?.referral_code){k(r?.customer?.referral_code);const n=new URL(q);n.searchParams.set(X,r?.customer?.referral_code),U(n.toString())}F(!!r?.customer?.referral_code),k(r?.customer?.referral_code||"")}else p(!0)}catch(s){p(!0),i.error(s?.response?.data?.message||"Failed to load referral code")}finally{N(!1)}},y=async(s=1,r=!1)=>{try{C(!0);const n=await z.get("/customer/referral-report",{params:{brand_id:o,lang:d,page:s},headers:{Authorization:`Bearer ${x}`}});if(n.data?.success){const f=n.data?.data||[],v=n.data?.pagination;V(v),_(r?f:se=>[...se,...f]),v?.current_page>=v?.last_page?I(!0):I(!1)}}catch(n){i.error(n?.response?.data?.message||"Failed to load referral dashboard")}finally{C(!1)}};l.useEffect(()=>{!o||!x||!m||u||$()},[o,x,m,d]),l.useEffect(()=>{!o||!x||u||(b(1),y(1,!0))},[o,x,d]);const A=async(s,r="Copied to clipboard!")=>{if(!s){i.error("Nothing to copy");return}try{await navigator.clipboard.writeText(s),i.success(r)}catch{i.error("Failed to copy")}},Z=async()=>{try{const s=D.current;if(!s){i.error("QR not available");return}s.toBlob(async r=>{if(!r){i.error("Failed to copy QR");return}const n=new ClipboardItem({"image/png":r});await navigator.clipboard.write([n]),i.success("QR code copied!")})}catch{i.error("Copy not supported in this browser")}},W=s=>s?new Date(s).toLocaleDateString("en-CA"):"-",ee=s=>{switch(s?.toLowerCase()){case"available":return"bg-green-100 text-green-700";case"pending":return"bg-bright-yellow text-black";case"cancelled":return"bg-airchinaRed/10 text-airchinaRed";default:return"bg-gray-100 text-gray-600"}};return e.jsx(ne,{children:u?e.jsx("div",{children:e.jsx("img",{src:"/assets/images/coming-soon.webp",alt:"coming soon"})}):e.jsx("section",{className:"",children:w?e.jsx("div",{className:"flex justify-center items-center py-12",children:e.jsx(T,{loop:!0,animationData:m,className:"w-56 h-56"})}):M?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(t,{className:"text-xl font-semibold text-gray-700",children:a("myReferrals.dataNotFound")}),e.jsx(t,{className:"text-gray-500 mt-2",children:a("myReferrals.dataNotFoundDesc")}),e.jsx("button",{onClick:$,className:"mt-5 px-6 py-2 bg-black text-white rounded-lg hover:opacity-80 transition",children:a("myReferrals.reload")})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(t,{className:"text-[clamp(30px,4vw,42px)] font-bold",children:a("hero.invite")}),e.jsx(t,{className:"text-[clamp(30px,4vw,42px)] font-bold text-bright-yellow",children:a("hero.earn",{amount:`$${c?.config?.credit_amount}`})}),e.jsx(t,{className:"text-sm sm:text-lg text-gray2 mt-2",children:a("hero.description",{amount:`$${c?.config?.credit_amount}`})})]}),e.jsxs("div",{className:"space-y-6 sm:space-y-10",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(t,{variant:"subHeading",className:"font-semibold! pl-6",children:a("myReferrals.myReferralsTitle")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 justify-between items-center gap-x-8 gap-y-4 h-full",children:[e.jsxs("div",{className:"bg-tan rounded-xl drop-shadow-lg w-full flex justify-between items-center px-7 min-h-[93.6px] h-full",children:[e.jsx("div",{className:"",children:e.jsxs("div",{className:"relative w-fit",children:[e.jsx(t,{variant:"regular",className:"text-bright-yellow font-semibold! text-[clamp(80px,26vw,165px)] leading-none select-none",children:"S"}),e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-[clamp(6px,1.5vw,12px)] h-full bg-bright-yellow"})]})}),e.jsxs("div",{className:"absolute left-0 inset-y-0 flex justify-between items-center z-20 w-full px-7",children:[e.jsx(t,{variant:"regular",className:"text-sm! font-semibold! text-nowrap",children:a("myReferrals.referralEarnings")}),e.jsx("div",{children:e.jsxs(t,{variant:"sectionHeading",className:"font-poppins! font-semibold!",children:["$",c?.wallet?.total_credits]})})]})]}),e.jsx("div",{className:"bg-tan rounded-xl drop-shadow-lg w-full flex justify-between items-center px-7 min-h-[93.6px] h-full",children:e.jsxs("div",{className:"flex justify-between items-center z-20 w-full",children:[e.jsx(t,{variant:"regular",className:"text-lg! font-semibold! text-nowrap",children:a("myReferrals.numOfReferrals")}),e.jsx("div",{children:e.jsx(t,{variant:"sectionHeading",className:"font-poppins! font-semibold!",children:c?.customer?.referral_count||0})})]})})]})]}),e.jsxs("div",{className:"bg-bright-yellow/20 w-fit flex items-center gap-4 px-4 py-2 rounded-full relative",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("p",{className:"w-2 h-2 bg-bright-yellow rounded-full"}),e.jsxs(t,{className:"text-sm font-semibold",children:[a("myReferrals.pending")," $",c?.wallet?.pending_credits]})]}),e.jsxs("div",{className:"relative",onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[e.jsx(oe,{className:"text-gray-400 cursor-pointer",onClick:()=>g(s=>!s)}),Y&&e.jsxs("div",{className:`\r 2 absolute z-40 bottom-full mb-3 left-1/2 -translate-x-1/2\r 3 w-64 bg-black text-white text-xs rounded-lg px-4 py-3 shadow-lg\r 4 `,children:[a("tooltip.pendingInfo"),e.jsx("div",{className:`absolute top-full left-1/2 -translate-x-1/2 -translate-y-1/2 \r 5 w-2 h-2 bg-black rotate-45`})]})]})]})]}),e.jsxs("div",{className:"overflow-hidden bg-white",children:[e.jsx("div",{className:"px-4 sm:px-6 pt-5 pb-3",children:e.jsx(t,{className:"text-[28px]! font-bold! text-black",children:a("referralDashboard.title")})}),e.jsxs("div",{className:"border border-black/10 rounded-2xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"overflow-x-auto scrollbar-custom",children:e.jsxs("table",{className:"w-full min-w-[750px] border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bright-yellow text-left",children:[e.jsx("th",{className:"px-6 py-4 text-sm font-semibold text-black",children:a("referralDashboard.table.referee")}),e.jsx("th",{className:"px-6 py-4 text-sm font-semibold text-black",children:a("referralDashboard.table.referralDate")}),e.jsx("th",{className:"px-6 py-4 text-sm font-semibold text-black",children:a("referralDashboard.table.referralBonus")}),e.jsx("th",{className:"px-6 py-4 text-sm font-semibold text-black",children:a("referralDashboard.table.status")}),e.jsx("th",{className:"px-6 py-4 text-sm font-semibold text-black",children:a("referralDashboard.table.rewardReceived")})]})}),e.jsx("tbody",{children:S?.length>0?S.map((s,r)=>{const n=`${s?.first_name||""} ${s?.last_name||""}`.trim();return e.jsxs("tr",{className:"border-b border-black/8 hover:bg-gray-50 transition",children:[e.jsx("td",{className:"px-6 py-5 text-sm text-gray-700 font-medium whitespace-nowrap",children:n||s?.referred_user_email}),e.jsx("td",{className:"px-6 py-5 text-sm text-gray-500 whitespace-nowrap",children:W(s?.date)}),e.jsxs("td",{className:`px-6 py-5 text-sm font-bold whitespace-nowrap ${s?.status?.toLowerCase()==="cancelled"?"text-airchinaRed":"text-green-600"}`,children:["$",s?.amount]}),e.jsx("td",{className:"px-6 py-5 whitespace-nowrap",children:e.jsx("span",{className:`px-3 py-1 rounded-full text-[10px] font-bold tracking-wide uppercase ${ee(s?.status)}`,children:s?.status})}),e.jsx("td",{className:"px-6 py-5 text-sm text-gray-400 font-medium whitespace-nowrap",children:s?.release_date?W(s?.release_date):"-"})]},r)}):e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"text-center py-14 text-gray-400 font-medium",children:"No referral records foun
5d"})})})]})}),K?.last_page>1&&e.jsx("div",{className:"flex justify-center py-5",children:e.jsxs("button",{onClick:()=>{if(j){b(1),y(1,!0);return}const s=G+1;b(s),y(s)},disabled:L,className:`\r 6 flex items-center gap-2\r 7 border border-black/10\r 8 rounded-full\r 9 px-8 py-3\r 10 text-sm font-semibold\r 11 bg-white\r 12 hover:shadow-md\r 13 hover:-translate-y-0.5\r 14 transition-all duration-300\r 15 disabled:opacity-50\r 16 disabled:pointer-events-none\r 17 `,children:[L?"Loading...":j?"See Less":"View More",e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`w-4 h-4 transition-transform duration-300 ${j?"rotate-180":""}`,children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]})})]})]}),e.jsxs("div",{className:"mt-10 space-y-6",children:[e.jsxs("div",{className:"border-y border-black/8 py-6",children:[e.jsx(t,{variant:"subHeading",className:"font-semibold mb-6",children:a("howItWorks.title")}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6",children:E.map((s,r)=>e.jsxs("div",{className:"relative flex flex-col gap-2 px-4 sm:px-0",children:[e.jsx("div",{children:e.jsx("img",{src:s.img,className:"max-w-16 h-auto aspect-square",alt:"img"})}),e.jsx("p",{className:"font-medium text-[clamp(14px,4vw,22px)] mt-4",children:s.title}),e.jsx("p",{className:"text-xs text-gray-600 font-medium",children:s.note}),e.jsx("p",{className:"text-xs font-medium",children:s.description}),r!==E.length-1&&e.jsx("div",{className:"hidden lg:block absolute top-0 right-0 h-full w-px bg-black/10"})]},r))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{variant:"subHeading",className:"font-semibold! pl-6",children:a("referWay.referWayTitle")}),w?e.jsx("div",{className:"flex justify-center items-center py-12",children:e.jsx(T,{loop:!0,animationData:m,className:"w-56 h-56"})}):B?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 sm:gap-6",children:[e.jsxs("div",{className:"bg-tan flex flex-col justify-between items-center rounded-xl p-4 sm:p-6 gap-y-12 min-h-[360px] sm:min-h-[420px] h-full",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4 w-full flex-1",children:[e.jsx(t,{className:"text-[clamp(20px,3.5vw,36px)]! font-semibold! text-center",dangerouslySetInnerHTML:{__html:a("referWay.viaCode")}}),e.jsxs("div",{className:"space-y-4 w-full mt-auto",children:[e.jsx("div",{className:"bg-white border-2 border-bright-yellow py-6 px-3 rounded-xl max-w-[85%] mx-auto w-full overflow-hidden",children:e.jsx(t,{variant:"regular",className:"text-center text-base! sm:text-xl! font-semibold! capitalize mb-0! truncate",children:R})}),e.jsx("div",{className:"flex justify-center items-center",children:e.jsx("img",{src:"/assets/svg/my-account/copy.svg",onClick:()=>A(R,"Referral code copied!"),className:"cursor-pointer hover:scale-105 active:scale-95 transition-all duration-300",alt:"copy"})})]})]}),e.jsxs("div",{className:"flex gap-1 px-1 w-full",children:[e.jsx(t,{className:"text-sm! sm:text-base! font-semibold! shrink-0",children:"*"}),e.jsx(t,{className:"text-sm! sm:text-base! font-semibold!",children:a("referWay.viaCodeNote")})]})]}),e.jsxs("div",{className:"bg-tan flex flex-col justify-between items-center rounded-xl p-4 sm:p-6 gap-y-12 min-h-[360px] sm:min-h-[420px] h-full",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4 flex-1",children:[e.jsx(t,{className:"text-[clamp(20px,3.5vw,36px)]! font-semibold! text-center",dangerouslySetInnerHTML:{__html:a("referWay.viaQR")}}),e.jsxs("div",{className:"space-y-4 mt-auto",children:[e.jsx("div",{className:"flex justify-center items-center bg-white border-2 border-bright-yellow p-3 rounded-xl",children:e.jsx(ie,{ref:D,value:h,size:90,bgColor:"#ffffff",fgColor:"#000000",level:"H"})}),e.jsx("div",{className:"flex justify-center items-center",children:e.jsx("img",{src:"/assets/svg/my-account/copy.svg",onClick:Z,className:"cursor-pointer hover:scale-105 active:scale-95 transition-all duration-300",alt:"copy"})})]})]}),e.jsxs("div",{className:"flex gap-1 px-1 w-full",children:[e.jsx(t,{className:"text-sm! sm:text-base! font-semibold! shrink-0",children:"*"}),e.jsx(t,{className:"text-sm! sm:text-base! font-semibold!",children:a("referWay.viaQRNote")})]})]}),e.jsxs("div",{className:"bg-tan flex flex-col justify-between items-center rounded-xl p-4 sm:p-6 gap-y-12 min-h-[360px] sm:min-h-[420px] h-full sm:col-span-2 lg:col-span-1",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4 w-full flex-1",children:[e.jsx(t,{className:"text-[clamp(20px,3.5vw,36px)]! font-semibold! text-center",dangerouslySetInnerHTML:{__html:a("referWay.viaLink")}}),e.jsxs("div",{className:"w-full max-w-xs mx-auto mt-auto space-y-4",children:[e.jsx("div",{className:"bg-white border-2 border-bright-yellow px-4 py-6 rounded-xl w-full overflow-hidden",children:e.jsx(t,{className:"text-sm! sm:text-base! font-semibold! mb-0! truncate text-center",children:h})}),e.jsx("div",{className:"flex justify-center items-center",children:e.jsx("img",{src:"/assets/svg/my-account/copy.svg",onClick:()=>A(h,"Referral link copied!"),className:"cursor-pointer hover:scale-105 active:scale-95 transition-all duration-300",alt:"copy"})})]})]}),e.jsxs("div",{className:"flex gap-1 px-1 w-full",children:[e.jsx(t,{className:"text-sm! sm:text-base! font-semibold! shrink-0",children:"*"}),e.jsx(t,{className:"text-sm! sm:text-base! font-semibold!",children:a("referWay.viaLinkNote")})]})]})]}):e.jsxs("div",{className:"bg-yellow-50 border border-yellow-300 rounded-xl p-6 max-w-xl",children:[e.jsx(t,{className:"text-yellow-800 font-semibold text-lg",children:a("referralStatus.notActivatedTitle")}),e.jsx(t,{className:"text-yellow-700 mt-2",children:a("referralStatus.notActivatedDesc")})]})]}),e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 flex justify-center items-center md:items-end md:justify-end overflow-hidden",children:e.jsx("img",{src:"/assets/images/my-account/my-referrals.webp",className:"hidden lg:block object-contain md:w-[320px]",alt:"my-referrals","aria-hidden":"true"})}),e.jsxs("div",{className:"relative z-10 md:w-2/3 space-y-2",children:[e.jsx(t,{variant:"subHeading",className:"font-semibold! hover:underline w-fit",children:e.jsx(re,{to:d==="en"?"/terms-conditions":`/${d}/terms-conditions`,children:a("programInformation.title")})}),e.jsx("ul",{className:"space-y-2",children:c?.config?.terms?.map((s,r)=>e.jsxs("li",{className:"flex gap-4",children:[e.jsx("span",{className:"mt-1 w-1.5 h-1.5 aspect-square bg-gray-400 rounded-full flex-shrink-0"}),e.jsx(t,{variant:"regular",className:"text-xs text-gray2",children:s})]},r))})]})]})]})]})})})};export{pe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.