PageSourceSearch

https://autogestione2026.vercel.app/assets/DidatticaDashboard-79LTXvX1.js

js autogestione2026.vercel.app collected 2026-10-03 06:08:58 UTC 10,737 bytes, 1 lines download raw bytes

1import{r as i,o as S,c as P,j as e,S as R,b as D,e as E,t as p,A as $,d as h,f as g,h as j}from"./index-BgifBhjT.js";const z=({user:L})=>{const[c,w]=i.useState([]),[m,v]=i.useState(""),[y,N]=i.useState(!0),[x,u]=i.useState({isOpen:!1,course:null,studentEmail:null}),b=`artifacts/${$}/public`;i.useEffect(()=>{const t=S(P(h,`${b}/data`,"students"),s=>{const l=s.docs.map(r=>({id:r.id,...r.data()}));l.sort((r,a)=>{const n=(r.cognome||"").localeCompare(a.cognome||"");return n!==0?n:(r.nome||"").localeCompare(a.nome||"")}),w(l),N(!1)},s=>{console.error("Error fetching students:",s),p.error("Errore di connessione al database.")});return()=>t()},[]);const f=i.useMemo(()=>{if(!m)return c;const t=m.toLowerCase();return c.filter(s=>`${s.nome||""}`.toLowerCase().includes(t)||`${s.cognome||""}`.toLowerCase().includes(t)||`${s.classe||""}`.toLowerCase().includes(t)||`${s.email||""}`.toLowerCase().includes(t)||Object.values(s.rawDetails||{}).some(l=>String(l||"").toLowerCase().includes(t)))},[c,m]),C=t=>{if(t.parsedCourses&&Array.isArray(t.parsedCourses.day1)&&Array.isArray(t.parsedCourses.day2))return t.parsedCourses;if(!t.rawDetails)return{day1:[],day2:[]};const s={day1:[],day2:[]},l=new Set;return Object.entries(t.rawDetails).forEach(([r,a])=>{const n=r.toLowerCase(),o=String(a).trim();!o||["nome","name","cognome","surname","email","mail","classe","class","username","informazioni","timestamp"].some(A=>n.includes(A))||l.has(o.toLowerCase())||(l.add(o.toLowerCase()),n.includes("1")||n.includes("primo")?s.day1.push(o):(n.includes("2")||n.includes("secondo"))&&(n.includes("giorno")||n.includes("day")||n.includes("del"))?s.day2.push(o):s.day1.push(o))}),s},d=async(t,s,l)=>{try{const r=c.find(n=>n.email===t);if(!r)return;const a={...r.attendance};if(a[s]?.status===l)delete a[s];else{if(l==="R"){u({isOpen:!0,course:s,studentEmail:t});return}a[s]={status:l,timestamp:new Date().toISOString()}}await g(j(h,`${b}/data/students`,r.id),{attendance:a},{merge:!0})}catch(r){console.error(r),p.error("Errore salvataggio presenza.")}},k=async t=>{if(!(!x.studentEmail||!x.course))try{const s=c.find(r=>r.email===x.studentEmail);if(!s)return;const l={...s.attendance};l[x.course]={status:"R",note:t.trim(),timestamp:new Date().toISOString()},await g(j(h,`${b}/data/students`,s.id),{attendance:l},{merge:!0})}catch(s){console.error(s),p.error("Errore salvataggio ritardo.")}finally{u({isOpen:!1,course:null,studentEmail:null})}};return e.jsxs("div",{className:"container py-8 lg:py-12 fade-in relative min-h-screen",children:[e.jsx("div",{className:"absolute top-0 right-0 w-[500px] h-[500px] bg-blue-400/10 rounded-full blur-[100px] pointer-events-none -z-10 animate-blob"}),e.jsxs("div",{className:"mb-10 space-y-4",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 bg-blue-100 text-blue-700 rounded-full text-sm font-bold border border-blue-200",children:[e.jsx(R,{size:16})," Area Didattica"]}),e.jsx("h1",{className:"text-4xl md:text-5xl font-black text-slate-900 tracking-tight",children:"Registro Presenze"}),e.jsx("p",{className:"text-lg text-slate-600 font-medium max-w-2xl",children:"Gestione rapida delle presenze. Trova lo studente e segna P (Presente), R (Ritardo) o A (Assente)."})]}),e.jsx("div",{className:"glass bg-white/70 rounded-3xl p-6 border border-white/50 shadow-lg mb-8",children:e.jsxs("div",{className:"relative max-w-2xl",children:[e.jsx(D,{className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400",size:20}),e.jsx("input",{type:"text",placeholder:"Cerca per nome, cognome, classe o codice corso...",className:"w-full pl-11 pr-4 py-4 bg-white/90 border-2 border-slate-200 rounded-2xl font-medium text-slate-800 focus:outline-none focus:border-blue-500 transition-colors shadow-sm text-lg",value:m,onChange:t=>v(t.target.value)})]})}),y?e.jsx("div",{className:"py-20 flex justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600"})}):e.jsxs("div",{className:"bg-white rounded-3xl border border-slate-200 shadow-sm overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"grid grid-cols-12 gap-8 lg:gap-4 px-6 py-4 md:px-10 bg-slate-50 border-b border-slate-200 items-center",children:[e.jsx("div",{className:"col-span-12 lg:col-span-4 text-xs tracking-widest font-bold text-slate-400 uppercase",children:"Informazioni Studente"}),e.jsx("div",{className:"col-span-12 lg:col-span-8 flex text-xs tracking-widest font-bold text-slate-400 uppercase relative",children:"Corsi e Appello"})]}),e.jsxs("div",{className:"max-h-[70vh] overflow-y-auto custom-scrollbar flex-1 bg-white",children:[f.map((t,s)=>{const l=C(t),r=s%2===0;return e.jsxs("div",{className:`px-6 py-6 md:px-10 md:py-8 grid grid-cols-12 gap-8 lg:gap-4 items-start border-b border-slate-100/50 ${r?"bg-white":"bg-slate-50/40"}`,children:[e.jsxs("div",{className:"col-span-12 lg:col-span-4 flex flex-col justify-center h-full pt-4",children:[e.jsxs("h3",{className:"text-xl md:text-2xl font-black text-slate-800 uppercase tracking-tight leading-none mb-2",children:[t.cognome," ",t.nome]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"bg-slate-100 text-slate-600 font-bold px-2 py-1 rounded text-sm border border-slate-200",children:t.classe||"N/D"}),e.jsx("span",{className:"text-sm font-medium text-slate-400 italic",children:t.email})]})]}),e.jsxs("div",{className:"col-span-12 lg:col-span-8 grid grid-cols-1 xl:grid-cols-2 gap-6 xl:gap-10",children:[e.jsxs("div",{className:"space-y-4 w-full",children:[e.jsx("h4",{className:"text-xs font-bold text-slate-400 uppercase tracking-widest",children:"29 APR"}),e.jsx("div",{className:"space-y-3",children:l.day1.length>0?l.day1.map((a,n)=>{const o=t.attendance?.[a]?.status;return e.jsxs("div",{className:"bg-white rounded-xl p-3 border border-slate-200 shadow-sm flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-black text-slate-700 uppercase line-clamp-2",title:a,children:a}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>d(t.email,a,"P"),className:`w-10 h-10 rounded-xl text-sm font-black transition-all border flex items-center justify-center ${o==="P"?"bg-[#0f9d58] text-white border-[#0f9d58] shadow-md":"bg-slate-50 text-slate-400 border-slate-200 hover:border-[#0f9d58] hover:text-[#0f9d58]"}`,children:"P"}),e.jsxs("button",{onClick:()=>d(t.email,a,"R"),className:`w-10 h-10 rounded-xl text-sm font-black transition-all border flex flex-col items-center justify-center ${o==="R"?"bg-[#f4b400] text-white border-[#f4b400] shadow-md":"bg-slate-50 text-slate-400 border-slate-200 hover:border-[#f4b400] hover:text-[#f4b400]"}`,children:[e.jsx("span",{children:"R"}),o==="R"&&t.attendance[a]?.note&&e.jsx("span",{className:"text-[9px] font-normal leading-none mt-0.5",children:t.attendance[a].note})]}),e.jsx("button",{onClick:()=>d(t.email,a,"A"),className:`w-10 h-10 rounded-xl text-sm font-black transition-all border flex items-center justify-center ${o==="A"?"bg-[#db4437] text-white border-[#db4437] shadow-md":"bg-slate-50 text-slate-400 border-slate-200 hover:border-[#db4437] hover:text-[#db4437]"}`,children:"A"})]})]},n)}):e.jsx("p",{className:"text-xs text-slate-300 italic",children:"Nessun corso asssignato"})})]}),e.jsxs("div",{className:"space-y-4 w-full",children:[e.jsx("h4",{className:"text-xs font-bold text-slate-400 uppercase tracking-widest",children:"30 APR"}),e.jsx("div",{className:"space-y-3",children:l.day2.length>0?l.day2.map((a,n)=>{const o=t.attendance?.[a]?.status;return e.jsxs("div",{className:"bg-white rounded-xl p-3 border border-slate-200 shadow-sm flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-black text-slate-700 uppercase line-clamp-2",title:a,children:a}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>d(t.email,a,"P"),className:`w-10 h-10 rounded-xl text-sm font-black transition-all border flex items-center justify-center ${o==="P"?"bg-[#0f9d58] text-white border-[#0f9d58] shadow-md":"bg-slate-50 text-slate-400 border-slate-200 hover:border-[#0f9d58] hover:text-[#0f9d58]"}`,children:"P"}),e.jsxs("button",{onClick:()=>d(t.email,a,"R"),className:`w-10 h-10 rounded-xl text-sm font-black transition-all border flex flex-col items-center justify-center ${o==="R"?"bg-[#f4b400] text-white border-[#f4b400] shadow-md":"bg-slate-50 text-slate-400 border-slate-200 hover:border-[#f4b400] hover:text-[#f4b400]"}`,children:[e.jsx("span",{children:"R"}),o==="R"&&t.attendance[a]?.note&&e.jsx("span",{className:"text-[9px] font-normal leading-none mt-0.5",children:t.attendance[a].note})]}),e.jsx("button",{onClick:()=>d(t.email,a,"A"),className:`w-10 h-10 rounded-xl text-sm font-black transition-all border flex items-center justify-center ${o==="A"?"bg-[#db4437] text-white border-[#db4437] shadow-md":"bg-slate-50 text-slate-400 border-slate-200 hover:border-[#db4437] hover:text-[#db4437]"}`,children:"A"})]})]},n)}):e.jsx("p",{className:"text-xs text-slate-300 italic",children:"Nessun corso asssignato"})})]})]})]},t.id)}),f.length===0&&e.jsx("div",{className:"py-20 text-center text-slate-400 font-medium",children:"Nessuno studente trovato."})]})]}),x.isOpen&&E.createPortal(e.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4 bg-slate-900/60 backdrop-blur-md fade-in",style:{zIndex:9999},children:e.jsxs("div",{className:"glass bg-white w-full max-w-md rounded-3xl p-6 shadow-2xl border border-slate-200",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{className:"text-xl font-bold text-slate-800 mb-2",children:"Ora di Ingresso"}),e.jsx("p",{className:"text-slate-500 font-medium mb-6 text-sm",children:"A che ora è entrato lo studente in classe?"}),e.jsxs("form",{onSubmit:t=>{t.preventDefault();const s=t.target.time.value;k(s)},children:[e.jsx("input",{name:"time",type:"text",placeholder:"es. 08:15",className:"w-full px-4 py-3 bg-slate-50 rounded-xl border border-slate-200 font-medium text-slate-800 focus:outline-none focus:border-[#f4b400] focus:ring-4 focus:ring-[#f4b400]/2
10 transition-all shadow-sm mb-8",autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>u({isOpen:!1,course:null,studentEmail:null}),className:"px-4 py-2 rounded-xl font-bold bg-slate-100 text-slate-700 hover:bg-slate-200 transition-colors",children:"Annulla"}),e.jsx("button",{type:"submit",className:"px-4 py-2 rounded-xl font-bold text-white transition-all shadow-md bg-[#f4b400] hover:bg-[#f4b400]/90",children:"Salva"})]})]})]})}),document.body)]})};export{z as DidatticaDashboard,z 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.