PageSourceSearch

https://app.ateliereonline.ro/assets/TrainerDashboard-9Xkvhjny.js

js ateliereonline.ro collected 2026-09-25 03:33:15 UTC 15,473 bytes, 1 lines download raw bytes

1import{d as P,j as e,u as F}from"./vendor-data-BnAsYEPc.js";import{r as x,e as G}from"./vendor-react-BNJcskRT.js";import{g as K,a as O}from"./trainerSessionGroups-2M7iZrri.js";import{S as Q}from"./StickyHeader-C2bKzdSJ.js";import{H as S,W as V,b as $,B as T,F as X,Q as z,c as Z,ai as W,f as M,aE as w,u as J,n as Y,N as ee,L as se,m as A,a2 as te,D as ae,G as m,j as v,T as B,M as f,am as R,w as re,a4 as ne,r as _}from"./index-P4Jm-5kS.js";import{G as q}from"./GradientBackground-BC9OqTIH.js";import{S as ie}from"./DoodleDecorations-Be3KNNN0.js";import{u as ce}from"./useTrainerSessions-CwtOrGtx.js";import{T as oe,a as le}from"./TrainerBookingRequests-BYkLXnpI.js";import{T as de}from"./TrainerAvailabilityEditor-DhqUott2.js";import{u as me}from"./useTrainerContracts-u6u6QFfM.js";import{A as xe,a as ue,b as pe,c as he,d as fe,e as ge,f as je,g as be}from"./alert-dialog-c0BHNspD.js";import{C as Ne}from"./circle-x-JenCB3By.js";import{u as we}from"./RefusalDialog-D6sBtwTs.js";import{A as ve}from"./arrow-right-BQmBYcdS.js";import{f as E}from"./vendor-date-BFEA4iDb.js";import"./vendor-ui-vXhwLHr8.js";import"./award-B6bL9ykU.js";import"./ConfirmAvailabilityModal-BJT75nXM.js";import"./TrainerConfirmBookingModal-mWCRlibN.js";import"./message-circle-BSLj25Ys.js";import"./tabs-BfwW4Qh6.js";import"./useTrainerAvailability-DzyDLJWQ.js";import"./pencil-CDvTGHYR.js";import"./trash-2-DAw2Z6Ro.js";import"./switch-CpKdJsIc.js";import"./invokeEdgeFunction-B8nxBS40.js";import"./notifications-BCiipJ3b.js";const ye=()=>{const{data:t,isLoading:c,refetch:y}=me(),g=P(),[j,C]=x.useState(null),[u,p]=x.useState(null),[i,o]=x.useState(!1);if(c||!(t!=null&&t.contract))return null;const b=t.contract,n=t.signature,l=async()=>{const{data:r,error:a}=await M.storage.from(b.storage_bucket).createSignedUrl(b.storage_path,3600);if(a||!(r!=null&&r.signedUrl)){w.error("Nu am putut deschide contractul. Reîncearcă.");return}window.open(r.signedUrl,"_blank","noopener,noreferrer")},k=async r=>{o(!0),C(r);try{const{data:a,error:h}=await M.functions.invoke("sign-trainer-contract",{body:{contract_id:b.id,decision:r}});if(h){const d=h.context;(d==null?void 0:d.status)===409?w.info("Ai semnat deja acest contract."):w.error(h.message??"Eroare la înregistrare.")}else a!=null&&a.success&&w.success("Decizia ta a fost înregistrată.")}catch(a){w.error(a.message??"Eroare la înregistrare.")}finally{o(!1),C(null),p(null),await y(),g.invalidateQueries({queryKey:["my-trainer-contract"]})}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 rounded-3xl border-2 border-accent/40 bg-gradient-to-br from-accent/10 via-background to-primary/5 p-5 shadow-lg animate-fade-in-up",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:n?n.decision==="accepted"?e.jsxs(S,{className:"bg-success text-success-foreground border-0 gap-1",children:[e.jsx(V,{className:"w-3 h-3"})," Contract semnat"]}):e.jsxs(S,{variant:"destructive",className:"gap-1",children:[e.jsx(Ne,{className:"w-3 h-3"})," Contract refuzat"]}):e.jsxs(S,{className:"bg-accent text-accent-foreground border-0 gap-1",children:[e.jsx($,{className:"w-3 h-3"})," Acțiune necesară"]})}),e.jsx("h3",{className:"text-lg font-bold text-foreground",children:n?"Contract de colaborare":"Contract de colaborare disponibil"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 mb-4",children:n?`Decizia ta a fost înregistrată pe ${new Date(n.signed_at).toLocaleDateString("ro-RO",{day:"2-digit",month:"long",year:"numeric"})}.`:"Vă rugăm să citiți și să semnați contractul pentru a continua colaborarea."}),e.jsxs(T,{onClick:l,className:"w-full mb-4",variant:n?"outline":"default",children:[e.jsx(X,{className:"w-4 h-4 mr-2"}),n?"Vezi contractul":"Deschide contractul"]}),!n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs font-semibold text-foreground mb-2",children:"Decizia ta:"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsxs(T,{onClick:()=>p("accepted"),disabled:i,className:"bg-success hover:bg-success/90 text-success-foreground",children:[i&&j==="accepted"?e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Z,{className:"w-4 h-4 mr-2"}),"Sunt de acord cu T&C"]}),e.jsxs(T,{onClick:()=>p("rejected"),disabled:i,variant:"destructive",children:[i&&j==="rejected"?e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(W,{className:"w-4 h-4 mr-2"}),"Nu sunt de acord"]})]})]})]}),e.jsx(xe,{open:!!u,onOpenChange:r=>!r&&p(null),children:e.jsxs(ue,{children:[e.jsxs(pe,{children:[e.jsxs(he,{children:["Confirmi ",u==="accepted"?"acceptarea":"refuzul"," Termenilor și Condițiilor?"]}),e.jsx(fe,{children:"Această acțiune va fi înregistrată cu IP-ul și data curente și nu poate fi modificată."})]}),e.jsxs(ge,{children:[e.jsx(je,{disabled:i,children:"Renunță"}),e.jsx(be,{onClick:()=>u&&k(u),disabled:i,children:"Confirmă"})]})]})})]})},Je=()=>{var L;const t=G(),{user:c,isAuthenticated:y,isLoading:g}=J(),{toast:j}=Y(),{data:C,isLoading:u,isError:p}=ee(),{data:i}=ce(),{data:o}=F({queryKey:["profile-name",c==null?void 0:c.id],queryFn:async()=>{const{data:s}=await M.from("profiles").select("full_name, role").eq("id",c.id).single();return s},enabled:!!(c!=null&&c.id)}),b=g||u,n=x.useMemo(()=>i?i.filter(s=>
1s.status!=="cancelled"&&s.status!=="technical_cancelled"):[],[i]);x.useEffect(()=>{!g&&!y&&t("/profile")},[g,y,t]),x.useEffect(()=>{!u&&p&&(j({title:"Acces interzis",description:"Nu ai permisiunea să accesezi această pagină.",variant:"destructive"}),t("/home"))},[u,p,t,j]);const l=x.useMemo(()=>K(n),[n]),k=x.useMemo(()=>{if(!l.length)return{upcoming:0,completed:0,total:0};const s=new Date,D=l.filter(N=>new Date(N.start_at)>s).length,H=l.filter(N=>{const I=N.end_at?new Date(N.end_at):new Date(N.start_at);return s>=I}).length;return{upcoming:D,completed:H,total:l.length}},[l]),r=x.useMemo(()=>{const s=new Date;return l.filter(D=>new Date(D.start_at)>s).slice(0,3)},[l]),a=r[0],{data:h}=we("requested"),d=(h==null?void 0:h.length)??0;if(b)return e.jsx(q,{children:e.jsx("div",{className:"min-h-dvh flex items-center justify-center",children:e.jsx(z,{className:"w-8 h-8 text-white animate-spin"})})});if(!C)return null;const U=((L=o==null?void 0:o.full_name)==null?void 0:L.split(" ")[0])||"Trainer";return e.jsx(q,{children:e.jsxs("div",{className:"min-h-dvh",children:[e.jsx(Q,{variant:"gradient",leftContent:e.jsx(se,{size:"sm",variant:"light",iconOnly:!0}),title:`Bună, ${U}! 👋`}),e.jsx(ie,{className:"absolute top-36 right-8"}),e.jsxs("div",{className:"px-4 py-6 pb-32",children:[(o==null?void 0:o.full_name)&&e.jsx(ye,{}),e.jsx(oe,{}),e.jsx("div",{id:"trainer-booking-requests",className:"mb-6 scroll-mt-24",children:e.jsx(le,{})}),e.jsx(de,{}),e.jsxs("section",{className:A("rounded-2xl border-2 p-4 space-y-3 mb-6 animate-fade-in-up",d>0?"border-accent bg-accent/5":"border-border bg-card"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:A("w-5 h-5",d>0?"text-accent":"text-primary")}),e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wide text-foreground",children:"Acțiuni rapide"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>{const s=document.getElementById("trainer-booking-requests");s&&s.scrollIntoView({behavior:"smooth",block:"start"})},className:A("rounded-xl p-3 text-center transition-colors min-h-[88px] flex flex-col justify-between",d>0?"bg-accent/10 hover:bg-accent/20 border border-accent/30":"bg-muted hover:bg-muted/80"),children:[e.jsx("p",{className:A("text-2xl font-bold",d>0?"text-accent":"text-foreground"),children:d}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"De aprobat"}),e.jsx("p",{className:"text-[10px] text-muted-foreground leading-tight mt-0.5",children:"Cereri noi de rezervare"})]})]}),e.jsxs("button",{onClick:()=>t("/trainer/workshops"),className:"rounded-xl p-3 text-center bg-muted hover:bg-muted/80 transition-colors min-h-[88px] flex flex-col justify-between",children:[e.jsx("p",{className:"text-2xl font-bold text-foreground",children:k.upcoming}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Ateliere viitoare"}),e.jsx("p",{className:"text-[10px] text-muted-foreground leading-tight mt-0.5",children:"Vezi atelierele mele"})]})]}),e.jsxs("button",{onClick:()=>a&&t(`/trainer/sessions/group/${encodeURIComponent(a.groupKey)}`),disabled:!a,className:"rounded-xl p-3 text-center bg-muted hover:bg-muted/80 transition-colors min-h-[88px] flex flex-col justify-between disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(ae,{className:"w-6 h-6 text-primary mx-auto"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Urm. sesiune"}),e.jsx("p",{className:"text-[10px] text-muted-foreground leading-tight mt-0.5",children:a?E(new Date(a.start_at),"d MMM, HH:mm",{locale:_}):"Nicio sesiune"})]})]})]})]}),a&&e.jsxs(m,{className:"mb-6 animate-fade-in-up border border-border",padding:"md",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(v,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-sm font-bold text-foreground",children:"Următoarea sesiune"})]}),e.jsx("h4",{className:"font-bold text-foreground text-base leading-tight mb-1",children:a.title}),e.jsx("p",{className:"text-muted-foreground text-sm capitalize",children:E(new Date(a.start_at),"EEEE, d MMMM yyyy 'la' HH:mm",{locale:_})}),a.participants.length>0&&e.jsxs("p",{className:"text-foreground text-sm mt-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Participanți: "}),a.participants.map(s=>
1O(s)).join(", ")]}),!a.zoom_link&&e.jsxs("span",{className:"text-accent text-xs flex items-center gap-1 mt-2",children:[e.jsx(B,{className:"w-3 h-3"})," Zoom lipsă"]}),e.jsxs("button",{onClick:()=>t(`/trainer/sessions/group/${encodeURIComponent(a.groupKey)}`),className:"mt-3 w-full inline-flex items-center justify-center gap-2 rounded-xl border border-primary/30 bg-primary/5 hover:bg-primary/10 text-primary text-sm font-medium py-2 transition-colors",children:["Vezi detalii",e.jsx(ve,{className:"w-4 h-4"})]})]}),e.jsxs("div",{className:"space-y-3 mb-6",children:[e.jsx(m,{padding:"md",onClick:()=>t("/trainer/calendar"),className:"animate-fade-in-up border border-border",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center",children:e.jsx(v,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-bold text-foreground",children:"Calendarul meu"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Sesiuni, disponibilitate & excepții"})]}),e.jsx(f,{className:"w-5 h-5 text-muted-foreground"})]})}),e.jsx(m,{padding:"md",onClick:()=>t("/trainer/workshops"),className:"animate-fade-in-up border border-border",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center",children:e.jsx(R,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-bold text-foreground",children:"Atelierele mele"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Adaugă și gestionează ateliere"})]}),e.jsx(f,{className:"w-5 h-5 text-muted-foreground"})]})}),e.jsx(m,{padding:"md",onClick:()=>t("/trainer/sessions"),className:"animate-fade-in-up border border-border",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center",children:e.jsx(v,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-bold text-foreground",children:"Sesiunile mele"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[k.upcoming," sesiuni programate"]})]}),e.jsx(f,{className:"w-5 h-5 text-muted-foreground"})]})}),e.jsx(m,{padding:"md",onClick:()=>t("/trainer/clients"),className:"animate-fade-in-up border border-border",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-accent/10 flex items-center justify-center",children:e.jsx(re,{className:"w-6 h-6 text-accent"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-bold text-foreground",children:"Clienții mei"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Istoric sesiuni per client"})]}),e.jsx(f,{className:"w-5 h-5 text-muted-foreground"})]})}),e.jsx(m,{padding:"md",onClick:()=>t("/trainer/settings"),className:"animate-fade-in-up border border-border",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center",children:e.jsx(ne,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-bold text-foreground",children:"Setările mele"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Profil public, IBAN & date fiscale"})]}),e.jsx(f,{className:"w-5 h-5 text-muted-foreground"})]})}),e.jsx(m,{padding:"md",onClick:()=>t("/trainer/help"),className:"animate-fade-in-up border border-border",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-accent/10 flex items-center justify-center",children:e.jsx(R,{className:"w-6 h-6 text-accent"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-bold text-foreground",children:"Ghid traineri"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manual, FAQ & troubleshooting"})]}),e.jsx(f,{className:"w-5 h-5 text-muted-foreground"})]})})]}),r.length>0&&e.jsxs("div",{className:"animate-fade-in-up animation-delay-200",children:[e.jsxs("h2",{className:"text-on-gradient font-bold mb-3 flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4"}),"Următoarele sesiuni"]}),e.jsx("div",{className:"space-y-3",children:r.map(s=>e.jsx(m,{padding:"sm",onClick:()=>t(`/trainer/sessions/group/${encodeURIComponent(s.groupKey)}`),className:"border border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"font-bold text-foreground text-sm truncate",children:s.title}),e.jsx("p",{className:"text-muted-foreground text-xs capitalize",children:E(new Date(s.start_at),"EEE d MMM, HH:mm",{locale:_})}),e.jsxs("p",{className:"text-muted-foreground text-xs mt-0.5",children:[s.participants.length," ",s.participants.length===1?"participant":"participanți"]}),!s.zoom_link&&e.jsxs("span",{className:"text-accent text-xs flex items-center gap-1 mt-1",children:[e.jsx(B,{className:"w-3 h-3"})," Zoom lipsă"]})]}),e.jsx(f,{className:"w-4 h-4 text-muted-foreground shrink-0"})]})},s.groupKey))})]}),i&&n.length===0&&e.jsxs(m,{className:"text-center py-8 border border-border animate-fade-in-up",children:[e.jsx(v,{className:"w-12 h-12 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"text-foreground font-medium",children:"Nicio sesiune încă"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Sesiunile tale vor apărea aici."})]})]})]})})};export{Je 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.