PageSourceSearch

https://pernambucorevista.com.br/assets/AdminAgenda-DZytMM-d.js

js pernambucorevista.com.br collected 2026-10-02 11:42:42 UTC 8,736 bytes, 1 lines download raw bytes

1import{j as a}from"./vendor-motion-COWzbZXj.js";import{r as c}from"./vendor-react-DabW9_xZ.js";import{a as C,e as S,s as E}from"./agenda-Bma2H6SC.js";import{L as u,I as h}from"./ui-p4zgnDPv.js";import{C as T}from"./calendar-Dl999RoT.js";import{P as D}from"./pencil-CLtl7n-G.js";import{T as w}from"./trash-2-Bd81rPFg.js";import"./index-VlZpbbNi.js";import"./vendor-supabase-otNoK39h.js";const z={titulo:"",local:"",cidade:"Recife",pais:"Brasil",data_inicio:"",data_fim:"",descricao:"",link:""};function L(s){if(!s)return"—";const[n,f,x]=s.split("T")[0].split("-");return"".concat(x,"/").concat(f,"/").concat(n)}function N(s){return s>=new Date().toISOString().split("T")[0]}function $({evento:s,onClose:n,onSaved:f}){const x=!(s!=null&&s.id),[i,j]=c.useState(s!=null?s:z),[p,v]=c.useState(!1),[g,d]=c.useState(null);c.useEffect(()=>{const t=o=>{o.key==="Escape"&&n()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[n]);function r(t,o){j(m=>({...m,[t]:o}))}async function b(){var t;if(!i.titulo.trim()){d("Título é obrigatório.");return}if(!i.local.trim()){d("Local é obrigatório.");return}if(!i.data_inicio){d("Data de início é obrigatória.");return}v(!0),d(null);try{await E({...i.id?{id:i.id}:{},titulo:i.titulo,local:i.local,cidade:i.cidade,pais:i.pais,data_inicio:i.data_inicio,data_fim:i.data_fim||void 0,descricao:i.descricao||void 0,link:i.link||void 0}),f(),n()}catch(o){d((t=o.message)!=null?t:"Erro ao salvar.")}finally{v(!1)}}return a.jsx("div",{className:"adm-modal-overlay",children:a.jsxs("div",{className:"adm-modal",children:[a.jsxs("div",{className:"adm-modal-header",children:[a.jsx("h2",{className:"adm-modal-title",children:x?"Novo evento":"Editar evento"}),a.jsx("button",{onClick:n,style:{background:"none",border:"none",cursor:"pointer",fontSize:"1.25rem",color:"var(--adm-text-faint)",lineHeight:1},children:"×"})]}),a.jsxs("div",{className:"adm-modal-body",style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1rem"},children:[a.jsxs("div",{style:{gridColumn:"1/-1"},children:[a.jsx("label",{className:u,children:"Título *"}),a.jsx("input",{type:"text",value:i.titulo,onChange:t=>r("titulo",t.target.value),className:h,placeholder:"Nome do evento"})]}),a.jsxs("div",{style:{gridColumn:"1/-1"},children:[a.jsx("label",{className:u,children:"Local *"}),a.jsx("input",{type:"text",value:i.local,onChange:t=>r("local",t.target.value),className:h,placeholder:"Teatro, livraria, auditório…"})]}),a.jsxs("div",{children:[a.jsx("label",{className:u,children:"Cidade"}),a.jsx("input",{type:"text",value:i.cidade,onChange:t=>r("cidade",t.target.value),className:h})]}),a.jsxs("div",{children:[a.jsx("label",{className:u,children:"País"}),a.jsx("input",{type:"text",value:i.pais,onChange:t=>r("pais",t.target.value),className:h})]}),a.jsxs("div",{children:[a.jsx("label",{className:u,children:"Data início *"}),a.jsx("input",{type:"date",value:i.data_inicio,onChange:t=>r("data_inicio",t.target.value),className:h})]}),a.jsxs("div",{children:[a.jsx("label",{className:u,children:"Data fim"}),a.jsx("input",{type:"date",value:i.data_fim,onChange:t=>r("data_fim",t.target.value),className:h,min:i.data_inicio})]}),a.jsxs("div",{style:{gridColumn:"1/-1"},children:[a.jsx("label",{className:u,children:"Descrição"}),a.jsx("textarea",{value:i.descricao,onChange:t=>r("descricao",t.target.value),rows:3,className:h,style:{resize:"none"},placeholder:"Detalhes do evento…"})]}),a.jsxs("div",{style:{gridColumn:"1/-1"},children:[a.jsx("label",{className:u,children:"Link"}),a.jsx("input",{type:"url",value:i.link,onChange:t=>r("link",t.target.value),className:h,placeholder:"https://…"})]})]}),g&&a.jsx("div",{className:"adm-alert adm-alert-error",style:{margin:"0 1.5rem 0.75rem"},children:g}),a.jsxs("div",{className:"adm-modal-footer",children:[a.jsx("button",{onClick:n,className:"adm-btn adm-btn-secondary",children:"Cancelar"}),a.jsx("button",{onClick:b,disabled:p,className:"adm-btn adm-btn-primary",children:p?"Salvando…":x?"Adicionar":"Salvar"})]})]})})}function H(){const[s,n]=c.useState([]),[f,x]=c.useState(!0),[i,j]=c.useState(null),[p,v]=c.useState(!1),[g,d]=c.useState({aberto:!1,evento:null});async function r(){var e;x(!0),j(null);try{n(await C())}catch(l){j((e=l.message)!=null?e:"Erro ao carregar.")}finally{x(!1)}}c.useEffect(()=>{r()},[]);async function b(e){if(confirm('Excluir "'.concat(e.titulo,'"?')))try{await S(e.id),n(l=>l.filter(y=>y.id!==e.id))}catch(l){alert("Erro: "+l.message)}}function t(e){var l,y,_;d({aberto:!0,evento:{id:e.id,titulo:e.titulo,local:e.local,cidade:e.cidade,pais:e.pais,data_inicio:e.data_inicio,data_fim:(l
1=e.data_fim)!=null?l:"",descricao:(y=e.descricao)!=null?y:"",link:(_=e.link)!=null?_:""}})}const o=s.filter(e=>N(e.data_inicio)),m=s.filter(e=>!N(e.data_inicio)),k=p?s:o;return a.jsxs("div",{className:"fi-page",children:[a.jsxs("div",{className:"fi-page-header",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"fi-page-heading",children:"Agenda Literária"}),a.jsxs("p",{className:"fi-page-subheading",children:[o.length," evento",o.length!==1?"s":""," próximo",o.length!==1?"s":"",m.length>0&&" · ".concat(m.length," passado").concat(m.length!==1?"s":"")]})]}),a.jsx("button",{onClick:()=>d({aberto:!0,evento:null}),className:"adm-btn adm-btn-primary",children:"+ Novo evento"})]}),i&&a.jsxs("div",{className:"adm-alert adm-alert-error",style:{marginBottom:"1rem"},children:[i," — ",a.jsx("button",{onClick:r,style:{background:"none",border:"none",cursor:"pointer",textDecoration:"underline",color:"inherit",fontSize:"inherit"},children:"tentar novamente"})]}),f?a.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"5rem 0"},children:a.jsxs("div",{className:"adm-dots",children:[a.jsx("span",{}),a.jsx("span",{}),a.jsx("span",{})]})}):a.jsxs(a.Fragment,{children:[k.length===0?a.jsx("div",{className:"fi-section",children:a.jsxs("div",{className:"adm-empty",children:[a.jsx("div",{className:"adm-empty-icon",children:a.jsx(T,{size:40,strokeWidth:1.25})}),a.jsx("p",{className:"adm-empty-text",children:"Nenhum evento próximo cadastrado."}),a.jsx("button",{onClick:()=>d({aberto:!0,evento:null}),className:"adm-btn adm-btn-primary adm-btn-sm",style:{marginTop:"1rem"},children:"Adicionar evento"})]})}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:k.map(e=>{const l=N(e.data_inicio);return a.jsxs("div",{className:"fi-event-card fi-group ".concat(l?"":"fi-event-card-past"),children:[a.jsxs("div",{className:"fi-event-date",children:[a.jsx("div",{className:"fi-event-day",children:e.data_inicio.split("-")[2]}),a.jsx("div",{className:"fi-event-month",children:new Date(e.data_inicio+"T12:00:00").toLocaleDateString("pt-BR",{month:"short"})}),a.jsx("div",{className:"fi-event-year",children:e.data_inicio.split("-")[0]})]}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",marginBottom:"0.25rem"},children:[a.jsx("p",{style:{fontWeight:600,fontSize:"0.875rem",color:"var(--adm-text)",flex:1},children:e.titulo}),!l&&a.jsx("span",{className:"adm-badge adm-badge-gray",children:"Encerrado"})]}),a.jsxs("p",{style:{fontSize:"0.75rem",color:"var(--adm-text-muted)"},children:["📍 ",e.local," · ",e.cidade,e.pais!=="Brasil"?", ".concat(e.pais):""]}),e.data_fim&&e.data_fim!==e.data_inicio&&a.jsxs("p",{style:{fontSize:"0.6875rem",color:"var(--adm-text-faint)",marginTop:"0.125rem"},children:["Até ",L(e.data_fim)]}),e.descricao&&a.jsx("p",{style:{fontSize:"0.75rem",color:"var(--adm-text-muted)",marginTop:"0.375rem",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:e.descricao}),e.link&&a.jsx("a",{href:e.link,target:"_blank",rel:"noreferrer",style:{fontSize:"0.75rem",color:"var(--adm-accent)",textDecoration:"none",marginTop:"0.25rem",display:"inline-block"},children:"Saiba mais →"})]}),a.jsxs("div",{className:"fi-row-actions",children:[a.jsx("button",{onClick:()=>t(e),title:"Editar",className:"fi-action-btn",children:a.jsx(D,{size:14})}),a.jsx("button",{onClick:()=>b(e),title:"Excluir",className:"fi-action-btn fi-action-btn-danger",children:a.jsx(w,{size:14})})]})]},e.id)})}),m.length>0&&a.jsxs("button",{onClick:()=>v(e=>!e),style:{marginTop:"1rem",background:"none",border:"none",cursor:"pointer",fontSize:"0.8125rem",color:"var(--adm-text-muted)",display:"flex",alignItems:"center",gap:"0.375rem"},children:[a.jsx("span",{children:p?"▲":"▼"}),p?"Ocultar eventos passados":"Mostrar ".concat(m.length," evento").concat(m.length!==1?"s":""," passado").concat(m.length!==1?"s":"")]})]}),g.aberto&&a.jsx($,{evento:g.evento,onClose:()=>d({aberto:!1,evento:null}),onSaved:r})]})}export{H 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.