1import{j as e}from"./vendor-query-DK5Fp9og.js";import{j as H,b as U,r as p}from"./vendor-react-Dhj04v6j.js";import{D as V}from"./dedicated-editor-service-CQJn6-vK.js";import{U as r,aB as M,B as R,K as d,Y as n,Z as l,L as o,N as F,V as J,a8 as K,ay as O,I as Y,O as Z}from"./index-D0Lmu7bM.js";import{B as c}from"./badge-CnkaJiqk.js";import{S as v}from"./separator-B3tH_TRd.js";import{L as z}from"./loading-CbzXDCJd.js";import{E as G}from"./empty-state-B-r7FlZC.js";import{a as Q}from"./user-display-helpers-DSiXIz4k.js";import{A as W}from"./arrow-left-CXJ55C57.js";import{M as N}from"./mail-dGQOnrGa.js";import{U as X}from"./users-CZNAFDH_.js";import{C as b}from"./circle-check-CrV84cn-.js";import"./vendor-supabase-CKouYt5_.js";function ge(){const{editorId:a}=H(),g=U(),[y,u]=p.useState(!0),[s,w]=p.useState(null),[h,E]=p.useState([]);p.useEffect(()=>{C()},[a]);const C=async()=>{if(!a){g("/admin/editors");return}try{u(!0);const{data:t,error:j}=await r.from("editors").select("*").eq("editor_id",a).single();if(j)throw j;const{data:m}=await r.from("user_profiles").select("first_name, last_name, email").eq("user_id",a).single(),{data:D}=await r.from("user_profiles").select("id").eq("assigned_editor_id",a),q=D?.length||0,{data:P}=await r.from("edit_requests").select("id").eq("assigned_editor_id",a).eq("status","completed"),S=P?.length||0,{data:A}=await r.from("edit_requests").select("id").eq("assigned_editor_id",a).in("status",["pending","assigned","in_progress"]),I=A?.length||0,{data:x}=await r.from("edit_requests").select("created_at, completed_at").eq("assigned_editor_id",a).eq("status","completed").not("completed_at","is",null);let f=0;x&&x.length>0&&(f=x.reduce((B,_)=>{const T=new Date(_.created_at).getTime(),k=new Date(_.completed_at).getTime();return B+(k-T)/36e5},0)/x.length),w({editor_id:t.editor_id,display_name:Q(m?.first_name,m?.last_name,m?.email),email:m?.email||"Desconocido",editor_type:t.editor_type,is_active:t.is_active,total_clients:q,completed_videos:S,pending_requests:I,avg_completion_hours:f});const L=(await V.getMyClientsAsEditor(a)).map(i=>({user_id:i.user_id,client_email:i.email,assignment_type:i.editor_assignment_type==="invited"?"private":"public",assigned_at:i.editor_assigned_at,pending_requests:i.pending_count}));E(L)}catch(t){console.error("Error loading editor data:",t),M.error("Error al cargar datos del editor"),g("/admin/editors")}finally{u(!1)}};return y?e.jsx(z,{variant:"page"}):s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs(R,{variant:"ghost",onClick:()=>g("/admin/editors"),className:"mb-4",children:[e.jsx(W,{className:"w-4 h-4 mr-2"}),"Volver a Editores"]}),e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:s.display_name}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(N,{className:"w-4 h-4"}),e.jsx("p",{children:s.email})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(c,{variant:s.editor_type==="private"?"default":"outline",children:s.editor_type==="private"?"Privado":"Público"}),e.jsx(c,{variant:"outline",className:s.is_active?"bg-green-100 text-green-800 border-green-200":"bg-gray-100 text-gray-800 border-gray-200",children:s.is_active?"Activo":"Inactivo"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(d,{children:[e.jsx(n,{className:"pb-3",children:e.jsxs(l,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(X,{className:"w-4 h-4"}),"Clientes"]})}),e.jsx(o,{children:e.jsx("div",{className:"text-2xl font-bold",children:s.total_clients})})]}),e.jsxs(d,{children:[e.jsx(n,{className:"pb-3",children:e.jsxs(l,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4"}),"Pendientes"]})}),e.jsx(o,{children:e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:s.pending_requests})})]}),e.jsxs(d,{children:[e.jsx(n,{className:"pb-3",children:e.jsxs(l,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(b,{className:"w-4 h-4"}),"Completados"]})}),e.jsx(o,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:s.completed_videos})})]}),e.jsxs(d,{children:[e.jsx(n,{className:"pb-3",children:e.jsxs(l,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4"}),"Tiempo Promedio"]})}),e.jsx(o,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[s.avg_completion_hours.toFixed(1),"h"]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(d,{className:"lg:col-span-2",children:[e.jsx(n,{children:e.jsx(l,{children:"Clientes Asignados"})}),e.jsx(o,{children:h.length===0?e.jsx(G,{variant:"plain",icon:K,description:"No hay clientes asignados a este editor"}):e.jsx("div",{className:"space-y-3",children:h.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:t.client_email})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsx(c,{variant:t.assignment_type==="private"?"default":"outline",className:"text-xs",children:t.assignment_type==="private"?"Privado":"Público"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"}),e.jsxs("span",{children:["Desde ",new Date(t.assigned_at).toLocaleDateString("es-ES")]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(c,{variant:"outline",className:"bg-blue-50 text-blue-700 border-blue-200",children:[t.pending_requests," pendientes"]})})]},t.user_id))})})]}),e.jsxs(d,{children:[e.jsx(n,{children:e.jsx(l,{children:"Información del Editor"})}),e.jsxs(o,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(N,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Email:"})]}),e.jsx("p",{className:"font-medium",children:s.email})]}),e.jsx(v,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Z,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Tipo:"})]}),e.jsx(c,{variant:s.editor_type==="private"?"default":"outline",children:s.editor_type==="private"?"Editor Privado":"Editor Público"})]}),e.jsx(v,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Estado:"})]}),e.jsx(c,{variant:"outline",className:s.is_active?"bg-green-100 text-green-800 border-green-200":"bg-gray-100 text-gray-800 border-gray-200",children:s.is_active?"Activo":"Inactivo"})]})]})]})]})]}):null}export{ge 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.