PageSourceSearch

https://portal.lanmac.edu.do/assets/Announcements-CHVzsaSH.js

js lanmac.edu.do collected 2026-10-05 23:44:35 UTC 8,510 bytes, 1 lines download raw bytes

1import{a as te,ci as ne,cj as le,ck as ie,cl as re,r as t,j as e,B as l,a0 as I,a1 as L,a2 as F,a3 as H,v as G,a4 as R,d as m,I as V,a9 as ce,x as de,y as oe,z as ue,F as xe,G as he,a5 as U,L as E,C as me,g as pe,V as $,E as ge,a6 as r}from"./index-BczQTqp9.js";import{t as q}from"./timezone-BfF1D3hP.js";import{T as je,a as be,b as Q,c as p,d as ve,e as g}from"./table-D-A_G3DW.js";import{P as fe}from"./plus-liZ-xsff.js";import{E as Ne}from"./eye-off-C_SstIda.js";import{P as ye}from"./pencil-DfKO-wvy.js";import{T as we}from"./trash-2-B4lfkL2k.js";const f=[{value:"all",label:"Todos"},{value:"students",label:"Estudiantes"},{value:"teachers",label:"Docentes"},{value:"parents",label:"Padres"}],Ce={all:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",students:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",teachers:"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-400",parents:"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-400"};function De(i){return i.published_at?i.expires_at&&new Date(i.expires_at)<new Date?{label:"Expirado",variant:"destructive"}:{label:"Publicado",variant:"success"}:{label:"Borrador",variant:"secondary"}}const Me=()=>{var z;const{profile:i}=te(),{data:n,isLoading:J}=ne(),T=le(),N=ie(),y=re(),[K,u]=t.useState(!1),[c,P]=t.useState(null),[x,w]=t.useState(""),[C,D]=t.useState(""),[A,_]=t.useState("all"),[k,S]=t.useState(!0),[j,b]=t.useState(""),[d,W]=t.useState("all"),[o,v]=t.useState(null),M=t.useMemo(()=>n?d==="all"?n:n.filter(s=>s.audience===d):[],[n,d]);function X(){P(null),w(""),D(""),_("all"),S(!0),b(""),u(!0)}function Y(s){P(s),w(s.title),D(s.body||""),_(s.audience||"all"),S(!!s.published_at),b(s.expires_at?s.expires_at.slice(0,16):""),u(!0)}async function Z(){if(x.trim())try{c?(await N.mutateAsync({id:c.id,title:x.trim(),body:C.trim(),audience:A,published_at:k?c.published_at||new Date().toISOString():null,expires_at:q(j)}),r.success("Anuncio actualizado")):(await T.mutateAsync({title:x.trim(),body:C.trim(),audience:A,published_at:k?new Date().toISOString():null,expires_at:q(j),created_by:(i==null?void 0:i.full_name)||null}),r.success("Anuncio creado")),u(!1)}catch(s){r.error(s.message||"Error guardando anuncio")}}async function ee(){if(o){try{await y.mutateAsync(o.id),r.success("Anuncio eliminado")}catch(s){r.error(s.message||"Error eliminando")}v(null)}}async function se(s){try{await N.mutateAsync({id:s.id,published_at:s.published_at?null:new Date().toISOString()}),r.success(s.published_at?"Despublicado":"Publicado")}catch(a){r.error(a.message)}}const h=t.useMemo(()=>{if(!n)return{total:0,published:0,drafts:0,expired:0};const s=new Date;return{total:n.length,published:n.filter(a=>a.published_at&&(!a.expires_at||new Date(a.expires_at)>s)).length,drafts:n.filter(a=>!a.published_at).length,expired:n.filter(a=>a.expires_at&&new Date(a.expires_at)<s).length}},[n]),O=T.isPending||N.isPending;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Anuncios"}),e.jsxs("p",{className:"text-muted-foreground",children:[h.published," publicados, ",h.drafts," borradores",h.expired>0&&`, ${h.expired} expirados`," ","— ",h.total," total"]})]}),e.jsxs(l,{className:"gap-2",onClick:X,children:[e.jsx(fe,{className:"w-4 h-4"})," Nuevo Anuncio"]})]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:f.map(s=>e.jsx(l,{size:"sm",variant:d===s.value?"default":"outline",onClick:()=>W(s.value),children:s.label},s.value))}),e.jsx(I,{open:K,onOpenChange:u,children:e.jsxs(L,{className:"sm:max-w-lg",children:[e.jsxs(F,{children:[e.jsxs(H,{
1className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-5 h-5"}),c?"Editar Anuncio":"Nuevo Anuncio"]}),e.jsx(R,{children:c?"Modifica el contenido del anuncio.":"Crea un nuevo anuncio para la comunidad LANMAC."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{children:"Titulo"}),e.jsx(V,{value:x,onChange:s=>w(s.target.value),placeholder:"Ej: Horarios de verano 2026"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{children:"Contenido"}),e.jsx(ce,{value:C,onChange:s=>D(s.target.value),placeholder:"Escribe el contenido del anuncio...",rows:5})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{children:"Audiencia"}),e.jsxs(de,{value:A,onValueChange:_,children:[e.jsx(oe,{children:e.jsx(ue,{})}),e.jsx(xe,{children:f.map(s=>e.jsx(he,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",id:"publishNow",checked:k,onChange:s=>S(s.target.checked),className:"h-4 w-4 rounded border-gray-300"}),e.jsx(m,{htmlFor:"publishNow",className:"cursor-pointer",children:"Publicar ahora"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{children:"Expira (opcional)"}),e.jsx(V,{type:"datetime-local",value:j,onChange:s=>b(s.target.value),placeholder:"Dejar vacio para no expirar"}),j&&e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>b(""),className:"text-xs",children:"Quitar fecha de expiracion"})]})]}),e.jsxs(U,{children:[e.jsx(l,{variant:"outline",onClick:()=>u(!1),children:"Cancelar"}),e.jsx(l,{onClick:Z,disabled:!x.trim()||O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"w-4 h-4 animate-spin"})," Guardando..."]}):c?"Guardar Cambios":"Crear Anuncio"})]})]})}),e.jsx(I,{open:!!o,onOpenChange:()=>v(null),children:e.jsxs(L,{children:[e.jsxs(F,{children:[e.jsx(H,{children:"Eliminar Anuncio"}),e.jsxs(R,{children:['¿Estas seguro de que deseas eliminar "',o==null?void 0:o.title,'"? Esta accion no se puede deshacer.']})]}),e.jsxs(U,{children:[e.jsx(l,{variant:"outline",onClick:()=>v(null),children:"Cancelar"}),e.jsx(l,{variant:"destructive",onClick:ee,disabled:y.isPending,children:y.isPending?e.jsx(E,{className:"w-4 h-4 animate-spin"}):"Eliminar"})]})]})}),e.jsx(me,{children:e.jsx(pe,{className:"p-0",children:J?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(E,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):M.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(G,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),e.jsxs("p",{children:["No hay anuncios",d!=="all"?` para ${(z=f.find(s=>s.value===d))==null?void 0:z.label}`:""]})]}):e.jsxs(je,{children:[e.jsx(be,{children:e.jsxs(Q,{children:[e.jsx(p,{children:"Titulo"}),e.jsx(p,{className:"hidden md:table-cell",children:"Audiencia"}),e.jsx(p,{className:"hidden md:table-cell",children:"Estado"}),e.jsx(p,{className:"hidden lg:table-cell",children:"Fecha"}),e.jsx(p,{className:"text-right",children:"Acciones"})]})}),e.jsx(ve,{children:M.map(s=>{var B;const a=De(s);return e.jsxs(Q,{children:[e.jsx(g,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:s.body})]})}),e.jsx(g,{className:"hidden md:table-cell",children:e.jsx($,{className:Ce[s.audience]||"",variant:"secondary",children:((B=f.find(ae=>ae.value===s.audience))==null?void 0:B.label)||s.audience})}),e.jsx(g,{className:"hidden md:table-cell",children:e.jsx($,{variant:"secondary",className:a.variant==="success"?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":a.variant==="destructive"?"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400":"",children:a.label})}),e.jsx(g,{className:"hidden lg:table-cell text-sm text-muted-foreground",children:e.jsxs("div",{children:[new Date(s.created_at).toLocaleDateString("es-DO",{day:"numeric",month:"short",year:"numeric"}),s.expires_at&&e.jsxs("p",{className:"text-xs opacity-70",children:["Expira: ",new Date(s.expires_at).toLocaleDateString("es-DO",{day:"numeric",month:"short"})]})]})}),e.jsx(g,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(l,{size:"icon",variant:"ghost",onClick:()=>se(s),title:s.published_at?"Despublicar":"Publicar",children:s.published_at?e.jsx(Ne,{className:"w-4 h-4"}):e.jsx(ge,{className:"w-4 h-4"})}),e.jsx(l,{size:"icon",variant:"ghost",onClick:()=>Y(s),children:e.jsx(ye,{className:"w-4 h-4"})}),e.jsx(l,{size:"icon",variant:"ghost",className:"text-destructive",onClick:()=>v(s),children:e.jsx(we,{className:"w-4 h-4"})})]})})]},s.id)})})]})})})]})};export{Me 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.