PageSourceSearch

https://silva.gr/assets/ReferralDashboard-yncWXlHJ.js

js silva.gr collected 2026-09-27 14:03:00 UTC 15,943 bytes, 11 lines download raw bytes

1import{c as O,D as te,bg as re,u as le,r as m,F as n,C as e,aI as c,bj as F,bi as M,br as V,G as o,aJ as l}from"./index-85vHsyJ2.js";import{bE as ie,u as N,af as P,M as ne,q as A,j as ce,r as b,I as H,H as oe,J as T,W as de,bV as J,T as G,l as me,m as xe,n as he,o as ue,p as x,w as je,a as ge,e as ve}from"./main-B2dcDIOH.js";import{P as pe}from"./PortalLayout-VZrXvA-1.js";import{C as fe}from"./chart-column-CjaOZ422.js";import{C as ye}from"./copy-mGjZHZet.js";import{f as Ne}from"./formatDistanceToNow-Cw4VpDXu.js";import"./constructNow-55YhTo2u.js";import"./differenceInCalendarMonths-YS4eGazC.js";import"./endOfDay-Cs57Fb6S.js";import"./endOfMonth-B2v-Xzej.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const be=O("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const W=O("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]),Ie=()=>{var $;const{softUser:w}=ie(),{user:_}=te(),a=(w==null?void 0:w.email)||(_==null?void 0:_.email),{toast:i}=re(),g=le(),[E,I]=m.useState("/"),[L,k]=m.useState(!1),[v,K]=m.useState(""),[C,D]=m.useState(""),[p,z]=m.useState(""),[Q,S]=m.useState(!1),[q,U]=m.useState(!1),{data:r}=N({queryKey:["user-profile-by-email",a],queryFn:async()=>{if(!a)return null;const{data:s}=await n.from("profiles").select("id").ilike("email",a).maybeSingle();return s},enabled:!!a}),{data:h}=N({queryKey:["graduate-name",a],queryFn:async()=>{if(!a)return null;const{data:s}=await n.rpc("portal_get_self_graduate",{p_caller_email:a});if(!s||s.length===0)return null;const t=s[0];return{first_name:t.first_name,full_name:t.full_name}},enabled:!!a}),R=(h==null?void 0:h.first_name)||(($=h==null?void 0:h.full_name)==null?void 0:$.split(" ")[0])||(a==null?void 0:a.split("@")[0])||"Απόφοιτος",{data:f}=N({queryKey:["invite-count",a],queryFn:async()=>{if(!a)return 0;const{count:s}=await n.from("portal_referrals").select("id",{count:"exact",head:!0}).ilike("referrer_email",a);return s||0},enabled:!!a}),{data:u,isLoading:X}=N({queryKey:["referral-links",r==null?void 0:r.id],queryFn:async()=>{if(!(r!=null&&r.id))return[];const{data:s,error:t}=await n.from("referral_links").select("*").eq("user_id",r.id).order("created_at",{ascending:!1});if(t)throw t;return s},enabled:!!(r!=null&&r.id)}),d=P({mutationFn:async()=>{const{error:s}=await n.functions.invoke("send-graduate-invite",{body:{referrer_email:a,referrer_name:R,invitee_email:C.trim(),invitee_first_name:v.trim(),personal_message:p.trim()}});if(s)throw s},onSuccess:()=>{U(!0),K(""),D(""),z(""),g.invalidateQueries({queryKey:["invite-count",a]}),g.invalidateQueries({queryKey:["portal-graduate",a]}),i({title:"Πρόσκληση στάλθηκε!",description:`Ο/Η ${v} θα λάβει σύντομα το email σου.`}),setTimeout(()=>{U(!1),S(!1)},4e3)},onError:s=>{console.error("Error sending invite:",s),i({title:"Σφάλμα",description:"Δεν ήταν δυνατή η αποστολή. Παρακαλώ δοκιμάστε ξανά.",variant:"destructive"})}}),Y=s=>{if(s.preventDefault(),!v.trim()||!C.trim()||!p.trim()){i({title:"Συμπληρώστε όλα τα πεδία",description:"Χρειάζονται όνομα, email και προσωπικό μήνυμα.",variant:"destructive"});return}d.mutate()},Z=async()=>{const{data:s,error:t}=await n.rpc("generate_referral_code",{user_id:r==null?void 0:r.id});if(t)throw t;return s},y=P({mutationFn:async()=>{if(!(r!=null&&r.id))throw new Error("Πρέπει να είστε συνδεδεμένος");const s=await Z(),{data:t,error:B}=await n.from("referral_links").insert({user_id:r.id,unique_code:s,target_url:E,clicks_count:0,conversions_count:0}).select().single();if(B)throw B;return t},onSuccess:()=>{i({title:"Σύνδεσμος δημιουργήθηκε",description:"Ο σύνδεσμος σύστασης δημιουργήθηκε επιτυχώς."}),I("/"),k(!1),g.invalidateQueries({queryKey:["referral-links"]})},onError:s=>{console.error("Error creating referral link:",s),i({title:"Σφάλμα",description:"Δεν ήταν δυνατή η δημιουργία του συνδέσμου.",variant:"destructive"})}}),ee=P({mutationFn:async s=>{const{error:t}=await n.from("referral_links").delete().eq("id",s);if(t)throw t},onSuccess:()=>{i({title:"Σύνδεσμος διαγράφηκε",description:"Ο σύνδεσμος σύστασης διαγράφηκε επιτυχώς."}),g.invalidateQueries({queryKey:["referral-links"]})},onError:s=>{console.error("Error deleting referral link:",s),i({title:"Σφάλμα",description:"Δεν ήταν δυνατή η διαγραφή του συνδέσμου.",variant:"destructive"})}}),se=s=>{s.preventDefault(),y.mutate()},ae=s=>{const t=`${window.location.origin}${s.target_url}?ref=${s.unique_code}`;navigator.clipboard.writeText(t),i({title:"Αντιγράφηκε!",description:"Ο σύνδεσμος αντιγράφηκε στο πρόχειρο."})},j=u?u.reduce((s,t)=>({clicks:s.clicks+(t.clicks_count||0),conversions:s.conversions+(t.conversions_count||0)}),{clicks:0,conversions:0}):{clicks:0,conversions:0};return e.jsx(pe,{activeTab:null,children:e.jsxs("div",{children:[e.jsxs(c,{className:"mb-6 border-2",style:{borderColor:"var(--portal-teal)",backgroundColor:"var(--portal-surface)"},children:[e.jsx(F,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{backgroundColor:"rgba(44,181,150,0.12)"},children:e.jsx(ne,{className:"h-5 w-5",style:{color:"var(--portal-teal)"}})}),e.jsxs("div",{children:[e.jsx(M,{className:"text-lg",style:{color:"var(--portal-text)"},children:"Στείλε προσωπική πρόσκληση"}),e.jsxs(V,{style:{color:"var(--portal-text-2)"},children:["Ένα αυθεντικό email από σένα αξίζει 10 διαÏ
11†Î·Î¼Î¯ÏƒÎµÎ¹Ï‚.",f!==void 0&&f>0&&e.jsxs("span",{className:"ml-2 font-semibold",style:{color:"var(--portal-teal)"},children:[f," ",f===1?"πρόσκληση":"προσκλήσεις"," σταλμένες ✓"]})]})]})]}),!Q&&!q&&e.jsxs(o,{size:"sm",onClick:()=>S(!0),style:{backgroundColor:"var(--portal-teal)",color:"#fff"},children:[e.jsx(A,{className:"mr-1 h-4 w-4"}),"Νέα πρόσκληση"]})]})}),q&&e.jsx(l,{className:"pt-0",children:e.jsxs("div",{className:"flex items-center gap-3 p-4 rounded-xl",style:{backgroundColor:"rgba(44,181,150,0.1)"},children:[e.jsx(ce,{className:"h-6 w-6",style:{color:"var(--portal-teal)"}}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",style:{color:"var(--portal-text)"},children:"Η πρόσκλησή σου στάλθηκε!"}),e.jsx("p",{className:"text-sm",style:{color:"var(--portal-text-2)"},children:"Θα κλείνει αυτόματα σε λίγο..."})]})]})}),Q&&!q&&e.jsx(l,{className:"pt-0",children:e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(b,{htmlFor:"invitee-name",style:{color:"var(--portal-text)"},children:"Όνομα φίλου/φίλης *"}),e.jsx(H,{id:"invitee-name",value:v,onChange:s=>K(s.target.value),placeholder:"π.χ. Μαρία",className:"mt-1",disabled:d.isPending})]}),e.jsxs("div",{children:[e.jsx(b,{htmlFor:"invitee-email",style:{color:"var(--portal-text)"},children:"Email φίλου/φίλης *"}),e.jsx(H,{id:"invitee-email",type:"email",value:C,onChange:s=>D(s.target.value),placeholder:"[email protected]",className:"mt-1",disabled:d.isPending})]})]}),e.jsxs("div",{children:[e.jsxs(b,{htmlFor:"personal-message",style:{color:"var(--portal-text)"},children:["Προσωπικό μήνυμα * ",e.jsx("span",{className:"font-normal text-sm",style:{color:"var(--portal-text-3)"},children:"(2-3 προτάσεις)"})]}),e.jsx(oe,{id:"personal-message",value:p,onChange:s=>z(s.target.value),placeholder:"π.χ. Ανακάλυψα τη Μέθοδο Silva πριν 3 χρόνια και άλλαξε τον τρόπο που σκέφτομαι. Νομίζω ότι θα σου ταίριαζε πολύ...",className:"mt-1 resize-none",rows:3,maxLength:400,disabled:d.isPending}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"var(--portal-text-3)"},children:[p.length,"/400"]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(o,{type:"submit",disabled:d.isPending,style:{backgroundColor:"var(--portal-teal)",color:"#fff"},children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"mr-2 h-4 w-4 animate-spin"}),"Αποστολή..."]}):e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"mr-2 h-4 w-4"}),"Στείλε την πρόσκληση"]})}),e.jsx(o,{type:"button",variant:"outline",onClick:()=>S(!1),disabled:d.isPending,children:"Ακύρωση"})]}),e.jsxs("p",{className:"text-xs",style:{color:"var(--portal-text-3)"},children:["Το email θα σταλεί εκ μέρους σου με αποστολέα «",R," μέσω Silva Method» · [email protected]"]})]})})]}),e.jsxs(c,{className:"mb-8 bg-gradient-to-br from-green-50 to-emerald-50 border-green-200",children:[e.jsx(F,{children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(J,{className:"h-8 w-8 text-green-600"}),e.jsxs("div",{children:[e.jsx(M,{className:"text-2xl text-green-900",children:"Πρόγραμμα Συστάσεων"}),e.jsx(V,{className:"text-green-700",children:"Μοιραστείτε τη Silva Method και κερδίστε ανταμοιβές"})]})]})}),e.jsxs(l,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-6",children:[e.jsx(c,{className:"bg-white/80 backdrop-blur-sm",children:e.jsxs(l,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"Συνολικές Προβολές"}),e.jsx(W,{className:"h-4 w-4 text-gray-400"})]}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:j.clicks})]})}),e.jsx(c,{className:"bg-white/80 backdrop-blur-sm",children:e.jsxs(l,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"Μετατροπές"}),e.jsx(G,{className:"h-4 w-4 text-gray-400"})]}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:j.conversions})]})}),e.jsx(c,{className:"bg-white/80 backdrop-blur-sm",children:e.jsxs(l,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"Ποσοστό Μετατροπής"}),e.jsx(fe,{className:"h-4 w-4 text-gray-400"})]}),e.jsxs("p",{className:"text-2xl font-bold text-gray-900",children:[j.clicks>0?Math.round(j.conversions/j.clicks*100):0,"%"]})]})})]}),!L&&e.jsxs(o,{onClick:()=>k(!0),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(A,{className:"mr-2 h-4 w-4"}),"Δημιουργία Νέου Συνδέσμου"]})]})]}),L&&e.jsxs(c,{className:"mb-8 border-green-200",children:[e.jsx(F,{children:e.jsx(M,{className:"text-xl",children:"Δημιουργία Νέου Συνδέσμου"})}),e.jsx(l,{children:e.jsxs("form",{onSubmit:se,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(b,{htmlFor:"targetUrl",children:"Σελίδα Προορισμού"}),e.jsxs(me,{value:E,onValueChange:I,children:[e.jsx(xe,{children:e.jsx(he,{placeholder:"Επιλέξτε σελίδα"})}),e.jsxs(ue,{children:[e.jsx(x,{value:"/",children:"Αρχική Σελίδα"}),e.jsx(x,{value:"/bls-seminar",children:"Basic Level Seminar"}),e.jsx(x,{value:"/ultra-seminar",children:"Ultra Seminar"}),e.jsx(x,{value:"/silva-mastery",children:"Silva Mastery"}),e.jsx(x,{value:"/silva-for-business",children:"Silva for Business"}
11),e.jsx(x,{value:"/what-is-silva",children:"Τι είναι η Silva"}),e.jsx(x,{value:"/upcoming-seminars",children:"Επερχόμενα Σεμινάρια"})]})]})]}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx(o,{type:"submit",disabled:y.isPending,className:"bg-green-600 hover:bg-green-700",children:y.isPending?e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"mr-2 h-4 w-4 animate-spin"}),"Δημιουργία..."]}):e.jsxs(e.Fragment,{children:[e.jsx(be,{className:"mr-2 h-4 w-4"}),"Δημιουργία Συνδέσμου"]})}),e.jsx(o,{type:"button",variant:"outline",onClick:()=>k(!1),disabled:y.isPending,children:"Ακύρωση"})]})]})})]}),e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Οι Σύνδεσμοί σας"}),X?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(T,{className:"h-8 w-8 animate-spin text-green-600"})}):e.jsx("div",{className:"grid gap-4",children:u&&u.length>0?u.map(s=>e.jsx(c,{className:"hover:shadow-lg transition-shadow",children:e.jsxs(l,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-gray-900 mb-1",children:s.target_url}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Κωδικός: ",s.unique_code]}),e.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:["Δημιουργήθηκε ",Ne(new Date(s.created_at),{addSuffix:!0,locale:ve})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(o,{variant:"outline",size:"sm",onClick:()=>ae(s),children:e.jsx(ye,{className:"h-4 w-4"})}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ee.mutate(s.id),className:"text-red-600 hover:text-red-700",children:e.jsx(je,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Πλήρης Σύνδεσμος:"}),e.jsxs("code",{className:"text-xs bg-white px-2 py-1 rounded border text-gray-700 break-all",children:[window.location.origin,s.target_url,"?ref=",s.unique_code]})]}),e.jsxs("div",{className:"flex items-center space-x-6 mt-4 text-sm",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(W,{className:"h-4 w-4 text-gray-400"}),e.jsxs("span",{className:"text-gray-600",children:[s.clicks_count||0," προβολές"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ge,{className:"h-4 w-4 text-gray-400"}),e.jsxs("span",{className:"text-gray-600",children:[s.conversions_count||0," μετατροπές"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(G,{className:"h-4 w-4 text-gray-400"}),e.jsxs("span",{className:"text-gray-600",children:[s.clicks_count>0?Math.round(s.conversions_count/s.clicks_count*100):0,"% μετατροπή"]})]})]})]})},s.id)):e.jsx(c,{className:"text-center py-12",children:e.jsxs(l,{children:[e.jsx(J,{className:"mx-auto h-12 w-12 text-gray-400 mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Δεν έχετε δημιουργήσει συνδέσμους ακόμα."}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Δημιουργήστε τον πρώτο σας σύνδεσμο για να ξεκινήσετε το πρόγραμμα συστάσεων."})]})})})]})})};export{Ie 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.