PageSourceSearch

https://irpa2026colombia.org/assets/RegistrationsAdmin-vcqOKA1U.js

js irpa2026colombia.org collected 2026-10-08 03:16:55 UTC 10,093 bytes, 1 lines download raw bytes

1import{u as J,g as O,d as X,r as n,s as m,q as C,j as e,B as c,b as E}from"./index-DnVm687U.js";import{H as K,F as Q}from"./Footer-Bvqa_r8G.js";import{T as W,a as Y,b as R,c as o,d as Z,e as d}from"./table-DWz2i9MN.js";import{C as ee,b as ae,c as ie,d as te,a as re}from"./card-CRFaJYNz.js";import{B as u}from"./badge-BLNB1n0H.js";import{I as se}from"./input-D4ugazI8.js";import{A as ce}from"./arrow-left-i1Qu9EeE.js";import{F as ne}from"./file-text-BU0yiu-Q.js";import{E as B}from"./eye-Bub6U8nG.js";import{C as N}from"./circle-check-big-hO1idMQN.js";import{C as _}from"./circle-x-DIo5bdqO.js";import{U as F}from"./upload-0ilaCe4N.js";import"./dropdown-menu-elZyZctl.js";import"./index-B-Wc5f3e.js";import"./Combination-D1NCdNup.js";import"./index-C7OIboLl.js";import"./shield-BN1RiLGr.js";import"./log-out-CtUQRbPX.js";import"./search-BNZJvCG8.js";import"./mail-BBtFmBsn.js";const ze=()=>{const b=J(),{userRole:f,loading:p}=O(),{toast:r}=X(),[w,L]=n.useState([]),[H,z]=n.useState(!0),[h,$]=n.useState(""),[x,k]=n.useState(null),S=n.useRef(null),[T,U]=n.useState(null);n.useEffect(()=>{!p&&!["super_admin","admin_association"].includes(f||"")&&(r({title:"Acceso denegado",description:"No tienes permisos para acceder a esta página",variant:"destructive"}),b("/"))},[f,p,b,r]),n.useEffect(()=>{["super_admin","admin_association"].includes(f||"")&&y()},[f]);const y=async()=>{try{z(!0);const{data:a,error:i}=await m.from("registrations").select("*").eq("category","estudiante_pregrado").order("created_at",{ascending:!1});if(i)throw i;L(a||[])}catch(a){console.error("Error fetching registrations:",a),r({title:"Error",description:"No se pudieron cargar las inscripciones",variant:"destructive"})}finally{z(!1)}},j=async(a,i)=>{try{const t=w.find(s=>s.id===a);if(!t)throw new Error("Registro no encontrado");const{error:g}=await m.from("registrations").update({certificate_validated:i}).eq("id",a);if(g)throw g;try{const{error:s}=await m.functions.invoke("notify-certificate-result",{body:{email:t.primary_email,fullName:t.full_name,approved:i}});s?(console.error("Error sending certificate email:",s),r({title:i?"Certificado Validado":"Validación Rechazada",description:`${i?"El certificado ha sido validado":"Se ha rechazado la validación"}, pero hubo un error al enviar el email de notificación.`,variant:"default"})):r({title:i?"Certificado Validado":"Validación Rechazada",description:i?"El certificado ha sido validado y se envió notificación al participante para que proceda con el pago.":"Se ha rechazado el certificado y se notificó al participante que debe cargarlo nuevamente."})}catch(s){console.error("Error invoking email function:",s),r({title:i?"Certificado Validado":"Validación Rechazada",description:"Estado actualizado correctamente. No se pudo enviar el email de notificación."})}y()}catch(t){console.error("Error validating certificate:",t),r({title:"Error",description:"No se pudo actualizar el estado del certificado",variant:"destructive"})}},A=async a=>{try{const{data:i,error:t}=await m.storage.from("student-certificates").createSignedUrl(a,3600);if(t)throw t;if(i!=null&&i.signedUrl)try{const s=await(await fetch(i.signedUrl)).blob(),l=URL.createObjectURL(s);window.open(l,"_blank")}catch{window.open(i.signedUrl,"_blank")}}catch(i){console.error("Error viewing certificate:",i),r({title:"Error",description:"No se pudo abrir el certificado",variant:"destructive"})}},V=a=>{var i;U(a),(i=S.current)==null||i.click()},D=async a=>{var s;const i=(s=a.target.files)==null?void 0:s[0];if(!i||!T)return;const t=T;if(U(null),!["image/jpeg","image/png","application/pdf"].includes(i.type)){r({title:"Error",description:"Solo se permiten archivos JPG, PNG o PDF",variant:"destructive"}),a.target.value="";return}if(i.size>5*1024*1024){r({title:"Error",description:"El archivo no debe superar los 5MB",variant:"destructive"}),a.target.value="";return}try{k(t);const l=w.find(G=>G.id===t);if(!l)throw new Error("Registro no encontrado");const M=i.name.split(".").pop(),I=`admin-upload/${t}/${Date.now()}.${M}`,{error:P}=await m.storage.from("student-certificates").upload(I,i,{upsert:!0});if(P)throw P;const{error:q}=await m.from("registrations").update({student_certificate_url:I,certificate_validated:null}).eq("id",t);if(q)throw q;r({title:"Certificado cargado",description:`Se cargó el certificado para ${l.full_name}. Ahora puede aprobar o rechazar.`}),y()}catch(l){console.error("Error uploading certificate:",l),r({title:"Error",description:"No se pudo cargar el certificado: "+(l.message||""),variant:"destructive"})}finally{k(null),a.target.value=""}},v=w.filter(a=>C(a.full_name,h)||C(a.primary_email,h)||C(a.study_institution,h));return p||!["super_admin","admin_association"].includes(f||"")&&!p?null:e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(K,{}),e.jsx("main",{className:"flex-grow pt-20",children:e.jsxs("div",{className:"container mx-auto px-4 py-12",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsxs(c,{variant:"ghost",onClick:()=>b("/admin?tab=management"),className:"gap-2",children:[e.jsx(ce,{className:"h-4 w-4"}),"Volver al Panel"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Validación de Certificados"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Revisa y valida los certificados de estudios de los participantes estudiantes"})]})]}),e.jsxs(ee,{children:[e.jsxs(ae,{children:[e.jsxs(ie,{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"w-5 h-5"}),"Certificados Pendientes"]}),e.jsx(te,{children:"Lista de certificados de estudiantes que requieren validación"})]}),e.jsxs(re,{children:[e.jsx("div",{className:"mb-6",children:e.jsx(se,{placeholder:"Buscar por nombre, email o institución...",value:h,onChange:a=>$(a.target.value),className:"max-w-md"})}),e.jsx("input",{ref:S,type:"file",accept:".jpg,.jpeg,.png,.pdf",className:"hidden",onChange:D}),H?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(E,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-md border hidden md:block",children:e.jsxs(W,{children:[e.jsx(Y,{children:e.jsxs(R,{children:[e.jsx(o,{children:"Nombre"}),e.jsx(o,{children:"Email"}),e.jsx(o,{children:"Institución"}),e.jsx(o,{children:"Carrera"}),e.jsx(o,{children:"Certificado"}),e.jsx(o,{children:"Estado"}),e.jsx(o,{className:"text-right",children:"Acciones"})]})}),e.jsx(Z,{children:v.length===0?e.jsx(R,{children:e.jsx(d,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No hay inscripciones de estudiantes"})}):v.map(a=>e.jsxs(R,{children:[e.jsx(d,{className:"font-medium",children:a.full_name}),e.jsx(d,{children:a.primary_email}),e.jsx(d,{children:a.study_institution||"-"}),e.jsx(d,{children:a.career||"-"}),e.jsx(d,{children:a.student_certificate_url?e.jsxs(c,{variant:"ghost",size:"sm",onClick:()=>A(a.student_certificate_url),children:[e.jsx(B,{className:"w-4 h-4 mr-1"}),"Ver"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Sin certificado"})}),e.jsx(d,{children:a.certificate_validated===!0?e.jsxs(u,{className:"bg-green-500 hover:bg-green-600",children:[e.jsx(N,{className:"w-3 h-3 mr-1"}),"Aprobado"]}):a.certificate_validated===!1?e.jsxs(u,{variant:"destructive",children:[e.jsx(_,{className:"w-3 h-3 mr-1"}),"Rechazado"]}):e.jsx(u,{variant:"outline",children:"Pendiente"})}),e.jsx(d,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1 flex-wrap",children:[(!a.student_certificate_url||a.certificate_validated===!1)&&e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>V(a.id),disabled:x===a.id,children:[x===a.id?e.jsx(E,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(F,{className:"w-4 h-4 mr-1"}),"Subir"]}),a.certificate_validated!==!0&&a.student_certificate_url&&e.jsxs(e.Fragment,{children:[e.jsxs(c,{variant:"default",size:"sm",onClick:()=>j(a.id,!0),children:[e.jsx(N,{className:"w-4 h-4 mr-1"}),"Aprobar"]}),a.certificate_validated!==!1&&e.jsxs(c,{variant:"destructive",size:"sm",onClick:()=>j(a.id,!1),children:[e.jsx(_,{className:"w-4 h-4 mr-1"}),"Rechazar"]})]})]})})]},a.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3",children:v.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8",children:"No hay inscripciones de estudiantes"}):v.map(a=>e.jsxs("div",{className:"border rounded-lg p-4 space-y-2",children:[e.jsx("div",{className:"font-medium text-sm",children:a.full_name}),e.jsx("div",{className:"text-xs text-muted-foreground break-all",children:a.primary_email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[a.study_institution||"-"," · ",a.career||"-"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[a.certificate_validated===!0?e.jsxs(u,{className:"bg-green-500 hover:bg-green-600",children:[e.jsx(N,{className:"w-3 h-3 mr-1"}),"Aprobado"]}):a.certificate_validated===!1?e.jsxs(u,{variant:"destructive",children:[e.jsx(_,{className:"w-3 h-3 mr-1"}),"Rechazado"]}):e.jsx(u,{variant:"outline",children:"Pendiente"}),a.student_certificate_url&&e.jsxs(c,{variant:"ghost",size:"sm",onClick:()=>A(a.student_certificate_url),children:[e.jsx(B,{className:"w-4 h-4 mr-1"}),"Ver"]})]}),(!a.student_certificate_url||a.certificate_validated===!1)&&e.jsx("div",{className:"pt-1 border-t",children:e.jsxs(c,{variant:"outline",size:"sm",className:"w-full",onClick:()=>V(a.id),disabled:x===a.id,children:[x===a.id?e.jsx(E,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(F,{className:"w-4 h-4 mr-1"}),"Subir certificado manualmente"]})}),a.certificate_validated!==!0&&a.student_certificate_url&&e.jsxs("div",{className:"flex gap-2 pt-1 border-t",children:[e.jsxs(c,{variant:"default",size:"sm",className:"flex-1",onClick:()=>j(a.id,!0),children:[e.jsx(N,{className:"w-4 h-4 mr-1"}),"Aprobar"]}),a.certificate_validated!==!1&&e.jsxs(c,{variant:"destructive",size:"sm",className:"flex-1",onClick:()=>j(a.id,!1),children:[e.jsx(_,{className:"w-4 h-4 mr-1"}),"Rechazar"]})]})]},a.id))})]})]})]})]})}),e.jsx(Q,{})]})};export{ze 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.