1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[38633],{22737:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>x});var s=l(37876),a=l(48230),n=l.n(a),r=l(20620),c=l(45594),i=l(44454),o=l(44929),d=l(91911),u=l.n(d);function h(){let{user:e}=(0,r.z8)(),t=(0,c.A)("posts"),{toasts:l,push:a}=(0,o.Yf)(),d=(0,r.$3)(e,"write"),h=async e=>{if(window.confirm('Delete "'.concat(e.title||e.slug,'"? This cannot be undone.')))try{await (0,i.Al)("/posts/".concat(e._id)),a("Post deleted."),t.reload()}catch(e){a(e.message,"error")}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Pf,{error:t.error}),(0,s.jsxs)(o.Zp,{flush:!0,children:[(0,s.jsxs)("div",{className:u().toolbar,children:[(0,s.jsx)("div",{className:u().searchField,children:(0,s.jsx)(o.A_,{label:"Search",value:t.q,onChange:t.setQ,placeholder:"Title, slug or categoryâ¦"})}),(0,s.jsx)(o.zM,{className:u().filterField,label:"Status",value:t.status,onChange:t.setStatus,options:[{value:"",label:"All"},{value:"published",label:"Published"},{value:"draft",label:"Draft"}]})]}),(0,s.jsx)("div",{className:u().tableWrap,children:(0,s.jsxs)("table",{className:u().table,children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{scope:"col",children:"Title"}),(0,s.jsx)("th",{scope:"col",children:"Status"}),(0,s.jsx)("th",{scope:"col",children:"Category"}),(0,s.jsx)("th",{scope:"col",children:"Author"}),(0,s.jsx)("th",{scope:"col",children:"Published"}),(0,s.jsx)("th",{scope:"col",style:{textAlign:"right"},children:"Actions"})]})}),(0,s.jsx)("tbody",{children:t.loading?(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:6,className:u().loading,children:"Loadingâ¦"})}):0===t.items.length?(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:6,className:u().empty,children:"No posts match."})}):t.items.map(e=>(0,s.jsxs)("tr",{children:[(0,s.jsxs)("td",{children:[(0,s.jsx)(n(),{href:"/admin/posts/".concat(e._id),className:u().cellTitle,children:e.title||"(untitled)"}),(0,s.jsxs)("span",{className:u().cellSub,children:["/blog/",e.slug]})]}),(0,s.jsx)("td",{children:(0,s.jsx)(o.Wh,{status:e.status})}),(0,s.jsx)("td",{children:e.category||"â"}),(0,s.jsx)("td",{children:e.author||"â"}),(0,s.jsx)("td",{className:u().numeric,children:function(e){if(!e)return"â";let t=new Date(e);return Number.isNaN(t.getTime())?"â":t.toLocaleDateString("en-GB",{dateStyle:"medium"})}(e.publishedAt)}),(0,s.jsx)("td",{children:(0,s.jsxs)("div",{className:u().rowActions,children:[(0,s.jsx)(n(),{href:"/admin/posts/".concat(e._id),className:"".concat(u().btn," ").concat(u().btnSmall),children:"Edit"}),d?(0,s.jsx)("button",{type:"button",className:"".concat(u().btn," ").concat(u().btnSmall," ").concat(u().btnDanger),onClick:()=>h(e),children:"Delete"}):null]})})]},e._id))})]})}),(0,s.jsx)(o.is,{page:t.page,limit:t.limit,total:t.total,onPage:t.setPage})]}),(0,s.jsx)(o.VA,{toasts:l})]})}function x(){return(0,s.jsx)(r.Ay,{title:"Blog posts",subtitle:"Articles served under /blog",actions:(0,s.jsx)(n(),{href:"/admin/posts/new",className:"".concat(u().btn," ").concat(u().btnPrimary),children:"New post"}),children:(0,s.jsx)(h,{})})}},45594:(e,t,l)=>{"use strict";l.d(t,{A:()=>r});var s=l(14232),a=l(44454),n=l(44929);function r(e){let{limit:t=20,extraParams:l={}}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},[r,c]=(0,s.useState)(""),[i,o]=(0,s.useState)(""),[d,u]=(0,s.useState)(1),[h,x]=(0,s.useState)({loading:!0,items:[],total:0,error:null}),j=(0,n.lW)(r),m=(0,s.useRef)(null),b=JSON.stringify(l);(0,s.useEffect)(()=>{u(1)},[j,i,b]);let g=(0,s.useCallback)(async()=>{var l,s;null==(l=m.current)||l.abort();let n=new AbortController;m.current=n,x(e=>({...e,loading:!0}));try{let l=await (0,a.FH)("/".concat(e).concat((0,a.ND)({page:d,limit:t,q:j,status:i,...JSON.parse(b)})),{signal:n.signal}),r=Array.isArray(l.data)?l.data:[];x({loading:!1,items:r,total:null!=(s=l.total)?s:r.length,error:null})}catch(e){if((null==e?void 0:e.name)==="AbortError")return;x({loading:!1,items:[],total:0,error:e})}},[e,d,t,j,i,b]);return(0,s.useEffect)(()=>(g(),()=>{var e;return null==(e=m.current)?void 0:e.abort()}),[g]),{q:r,setQ:c,status:i,setStatus:o,page:d,setPage:u,limit:t,...h,reload:g}}},98985:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/posts",function(){return l(22737)}])}},e=>{e.O(0,[9396,90636,46593,38792],()=>e(e.s=98985)),_N_E=e.O()}]);
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.