PageSourceSearch

https://effervescent-cupcake-210607.netlify.app/assets/AdminReports-5As05-_y.js

js effervescent-cupcake-210607.netlify.app collected 2026-10-03 10:41:28 UTC 13,444 bytes, 44 lines download raw bytes

1import{r,j as e,s as n}from"./index-bMFZPluE.js";const R=({onBack:w})=>{const[N,k]=r.useState([]),[_,f]=r.useState(!0),[a,d]=r.useState(null),[c,h]=r.useState(""),[x,y]=r.useState(""),[p,m]=r.useState(!1),[o,b]=r.useState("Pendiente"),u=async()=>{f(!0);const{data:t,error:s}=await n.from("monthly_reports").select("*").order("created_at",{ascending:!1});t&&k(t),f(!1)};r.useEffect(()=>{u()},[]);const A=t=>{d(t),h(t.daily_notes_summary||""),y(t.monitor_conclusion||"")},C=async()=>{m(!0);const{error:t}=await n.from("monthly_reports").update({daily_notes_summary:c,monitor_conclusion:x,status:"Aprobado"}).eq("id",a.id);if(t){alert("🚨 Error al guardar el informe: "+t.message),m(!1);return}const{data:s}=await n.from("students").select("email, parent_email, parent_name").eq("name",a.student_name).maybeSingle(),i=String((s==null?void 0:s.email)||(s==null?void 0:s.parent_email)||"").trim();if(s&&i){const g="⭐".repeat(Math.round(a.average_attitude))+"☆".repeat(5-Math.round(a.average_attitude)),l="⭐".repeat(Math.round(a.average_understanding))+"☆".repeat(5-Math.round(a.average_understanding)),E=`
2        <div style="font-family: sans-serif; max-w: 600px; margin: 0 auto; color: #333; border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.05);">
3          <div style="background-color: #1c74e9; padding: 30px 20px; text-align: center;">
4            <h1 style="color: white; margin: 0; font-size: 24px; font-style: italic; font-weight: 900;">Profe en Casa</h1>
5            <p style="color: #bfdbfe; font-size: 12px; text-transform: uppercase; letter-spacing: 2px; margin-top: 5px;">Boletín Académico Mensual</p>
6          </div>
7          <div style="padding: 30px 20px;">
8            <p style="font-size: 16px;">Hola <strong>${s.parent_name!=="Familia"?s.parent_name.split(" ")[0]:"Familia"}</strong>,</p>
9            <p style="font-size: 16px;">El profesor ha preparado el informe de seguimiento de <strong>${a.student_name}</strong> correspondiente al mes de <strong>${a.month_year}</strong>.</p>
10            
11            <div style="background-color: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 20px; margin: 25px 0;">
12              <h3 style="margin-top: 0; font-size: 12px; text-transform: uppercase; color: #6b7280; border-bottom: 2px solid #e5e7eb; padding-bottom: 10px;">Métricas de Rendimiento</h3>
13              <div style="display: flex; justify-content: space-between; margin-bottom: 10px;">
14                <strong style="color: #374151;">Actitud y Trabajo:</strong>
15                <span style="color: #eab308; font-size: 16px;">${g} <span style="font-size:12px; color:#9ca3af;">(${a.average_attitude}/5)</span></span>
16              </div>
17              <div style="display: flex; justify-content: space-between;">
18                <strong style="color: #374151;">Comprensión:</strong>
19                <span style="color: #eab308; font-size: 16px;">${l} <span style="font-size:12px; color:#9ca3af;">(${a.average_understanding}/5)</span></span>
20              </div>
21            </div>
22
23            <div style="margin-bottom: 20px;">
24              <h3 style="font-size: 12px; text-transform: uppercase; color: #6b7280; margin-bottom: 8px;">Conclusión del Profesor</h3>
25              <div style="background-color: #eff6ff; border-left: 4px solid #3b82f6; padding: 15px; border-radius: 4px; color: #1e3a8a; font-style: italic; line-height: 1.5;">
26                "${x.replace(/\n/g,"<br/>")}"
27              </div>
28            </div>
29
30            <div style="margin-bottom: 20px;">
31              <h3 style="font-size: 12px; text-transform: uppercase; color: #6b7280; margin-bottom: 8px;">Registro de Sesiones Diarias</h3>
32              <div style="background-color: #f9fafb; border: 1px solid #e5e7eb; padding: 15px; border-radius: 4px; color: #4b5563; font-size: 14px; line-height: 1.5;">
33                ${c.replace(/\n/g,"<br/>")}
34              </div>
35            </div>
36
37            <p style="font-size: 12px; color: #9ca3af; text-align: center; margin-top: 30px;">
38              Si tienes cualquier duda sobre este informe, puedes responder a este correo o escribirnos por WhatsApp. ¡Gracias por confiar en nosotros! 🚀
39            </p>
40          </div>
41        </div>
42      `,{error:j}=await n.functions.invoke("send-email",{body:{to:i,subject:`📊 Informe Mensual de ${a.student_name} - Profe en Casa`,html:E}});alert(j?"El informe se aprobó y guardó, pero hubo un error enviando el email: "+j.message:"✅ ¡Informe aprobado y enviado al email de la familia con éxito!")}else alert("✅ Informe aprobado y guardado en su ficha. (Nota: La familia no tiene un email guardado, así que no se ha enviado el correo automático).");m(!1),d(null),u()},P=async t=>{const s=t.status==="Descartado",i=s?"Pendiente":"Descartado",g=s?"devolver a pendientes":"descartar";if(!window.confirm(`¿Quieres ${g} este informe?
43
44El informe se conservará y podrás recuperarlo.`))return;const{error:l}=await n.from("monthly_reports").update({status:i}).eq("id",t.id);if(l){alert("No se pudo cambiar el estado del informe: "+l.message);return}u()},v=N.filter(t=>t.status===o);return e.jsxs("div",{className:"max-w-md mx-auto w-full min-h-screen bg-[#F5F7FA] p-6 text-left pb-24 overflow-y-auto font-sans relative animate-in fade-in duration-300",children:[e.jsx("div",{className:"flex justify-between items-start mb-6",children:e.jsx("button",{onClick:w,className:"text-gray-400 text-[10px] font-black uppercase flex items-center gap-2 hover:text-[#1c74e9] transition-colors",children:"← Volver al Panel"})}),e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-black italic text-gray-900 leading-none",children:"Informes"}),e.jsx("p",{className:"text-red-600 text-[10px] font-black uppercase tracking-widest mt-2 bg-red-50 inline-block px-3 py-1 rounded-full border border-red-100",children:"Control de Calidad"})]}),e.jsxs("div",{className:"flex bg-gray-100 p-1 rounded-2xl mb-6 border border-gray-200",children:[e.jsxs("button",{onClick:()=>b("Pendiente"),className:`flex-1 py-3 rounded-xl text-[10px] font-black uppercase transition-all flex items-center justify-center gap-1 ${o==="Pendiente"?"bg-white text-red-600 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:[e.jsx("span",{className:"text-lg leading-none mt-[-2px]",children:"⚠️"})," PENDIENTES"]}),e.jsxs("button",{onClick:()=>b("Aprobado"),className:`flex-1 py-3 rounded-xl text-[10px] font-black uppercase transition-all flex items-center justify-center gap-1 ${o==="Aprobado"?"bg-white text-green-600 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:[e.jsx("span",{className:"text-lg leading-none mt-[-2px]",children:"✅"})," APROBADOS"]}),e.jsx("button",{onClick:()=>b("Descartado"),className:`flex-1 py-3 rounded-xl text-[10px] font-black uppercase transition-all flex items-center justify-center gap-1 ${o==="Descartado"?"bg-white text-slate-600 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:"ARCHIVO"})]}),e.jsx("div",{className:"space-y-4",children:_?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-4 border-[#1c74e9] border-t-transparent roun
44ded-full animate-spin"})}):v.length===0?e.jsxs("div",{className:"text-center py-10 bg-white rounded-[32px] p-8 border border-gray-100 shadow-sm",children:[e.jsx("span",{className:"text-4xl block mb-2 opacity-50",children:"✨"}),e.jsx("p",{className:"text-gray-900 font-bold text-sm",children:"Bandeja Vacía"}),e.jsx("p",{className:"text-gray-400 text-[10px] uppercase font-black tracking-widest mt-1",children:"Todo está al día"})]}):v.map(t=>e.jsxs("div",{className:`bg-white p-5 rounded-[28px] border transition-all relative overflow-hidden ${t.status==="Pendiente"?"border-red-100 shadow-sm hover:border-red-300":t.status==="Aprobado"?"border-green-100 shadow-sm hover:border-green-300":"border-slate-200 shadow-sm"}`,children:[e.jsx("div",{className:`absolute top-0 left-0 w-1.5 h-full ${t.status==="Pendiente"?"bg-red-500":t.status==="Aprobado"?"bg-green-500":"bg-slate-400"}`}),e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-gray-900 text-sm truncate",children:t.student_name}),e.jsx("p",{className:"text-gray-400 text-[9px] font-bold uppercase tracking-widest mt-0.5",children:t.month_year})]}),e.jsx("span",{className:`text-[8px] font-black uppercase tracking-widest px-2 py-1 rounded border ${t.status==="Pendiente"?"bg-red-50 text-red-600 border-red-100":t.status==="Aprobado"?"bg-green-50 text-green-600 border-green-100":"bg-slate-50 text-slate-600 border-slate-200"}`,children:t.status})]}),e.jsxs("div",{className:"bg-gray-50 p-3 rounded-xl border border-gray-100 mb-4 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-400 text-[8px] font-black uppercase tracking-widest mb-0.5",children:"Profesor"}),e.jsx("p",{className:"text-xs font-bold text-gray-900 truncate max-w-[150px]",children:t.monitor_email})]}),e.jsx("div",{className:"text-right",children:e.jsx("p",{className:"text-yellow-500 text-[10px] tracking-widest leading-none",children:"⭐".repeat(Math.round(t.average_attitude))})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>A(t),className:`flex-1 py-3 text-white font-black text-[10px] uppercase tracking-widest rounded-xl shadow-md active:scale-95 transition-all ${t.status==="Pendiente"?"bg-[#1c74e9] hover:bg-blue-600 shadow-blue-500/30":"bg-gray-800 hover:bg-gray-900"}`,children:t.status==="Pendiente"?"🔍 Revisar y Aprobar":"📄 Ver Informe"}),e.jsx("button",{onClick:()=>P(t),title:t.status==="Descartado"?"Recuperar informe":"Archivar informe",className:"w-12 flex items-center justify-center bg-gray-100 text-gray-500 hover:text-[#1c74e9] hover:bg-blue-50 rounded-xl transition-colors active:scale-95",children:t.status==="Descartado"?"↩":"📁"})]})]},t.id))}),a&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/80 backdrop-blur-sm z-[10000] p-4 flex justify-center items-center",children:e.jsxs("div",{className:"bg-white w-full max-w-md rounded-[32px] shadow-2xl relative flex flex-col max-h-[90vh] overflow-hidden animate-in zoom-in-95 duration-200 border border-gray-100",children:[e.jsxs("div",{className:"p-5 text-center border-b border-gray-100 shrink-0 bg-gray-50",children:[e.jsx("h3",{className:"text-[#1c74e9] font-black text-xl mb-1",children:"Informe Académico"}),e.jsxs("p",{className:"text-gray-500 text-[10px] uppercase font-black tracking-widest",children:[a.student_name," | ",a.month_year]})]}),e.jsxs("div",{className:"p-6 overflow-y-auto hide-scroll flex-1 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-blue-50 p-3 rounded-xl border border-blue-100 text-center",children:[e.jsx("p",{className:"text-blue-500 text-[8px] font-black uppercase tracking-widest",children:"Actitud Media"}),e.jsxs("p",{className:"text-blue-700 font-black text-lg",children:[a.average_attitude," ",e.jsx("span",{className:"text-sm",children:"/ 5"})]})]}),e.jsxs("div",{className:"bg-blue-50 p-3 rounded-xl border border-blue-100 text-center",children:[e.jsx("p",{className:"text-blue-500 text-[8px] font-black uppercase tracking-widest",children:"Comprensión"}),e.jsxs("p",{className:"text-blue-700 font-black text-lg",children:[a.average_understanding," ",e.jsx("span",{className:"text-sm",children:"/ 5"})]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-gray-400 text-[10px] font-black uppercase tracking-widest mb-2 flex items-center justify-between",children:[e.jsx("span",{children:"Conclusión del Profesor"}),e.jsx("span",{className:"text-blue-500 bg-blue-50 px-2 py-0.5 rounded text-[8px]",children:"Editable ✏️"})]}),e.jsx("textarea",{value:x,onChange:t=>y(t.target.value),disabled:a.status!=="Pendiente",className:"w-full bg-white text-gray-900 p-4 rounded-2xl border border-gray-200 outline-none text-sm min-h-[120px] focus:border-[#1c74e9] transition-colors shadow-inner"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-gray-400 text-[10px] font-black uppercase tracking-widest mb-2 flex items-center justify-between",children:[e.jsx("span",{children:"Registro Diario (IA)"}),e.jsx("span",{className:"text-blue-500 bg-blue-50 px-2 py-0.5 rounded text-[8px]",children:"Editable ✏️"})]}),e.jsx("textarea",{value:c,onChange:t=>h(t.target.value),disabled:a.status!=="Pendiente",className:"w-full bg-white text-gray-900 p-4 rounded-2xl border border-gray-200 outline-none text-xs min-h-[150px] focus:border-[#1c74e9] transition-colors shadow-inner leading-relaxed"})]})]}),e.jsxs("div",{className:"p-4 border-t border-gray-100 bg-gray-50 shrink-0 flex gap-3",children:[e.jsx("button",{type:"button",onClick:()=>d(null),className:"flex-1 py-4 text-gray-500 font-black text-[10px] uppercase tracking-widest hover:text-gray-900 transition-colors bg-gray-200 rounded-xl",children:"Cancelar"}),a.status==="Pendiente"&&e.jsx("button",{onClick:C,disabled:p,className:`flex-[2] py-4 font-black rounded-xl shadow-lg uppercase text-[10px] tracking-widest transition-all ${p?"bg-gray-300 text-gray-500 shadow-none cursor-not-allowed":"bg-green-500 text-white shadow-green-500/30 active:scale-95 hover:bg-green-600"}`,children:p?"Enviando email...":"✅ Aprobar y Enviar"})]})]})})]})};export{R as AdminReports};

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.