PageSourceSearch

https://bafreinmobiliaria.es/assets/admin.observatorio.index-D_zRA-Ub.js

js bafreinmobiliaria.es collected 2026-10-04 17:52:16 UTC 4,683 bytes, 1 lines download raw bytes

1import{u as j,r as t,j as e,L as o,B as N,J as u}from"./index-DFhUiiAX.js";import{n as h}from"./noticiasService-DJrJ_x4R.js";import{C as y}from"./confirm-delete-dialog-Bu1UH_Vu.js";import{P as w}from"./plus-An2xpF0B.js";import{S as v}from"./star-nSbmZmiG.js";import{P as S}from"./pencil-jppC2Gwb.js";import{T as k}from"./trash-2-D4tqoxgS.js";import"./_cmsHttp-DkQOvB1A.js";import"./alert-dialog-DTv8TsdO.js";import"./index-F2K0RhTL.js";import"./index-BDVvL8Sa.js";function $(){const{t:l}=j(),[c,g]=t.useState([]),[a,d]=t.useState(!0),[i,x]=t.useState(null),[r,n]=t.useState(null),[b,m]=t.useState(!1);async function p(){d(!0),x(null);try{const s=await h.getNewsList();g(s.items)}catch(s){x(s instanceof Error?s.message:"No se pudieron cargar las noticias.")}finally{d(!1)}}t.useEffect(()=>{p()},[]);async function f(){if(r){m(!0);try{await h.deleteNews(r.id),u.success("Noticia eliminada correctamente."),n(null),p()}catch(s){u.error(s instanceof Error?s.message:"No se pudo eliminar.")}finally{m(!1)}}}return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-4 sm:flex sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"eyebrow",children:l("content.admin.observatorio.eyebrow")}),e.jsx("h1",{className:"mt-2 font-display text-3xl sm:text-4xl",children:l("content.admin.observatorio.title")})]}),e.jsxs(o,{to:"/admin/observatorio/nueva",className:"inline-flex h-10 shrink-0 items-center gap-2 bg-black px-3 text-[11px] font-medium uppercase tracking-widest text-white hover:bg-neutral-800 sm:px-4 sm:text-xs",children:[e.jsx(w,{className:"h-4 w-4"})," Nueva noticia"]})]}),e.jsx("div",{className:"border border-border bg-background overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[720px] text-sm md:min-w-0",children:[e.jsx("thead",{className:"border-b border-border bg-surface text-left text-xs uppercase tracking-widest text-muted-foreground md:tracking-normal lg:tracking-widest",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 md:px-2 lg:px-4",children:"Título"}),e.jsx("th",{className:"px-4 py-3 md:px-2 lg:px-4",children:"Categoría"}),e.jsx("th",{className:"px-4 py-3 md:px-2 lg:px-4",children:"Publicación"}),e.jsx("th",{className:"px-4 py-3 md:px-2 lg:px-4",children:"Destacada"}),e.jsx("th",{className:"px-4 py-3 md:px-2 lg:px-4"})]})}),e.jsxs("tbody",{children:[a&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-muted-foreground",children:e.jsx(N,{size:"md",showLabel:!0,label:"Cargando…"})})}),!a&&i&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-bafre-red",children:i})}),!a&&!i&&c.length===0&&e.jsx("tr",{children:e.jsxs("td",{colSpan:5,className:"px-4 py-10 text-center text-muted-foreground",children:["Todavía no hay noticias. Pulsa ",e.jsx("strong",{children:"Nueva noticia"})," para crear la primera."]})}),c.map(s=>e.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[e.jsx("td",{className:"px-4 py-3 md:px-2 lg:px-4",children:e.jsx(o,{to:"/admin/observatorio/$id",params:{id:s.id},className:"font-medium hover:text-brass",children:s.title||"(Sin título)"})}),e.jsx("td",{className:"px-4 py-3 md:px-2 lg:px-4 text-xs text-muted-foreground",children:s.category.name}),e.jsx("td",{className:"px-4 py-3 md:px-2 lg:px-4 text-xs text-muted-foreground",children:new Date(s.publishedAt).toLocaleString("es-ES")}),e.jsx("td",{className:"px-4 py-3 md:px-2 lg:px-4",children:s.isFeatured?e.jsxs("span",{className:"inline-flex items-center gap-1 border border-brass/50 px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-widest text-brass",children:[e.jsx(v,{className:"h-3 w-3"})," Destacada"]}):e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"—"})}),e.jsxs("td",{className:"px-4 py-3 md:px-2 lg:px-4 text-right space-x-1",children:[e.jsxs(o,{to:"/admin/observatorio/$id",params:{id:s.id},className:"inline-flex items-center gap-1 border border-border px-2 py-1 text-[11px] uppercase tracking-widest hover:bg-secondary",children:[e.jsx(S,{className:"h-3 w-3"})," Editar"]}),e.jsx("button",{onClick:()=>n(s),className:"inline-flex items-center gap-1 border border-bafre-red/40 px-2 py-1 text-[11px] uppercase tracking-widest text-bafre-red hover:bg-bafre-red/10",children:e.jsx(k,{className:"h-3 w-3"})})]})]},s.id))]})]})}),e.jsx(y,{open:!!r,onOpenChange:s=>{s||n(null)},title:"Eliminar noticia",description:r?e.jsxs(e.Fragment,{children:["¿Seguro que quieres eliminar “",r.title,"”? Esta acción no se puede deshacer."]}
1):null,loading:b,onConfirm:f})]})}export{$ as component};

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.