1/* ANPG DEVTEAM - 29/09/2026, 14:34:20 */ 2import{e as M,u as A,d as D,j as e}from"./data-vendor-BRYI0K8G.js";import{i as _,r as N,L as v}from"./react-vendor-Bj9LQV-u.js";import{A as z}from"./AdminLayout-h_nmul7P.js";import{b as c,w as C,cd as u,bh as h}from"./index-B5fS5HUA.js";import{I as L}from"./input-CtWCrhgd.js";import{B as x}from"./badge-jukGcCw8.js";import{T as B,a as F,b as w,c as d,d as K,e as o}from"./table-BTascmHv.js";import{A as Q,a as $,b as H,c as I,d as G,e as R,f as O,g as Z}from"./alert-dialog-J_9uTetV.js";import{C as J,b as U,c as V,d as W,a as X}from"./card-SWKDiSm6.js";import{P as Y,a as ee,b as p,c as se,d as ae,e as ie,f as te}from"./pagination-Ur29j9K4.js";import{P as re}from"./plus-lNvdMfmK.js";import{S as ne}from"./search-B8XA8FkL.js";import{E as oe}from"./eye-D_wcHN_j.js";import{P as le}from"./pencil-C8r3g6iN.js";import{C as ce}from"./copy-DPqCuShI.js";import{T as de}from"./trash-2-BmjaA2Y9.js";import{f as me,p as ue}from"./pt-C0cLzuL-.js";import"./message-square-3F19oJ7J.js";import"./newspaper-B1VsFBcy.js";import"./tag-zpo8YYRH.js";import"./camera-DF73IPZH.js";import"./shield-check-DBFg_Isw.js";import"./sliders-horizontal-CI8TRfgr.js";import"./user-check-Omtv7yGv.js";import"./network-Bioht48n.js";import"./clock-DjVV6Aw0.js";import"./book-open-BvZy1lzn.js";import"./bot-Ckp6pNDt.js";import"./gavel-D8KhpCGX.js";import"./presentation-Bg7Ve6-F.js";import"./star-BMTUmwlW.js";import"./clipboard-check-AscQTU3D.js";import"./folder-open-DBolFNfs.js";import"./settings-2-5vee-iyr.js";import"./label-ByFBDaC1.js";import"./rocket-OwwOM41y.js";import"./user-B2J0vviq.js";import"./arrow-left-B5pHXlkl.js";import"./circle-check-big-R1zEC76Q.js";import"./charts-vendor-Cs07Jtv5.js";import"./motion-vendor-DMc3mo8t.js";import"./i18n-vendor-BSIZ7LIS.js";import"./ellipsis-DVCWJu6c.js";const b=10;function is(){const E=_(),j=M(),[i,T]=N.useState(""),[r,f]=N.useState(null),[a,m]=N.useState(1),{data:g=0}=A({queryKey:["admin-articles-count",i],queryFn:async()=>{const s={limit:1};return i&&(s.title_like=i),(await u.list(s)).total??0}}),{data:n,isLoading:S}=A({queryKey:["admin-articles",a,i],queryFn:async()=>{const s=(a-1)*b,t={sort:"-created_at",limit:b,offset:s};return i&&(t.title_like=i),(await u.list(t)).data}}),P=D({mutationFn:async s=>{await u.delete(s)},onSuccess:()=>{j.invalidateQueries({queryKey:["admin-articles"]}),h.success("NotÃcia eliminada com sucesso"),f(null)},onError:s=>{h.error(`Erro ao eliminar: ${s.message}`)}}),y=D({mutationFn:async s=>await u.duplicate(s),onSuccess:s=>{j.invalidateQueries({queryKey:["admin-articles"]}),j.invalidateQueries({queryKey:["admin-articles-count"]}),h.success("NotÃcia duplicada com sucesso"),s!=null&&s.id&&E(`/admin/news/${s.id}`)},onError:s=>{h.error(`Erro ao duplicar: ${s.message}`)}}),l=Math.ceil(g/b),k=s=>{T(s),m(1)},q=s=>{switch(s){case"published":return e.jsx(x,{className:"bg-status-success text-white",children:"Publicado"});case"draft":return e.jsx(x,{variant:"secondary",children:"Rascunho"});case"archived":return e.jsx(x,{variant:"outline",children:"Arquivado"});default:return e.jsx(x,{variant:"outline",children:s})}};return e.jsxs(z,{title:"NotÃcias",subtitle:"Gerir artigos e publicações",children:[e.jsx("main",{className:"container mx-auto px-4 py-8",children:e.jsxs(J,{children:[e.jsx(U,{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(V,{children:"NotÃcias"}),e.jsx(W,{children:"Gerir artigos e comunicados de imprensa"})]}),e.jsx(c,{asChild:!0,children:e.jsxs(v,{to:"/admin/news/new",children:[e.jsx(re,{className:"h-4 w-4 mr-2"}),"Nova NotÃcia"]})})]})}),e.jsxs(X,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(ne,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(L,{placeholder:"Pesquisar notÃcias...",value:i,onChange:s=>k(s.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[g," ",g===1?"notÃcia":"notÃcias"]})]}),S?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border",children:e.jsxs(B,{children:[e.jsx(F,{children:e.jsxs(w,{children:[e.jsx(d,{children:"TÃtulo"}),e.jsx(d,{children:"Estado"}),e.jsx(d,{children:"Categoria"}),e.jsx(d,{children:"Data"}),e.jsx(d,{className:"text-right",children:"Acções"})]})}),e.jsx(K,{children:(n==null?void 0:n.length)===0?e.jsx(w,{children:e.jsx(o,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:i?"Nenhuma notÃcia encontrada.":"Ainda não existem notÃcias. Crie a primeira!"})}):n==null?void 0:n.map(s=>e.jsxs(w,{children:[e.jsx(o,{className:"font-medium",children:s.title}),e.jsx(o,{children:q(s.status)}),e.jsx(o,{className:"capitalize",children:s.category}),e.jsx(o,{children:me(new Date(s.created_at),"d MMM yyyy",{locale:ue})}),e.jsx(o,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[s.status==="published"&&e.jsx(c,{variant:"ghost",size:"icon",asChild:!0,children:e.jsx(v,{to:`/noticias/${s.slug}`,target:"_blank",children:e.jsx(oe,{className:"h-4 w-4"})})}),e.jsx(c,{variant:"ghost",size:"icon",asChild:!0,children:e.jsx(v,{to:`/admin/news/${s.id}`,children:e.jsx(le,{className:"h-4 w-4"})})}),e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>y.mutate(s.id),disabled:y.isPending,title:"Duplicar notÃcia",children:y.isPending?e.jsx(C,{className:"h-4 w-4 animate-spin"}):e.jsx(ce,{className:"h-4 w-4"})}),e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>f(s),children:e.jsx(de,{className:"h-4 w-4 text-destructive"})})]})})]},s.id))})]})}),l>1&&e.jsx("div",{className:"mt-6",children:e.jsx(Y,{children:e.jsxs(ee,{children:[e.jsx(p,{children:e.jsx(se,{href:"#",onClick:s=>{s.preventDefault(),a>1&&m(a-1)},className:a===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:l},(s,t)=>t+1).map(s=>s===1||s===l||s>=a-1&&s<=a+1?e.jsx(p,{children:e.jsx(ae,{href:"#",isActive:s===a,onClick:t=>{t.preventDefault(),m(s)},className:"cursor-pointer",children:s})},s):s===a-2||s===a+2?e.jsx(p,{children:e.jsx(ie,{})},s):null),e.jsx(p,{children:e.jsx(te,{href:"#",onClick:s=>{s.preventDefault(),a<l&&m(a+1)},className:a===l?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})}),e.jsx(Q,{open:!!r,onOpenChange:()=>
2f(null),children:e.jsxs($,{children:[e.jsxs(H,{children:[e.jsx(I,{children:"Eliminar NotÃcia"}),e.jsxs(G,{children:['Tem a certeza que deseja eliminar "',r==null?void 0:r.title,'"? Esta acção não pode ser revertida.']})]}),e.jsxs(R,{children:[e.jsx(O,{children:"Cancelar"}),e.jsxs(Z,{onClick:()=>r&&P.mutate(r.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[P.isPending&&e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}),"Eliminar"]})]})]})})]})}export{is 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.