PageSourceSearch

https://sistur.lovable.app/assets/EduCalendario-DHABSr_q.js

js sistur.lovable.app collected 2026-10-03 03:44:56 UTC 9,676 bytes, 1 lines download raw bytes

1import{r as o,j as e,L as G}from"./vendor-react-CO7PoREX.js";import{t as s,F as K,O as J,d as g,G as Q,H as W,J as Y,K as Z,L as m,S as y,j as w,k as S,l as E,m as D,I as h,M as X,N as ee,r as se,s as ae,A as te,C as le,f as ne,g as ie,i as re,n as oe,B as ce}from"./index-pTXHG3cO.js";import{b as de}from"./eduSubNav-DIFZS1Vh.js";import{u as me}from"./useEduTrainings-B3Ir4jax.js";import{u as ue}from"./useStudentAssignments-BRx9C2HT.js";import{b as xe,d as he}from"./icsExport-BYKh04Qh.js";import{a as pe,b as ve,c as je}from"./useClassroomEvents-T8U7BM0T.js";import{u as ge}from"./vendor-query-BrmcFX9b.js";import{a1 as fe,b3 as be,ac as F,W as Ne,U as H,ad as Ce,E as ye,bE as we,ao as Se,aL as Ee,Z as De,F as _e}from"./vendor-icons-CbEPf7Uj.js";import{a as Te,i as R,b as B}from"./isBefore-DzvMFV2Q.js";import{f as _}from"./format-BiRs32QI.js";function Me(){const{user:c}=se();return ge({queryKey:["my-owned-classrooms",c==null?void 0:c.id],queryFn:async()=>{if(!c)return[];const{data:u,error:d}=await ae.from("classrooms").select("id, name").eq("professor_id",c.id).eq("status","active").order("name");if(d)throw d;return u??[]},enabled:!!c})}const ke=[{value:"aula",label:s("Aula")},{value:"live",label:s("Live")},{value:"prova",label:s("Prova")},{value:"prazo",label:s("Prazo")},{value:"reuniao",label:s("Reunião")},{value:"evento",label:s("Evento")}],Ae=[0,15,30,60,120,1440];function $e(){const[c,u]=o.useState(!1),{data:d=[]}=Me(),v=pe(),[x,j]=o.useState(""),[p,f]=o.useState(""),[b,n]=o.useState(""),[i,a]=o.useState("aula"),[l,r]=o.useState(""),[N,T]=o.useState("19:00"),[C,M]=o.useState(""),[k,A]=o.useState(""),[$,L]=o.useState(""),[I,P]=o.useState(""),[O,z]=o.useState(60);o.useEffect(()=>{!x&&d[0]&&j(d[0].id)},[d,x]);const V=()=>{f(""),n(""),a("aula"),r(""),T("19:00"),M(""),A(""),L(""),P(""),z(60)},q=()=>{if(!x||!p.trim()||!l)return;const t=new Date(`${l}T${N||"00:00"}`).toISOString(),U=C?new Date(`${C}T${k||N||"00:00"}`).toISOString():null;v.mutate({classroom_id:x,title:p.trim(),description:b.trim()||void 0,event_type:i,starts_at:t,ends_at:U,location:$.trim()||null,link_url:I.trim()||null,alarm_minutes_before:O},{onSuccess:()=>{V(),u(!1)}})};return d.length===0?null:e.jsxs(K,{open:c,onOpenChange:u,children:[e.jsx(J,{asChild:!0,children:e.jsxs(g,{variant:"default",children:[e.jsx(fe,{className:"h-4 w-4 mr-2"})," ",s("Novo evento")]})}),e.jsxs(Q,{className:"max-w-lg",children:[e.jsxs(W,{children:[e.jsx(Y,{children:s("Criar evento da turma")}),e.jsx(Z,{children:s("Os alunos matriculados serão notificados automaticamente.")})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(m,{children:s("Turma")}),e.jsxs(y,{value:x,onValueChange:j,children:[e.jsx(w,{children:e.jsx(S,{placeholder:s("Escolha a turma")})}),e.jsx(E,{children:d.map(t=>e.jsx(D,{value:t.id,children:t.name},t.id))})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(m,{children:s("Título")}),e.jsx(h,{value:p,onChange:t=>f(t.target.value),placeholder:s("Ex.: Aula sobre IGMA")})]}),e.jsxs("div",{children:[e.jsx(m,{children:s("Tipo")}),e.jsxs(y,{value:i,onValueChange:t=>a(t),children:[e.jsx(w,{children:e.jsx(S,{})}),e.jsx(E,{children:ke.map(t=>e.jsx(D,{value:t.value,children:s(t.label)},t.value))})]})]}),e.jsxs("div",{children:[e.jsx(m,{children:s("Alarme (antes)")}),e.jsxs(y,{value:String(O),onValueChange:t=>z(Number(t)),children:[e.jsx(w,{children:e.jsx(S,{})}),e.jsx(E,{children:Ae.map(t=>e.jsx(D,{value:String(t),children:t===0?s("No horário"):t<60?`${t} min`:t===1440?"1 dia":`${t/60} h`},t))})]})]}),e.jsxs("div",{children:[e.jsx(m,{children:s("Data")}),e.jsx(h,{type:"date",value:l,onChange:t=>r(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(m,{children:s("Horário")}),e.jsx(h,{type:"time",value:N,onChange:t=>T(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(m,{children:s("Fim (data)")}),e.jsx(h,{type:"date",value:C,onChange:t=>M(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(m,{children:s("Fim (hora)")}),e.jsx(h,{type:"time",value:k,onChange:t=>A(t.target.value)})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(m,{children:s("Local")}),e.jsx(h,{value:$,onChange:t=>L(t.target.value),placeholder:s("Sala 12 ou online")})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(m,{children:s("Link (opcional)")}
1),e.jsx(h,{value:I,onChange:t=>P(t.target.value),placeholder:"https://meet..."})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(m,{children:s("Descrição")}),e.jsx(X,{value:b,onChange:t=>n(t.target.value),rows:3})]})]})}),e.jsxs(ee,{children:[e.jsx(g,{variant:"ghost",onClick:()=>u(!1),children:s("Cancelar")}),e.jsx(g,{onClick:q,disabled:!p.trim()||!l||v.isPending,children:v.isPending?s("Criando..."):s("Criar e notificar")})]})]})]})}function Ue(){const{data:c}=me(),{data:u}=ue(),{data:d}=ve(),v=je(),x=o.useMemo(()=>{const n=[],i=new Date,a=Te(i,90);return c==null||c.forEach(l=>{if(l.type==="live"&&l.scheduled_at){const r=new Date(l.scheduled_at);R(r,i)&&B(r,a)&&n.push({id:`live-${l.training_id}`,title:l.title,date:r,type:"live",href:`/edu/training/${l.training_id}`,description:s("Aula ao vivo")})}}),u==null||u.forEach(l=>{if(l.due_date){const r=new Date(l.due_date);R(r,i)&&B(r,a)&&n.push({id:`asg-${l.id}`,title:`${l.title} (${l.classroom_name})`,date:r,type:l.assignment_type==="exam"?"exam":"assignment_due",description:l.description??void 0})}}),d==null||d.forEach(l=>{const r=new Date(l.starts_at);n.push({id:`clev-${l.id}`,rawId:l.id,title:l.title,date:r,type:l.event_type,description:l.description??void 0,location:l.location,link:l.link_url,classroom:l.classroom_name,alarmMinutes:l.alarm_minutes_before,isOwner:l.is_owner})}),n.sort((l,r)=>l.date.getTime()-r.date.getTime())},[c,u,d]),j=o.useMemo(()=>{const n={};return x.forEach(i=>{const a=_(i.date,"yyyy-MM-dd");(n[a]||(n[a]=[])).push(i)}),n},[x]),p=()=>{const n=xe(x.map(i=>({uid:i.id,title:i.title,description:i.description,start:i.date,url:i.href?`${window.location.origin}${i.href}`:void 0})),"SISTUR EDU — Calendário Acadêmico");he("sistur-edu-calendario",n)},f=n=>n==="live"||n==="aula"?e.jsx(Ee,{className:"h-4 w-4 text-red-500"}):n==="exam"||n==="prova"?e.jsx(De,{className:"h-4 w-4 text-amber-500"}):n==="reuniao"?e.jsx(H,{className:"h-4 w-4 text-purple-500"}):n==="evento"?e.jsx(F,{className:"h-4 w-4 text-emerald-500"}):e.jsx(_e,{className:"h-4 w-4 text-blue-500"}),b=n=>{const a={live:{v:"destructive",label:s("Live")},aula:{v:"destructive",label:s("Aula")},exam:{v:"secondary",label:s("Exame")},prova:{v:"secondary",label:s("Prova")},assignment_due:{v:"default",label:s("Prazo")},prazo:{v:"default",label:s("Prazo")},reuniao:{v:"outline",label:s("Reunião")},evento:{v:"outline",label:s("Evento")}}[n]??{v:"outline",label:s("Evento")};return e.jsx(ce,{variant:a.v,children:s(a.label)})};return e.jsx(te,{subNav:de,title:s("Calendário Acadêmico"),subtitle:s("Lives, prazos e exames dos próximos 90 dias"),actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsx($e,{}),e.jsxs(g,{variant:"outline",onClick:p,disabled:x.length===0,children:[e.jsx(be,{className:"h-4 w-4 mr-2"}),s("Exportar .ics")]})]}),children:e.jsx("div",{className:"container mx-auto p-4 md:p-6 space-y-4",children:e.jsxs(le,{children:[e.jsx(ne,{className:"pb-2",children:e.jsx(ie,{className:"text-base",children:s("Próximos eventos")})}),e.jsx(re,{children:Object.keys(j).length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(F,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:s("Nenhum evento agendado nos próximos 90 dias.")})]}):e.jsx("div",{className:"space-y-5",children:Object.entries(j).map(([n,i])=>e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-muted-foreground mb-2",children:_(new Date(n),s("EEEE, dd 'de' MMMM 'de' yyyy"),{locale:oe()})}),e.jsx("div",{className:"space-y-2",children:i.map(a=>{const l=e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors",children:[f(a.type),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium line-clamp-1",children:s(a.title)}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ne,{className:"h-3 w-3"}),_(a.date,"HH:mm")]}),a.classroom&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(H,{className:"h-3 w-3"}),a.classroom]}),a.location&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ce,{className:"h-3 w-3"}),a.location]}),typeof a.alarmMinutes=="number"&&a.alarmMinutes>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ye,{className:"h-3 w-3"}),a.alarmMinutes<60?`${a.alarmMinutes}min`:a.alarmMinutes===1440?"1 dia":`${a.alarmMinutes/60}h`," antes"]}),a.link&&e.jsxs("a",{href:a.link,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-primary hover:underline",onClick:r=>r.stopPropagation(),children:[e.jsx(we,{className:"h-3 w-3"}),s("Acessar")]})]}),a.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s(a.description)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[b(a.type),a.isOwner&&a.rawId&&e.jsx(g,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r=>{r.preventDefault(),confirm("Remover este evento?")&&v.mutate(a.rawId)},children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]})]});return a.href?e.jsx(G,{to:a.href,children:l},a.id):e.jsx("div",{children:l},a.id)})})]},n))})})]})})})}export{Ue 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.