PageSourceSearch

https://abracadabra.plus/assets/ReferralSettings-BASSkXa0.js

js abracadabra.plus collected 2026-09-24 14:28:47 UTC 13,125 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BbwwgQ_I.js","assets/supabase-vendor-DZMyPAGe.js","assets/react-vendor-DxVGvRr9.js","assets/ui-vendor-DUcFxwzi.js","assets/query-vendor-KXAT96aZ.js","assets/i18n-vendor-bd6ZeL4K.js","assets/index-DpGCxJ4W.css"])))=>i.map(i=>d[i]);
2import{_ as e}from"./supabase-vendor-DZMyPAGe.js";import{j as r}from"./ui-vendor-DUcFxwzi.js";import{r as a,u as t}from"./react-vendor-DxVGvRr9.js";import{B as s}from"./BackButton-Bllpe0-U.js";import{u as i,s as l,l as n,B as o,C as d,aP as c,a as m,L as f}from"./index-BbwwgQ_I.js";import{C as p,c as h,a as u,b as x,d as g}from"./card-8sY228PJ.js";import{I as j}from"./input-BlvkA2Rw.js";import{S as v}from"./index-Cfmsycez.js";import{P as b}from"./appConfig-q6WyWdqE.js";import{u as w}from"./i18n-vendor-bd6ZeL4K.js";import{G as y}from"./gift-HBZpPN-U.js";import{C as N}from"./check-Bqlqrcep.js";import{C}from"./copy-BXsgJhDN.js";import{M as k}from"./mail-DYbBE4iQ.js";import{S as _}from"./share-2-BoCBGP0E.js";import{U as R}from"./users-DKJ_05YO.js";import{L as S}from"./loader-circle-DLtnO1f2.js";import"./arrow-left-BJRKEDn_.js";import"./query-vendor-KXAT96aZ.js";function I({userId:e}){const{t:t}=w(),{toast:s}=i(),[c,m]=a.useState(null),[f,S]=a.useState(!0),[I,A]=a.useState(!1),[$,P]=a.useState({totalReferrals:0,pendingReferrals:0,completedReferrals:0,giftClaimedAt:null}),[U,D]=a.useState(!1),F=c?`${b}/signup?ref=${c}`:"",L=t("referral.shareMessage",{defaultValue:"Join me on Abracadabra+! Use my referral code to sign up: {{code}}",code:c});a.useEffect(()=>{O()},[e]);const O=async()=>{try{const{data:r,error:a}=await l.from("profiles").select("referral_code, referral_count, referral_gift_claimed_at").eq("user_id",e).single();if(a)throw a;if(null==r?void 0:r.referral_code)m(r.referral_code);else{const r=M(),{error:a}=await l.from("profiles").update({referral_code:r}).eq("user_id",e);a||m(r)}const{data:t,error:s}=await l.from("referrals").select("status").eq("referrer_user_id",e);!s&&t&&P({totalReferrals:t.length,pendingReferrals:t.filter(e=>"pending"===e.status||"clicked"===e.status).length,completedReferrals:t.filter(e=>"completed"===e.status||"signed_up"===e.status).length,giftClaimedAt:(null==r?void 0:r.referral_gift_claimed_at)||null})}catch(r){n.error("Failed to load referral data",r,{component:"ReferralSection"})}finally{S(!1)}},M=()=>Math.random().toString(36).substring(2,10).toUpperCase(),T=async r=>{if(c)try{await l.from("referrals").insert({referrer_user_id:e,referral_code:`${c}-${Date.now()}`,share_method:r,status:"pending"})}catch(a){n.error("Failed to track referral",a,{component:"ReferralSection"})}},z=async()=>{try{await navigator.clipboard.writeText(F),A(!0),setTimeout(()=>A(!1),2e3),await T("copy"),s({title:t("referral.linkCopied","Link copied!"),description:t("referral.linkCopiedDesc","Share it with your friends")})}catch(e){n.error("Failed to copy link",e,{component:"ReferralSection"})}},B=$.completedReferrals>=20&&!$.giftClaimedAt;return f?r.jsx(p,{children:r.jsx(h,{className:"p-6",children:r.jsxs("div",{className:"animate-pulse space-y-4",children:[r.jsx("div",{className:"h-4 bg-muted rounded w-1/3"}),r.jsx("div",{className:"h-10 bg-muted rounded"})]})})}):r.jsxs(p,{children:[r.jsx(u,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 rounded-lg bg-prism",children:r.jsx(y,{className:"h-5 w-5 text-white"})}),r.jsxs("div",{children:[r.jsx(x,{children:t("referral.title","Invite Friends")}),r.jsx(g,{children:t("referral.description","Share the app with your friends")})]})]})}),r.jsxs(h,{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[r.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[r.jsx("p",{className:"text-2xl font-bold text-primary",children:$.totalReferrals}),r.jsx("p",{className:"text-xs text-muted-foreground",children:t("referral.totalInvites","Invites Sent")})]}),r.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[r.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:$.pendingReferrals}),r.jsx("p",{className:"text-xs text-muted-foreground",children:t("referral.pending","Pending")})]}),r.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[r.jsx("p",{className:"text-2xl font-bold text-green-600",children:$.completedReferrals}),r.jsx("p",{className:"text-xs text-muted-foreground",children:t("referral.joined","Joined")})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-sm font-medium",children:t("referral.yourCode","Your Referral Code")}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(j,{value:c||"",readOnly:!0,className:"font-mono text-lg text-center tracking-wider"}),r.jsx(o,{variant:"outline",size:"icon",onClick:z,children:I?r.jsx(N,{className:"h-4 w-4 text-green-600"}):r.jsx(C,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("label",{className:"text-sm font-medium",children:t("referral.shareVia","Share via")}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs(o,{variant:"outline",className:"h-12 gap-2 hover:bg-green-50 hover:border-green-500 hover:text-green-700",onClick:async()=>{await T("whatsapp");const e=encodeURIComponent(`${L}\n\n${F}`);window.open(`https://wa.me/?text=${e}`,"_blank")},children:[r.jsx("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"
2currentColor",children:r.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})}),"WhatsApp"]}),r.jsxs(o,{variant:"outline",className:"h-12 gap-2 hover:bg-blue-50 hover:border-blue-500 hover:text-blue-700",onClick:async()=>{await T("email");const e=encodeURIComponent(t("referral.emailSubject","Join me on Abracadabra+!")),r=encodeURIComponent(`${L}\n\n${F}`);window.open(`mailto:?subject=${e}&body=${r}`,"_blank")},children:[r.jsx(k,{className:"h-5 w-5"}),"Email"]}),r.jsxs(o,{variant:"outline",className:"h-12 gap-2 hover:bg-pink-50 hover:border-pink-500 hover:text-pink-700",onClick:async()=>{if(await T("instagram"),await navigator.clipboard.writeText(F),s({title:t("referral.linkCopied","Link copied!"),description:t("referral.pasteOnInstagram","Paste it in your Instagram story or DM")}),d.isNativePlatform())try{await v.share({title:t("referral.emailSubject","Join me on Abracadabra+!"),text:L,url:F})}catch{window.open("https://instagram.com","_blank")}else window.open("https://instagram.com","_blank")},children:[r.jsx("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"currentColor",children:r.jsx("path",{d:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"})}),"Instagram"]}),d.isNativePlatform()?r.jsxs(o,{variant:"outline",className:"h-12 gap-2",onClick:async()=>{if(d.isNativePlatform())try{await T("native_share"),await v.share({title:t("referral.emailSubject","Join me on Abracadabra+!"),text:L,url:F})}catch(e){n.error("Native share failed",e,{component:"ReferralSection"})}},children:[r.jsx(_,{className:"h-5 w-5"}),t("referral.moreOptions","More")]}):r.jsxs(o,{variant:"outline",className:"h-12 gap-2",onClick:z,children:[I?r.jsx(N,{className:"h-5 w-5 text-green-600"}):r.jsx(C,{className:"h-5 w-5"}),t("referral.copyLink","Copy Link")]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border-2 border-dashed border-primary/30 bg-gradient-to-r from-purple-50 to-pink-50 dark:from-purple-950/20 dark:to-pink-950/20",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 rounded-full "+(B?"bg-prism":"bg-muted"),children:r.jsx(y,{className:"h-5 w-5 "+(B?"text-white":"text-muted-foreground")})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:$.giftClaimedAt?t("referral.giftAlreadyClaimed","Gift Claimed!"):t("referral.giftTitle","Claim Your Gift")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:$.giftClaimedAt?t("referral.giftClaimedOn","Claimed on {{date}}",{date:new Date($.giftClaimedAt).toLocaleDateString()}):t("referral.giftProgress","{{count}}/20 friends joined",{count:$.completedReferrals})})]})]}),r.jsx(o,{onClick:async()=>
2{if(!($.completedReferrals<20||$.giftClaimedAt))try{D(!0);const{error:r}=await l.from("profiles").update({referral_gift_claimed_at:(new Date).toISOString()}).eq("user_id",e);if(r)throw r;P(e=>({...e,giftClaimedAt:(new Date).toISOString()}));const a=encodeURIComponent("Referral Gift Claim"),i=encodeURIComponent(`Hello!\n\nI have successfully referred 20 friends to Abracadabra+ and would like to claim my gift.\n\nMy referral code: ${c}\nTotal completed referrals: ${$.completedReferrals}\n\nThank you!`);window.open(`mailto:[email protected]?subject=${a}&body=${i}`,"_blank"),s({title:t("referral.giftClaimed","Gift Claimed!"),description:t("referral.giftClaimedDesc","We've opened your email to claim your gift")})}catch(r){n.error("Failed to claim gift",r,{component:"ReferralSection"}),s({title:t("common.error","Error"),description:t("referral.claimError","Failed to claim gift. Please try again."),variant:"destructive"})}finally{D(!1)}},disabled:!B||U,className:B?"bg-prism hover:opacity-90":"",children:U?t("common.loading","Loading..."):$.giftClaimedAt?r.jsx(N,{className:"h-4 w-4"}):t("referral.claimGift","Claim Gift")})]}),!$.giftClaimedAt&&$.completedReferrals<20&&r.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:r.jsx("div",{className:"bg-prism h-2 rounded-full transition-all",style:{width:`${Math.min($.completedReferrals/20*100,100)}%`}})})]}),r.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-gradient-to-r from-purple-50 to-pink-50 dark:from-purple-950/20 dark:to-pink-950/20",children:[r.jsx(R,{className:"h-5 w-5 text-primary mt-0.5 shrink-0"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:t("referral.info","Invite your friends and help grow our community. The more friends you invite, the better experience for everyone!")})]})]})]})}function A(){const{t:i}
2=w(),l=t(),[n,o]=a.useState(!0),[d,p]=a.useState(null);a.useEffect(()=>{h()},[]);const h=async()=>{try{const{getCachedOrFetchUserId:r}=await e(async()=>{const{getCachedOrFetchUserId:e}=await import("./index-BbwwgQ_I.js").then(e=>e.dH);return{getCachedOrFetchUserId:e}},__vite__mapDeps([0,1,2,3,4,5,6])),a=await r();if(!a)return void l("/auth");p(a)}catch(r){}finally{o(!1)}};return n?r.jsx("div",{className:"min-h-screen flex items-center justify-center",children:r.jsx(S,{className:"h-8 w-8 animate-spin"})}):r.jsx("div",{className:"fixed inset-0 bg-background overflow-auto "+(f()?"pb-40":"pb-32"),style:{...m(),paddingBottom:c()},children:r.jsxs("div",{className:"container max-w-2xl mx-auto px-4 pt-6",children:[r.jsx(s,{}),r.jsxs("div",{className:"mt-6 space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-3xl font-bold",children:i("referral.title","Invite Friends")}),r.jsx("p",{className:"text-muted-foreground mt-2",children:i("referral.description","Share the app with your friends")})]}),d&&r.jsx(I,{userId:d})]})]})})}export{A 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.