1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7394],{98214:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/blog",function(){return a(85407)}])},85407:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return AdminBlogPage}});var r=a(24246),s=a(27378),n=a(86677),d=a(73977),l=a(14819);function AdminBlogPage(){let{auth:e}=(0,d.XL)(),t=(0,n.useRouter)(),[a,i]=(0,s.useState)([]),[o,c]=(0,s.useState)(!0),[x,g]=(0,s.useState)(!1),[h,p]=(0,s.useState)(null),[u,m]=(0,s.useState)(1),[y,b]=(0,s.useState)(1),[k,f]=(0,s.useState)(null),loadPosts=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{var r;a?g(!0):c(!0);let s=await (null==e?void 0:null===(r=e.currentUser)||void 0===r?void 0:r.getIdToken()),n=await fetch("/api/admin/blog?page=".concat(t,"&limit=50"),{headers:{Authorization:"Bearer ".concat(s)}});if(!n.ok)throw Error("Failed to load posts");let d=await n.json();a?i(e=>[...e,...d.posts]):i(d.posts),m(d.pagination.page),b(d.pagination.totalPages)}catch(e){p(e instanceof Error?e.message:"Unknown error")}finally{c(!1),g(!1)}};(0,s.useEffect)(()=>{if((null==e?void 0:e.currentUser)&&loadPosts(),!e)return;let t=e.onAuthStateChanged(e=>{e&&loadPosts()});return()=>t()},[e]);let handleDelete=async t=>{let a=window.confirm('Are you sure you want to delete "'.concat(t.title,'"?\n\nThis action cannot be undone.'));if(a)try{var r;f(t.pk);let a=await (null==e?void 0:null===(r=e.currentUser)||void 0===r?void 0:r.getIdToken()),s=await fetch("/api/admin/blog/".concat(t.pk),{method:"DELETE",headers:{Authorization:"Bearer ".concat(a)}});if(!s.ok)throw Error("Failed to delete post");i(e=>e.filter(e=>e.pk!==t.pk))}catch(e){p(e instanceof Error?e.message:"Unknown error")}finally{f(null)}};return(0,r.jsx)(l.B,{title:"Blog",children:(0,r.jsxs)("div",{className:"p-6 lg:p-8",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,r.jsx)("p",{className:"text-gray-600 dark:text-gray-400",children:"Manage blog posts and announcements"}),(0,r.jsx)("button",{onClick:()=>t.push("/admin/blog/new"),className:"px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition-colors",children:"New Post"})]}),h&&(0,r.jsx)("div",{className:"mb-4 p-4 bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 rounded-md",children:h}),o?(0,r.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-8 text-center",children:[(0,r.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"}),(0,r.jsx)("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading posts..."})]}):(0,r.jsx)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:(0,r.jsxs)("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[(0,r.jsx)("thead",{className:"bg-gray-50 dark:bg-gray-900",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Title"}),(0,r.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Slug"}),(0,r.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Publish Time"}),(0,r.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Status"}),(0,r.jsx)("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Shared"}),(0,r.jsx)("th",{scope:"col",className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Actions"})]})}),(0,r.jsx)("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:0===a.length?(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,className:"px-6 py-4 text-center text-sm text-gray-500 dark:text-gray-400",children:"No blog posts yet. Create your first post!"})}):a.map(e=>(0,r.jsxs)("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[(0,r.jsx)("td",{className:"px-6 py-4 text-sm font-medium",children:(0,r.jsxs)("a",{href:"/blog/".concat(e.slug).concat(e.is_draft||!e.is_published?"?preview=true":""),target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 hover:underline",children:[e.emoji&&(0,r.jsx)("span",{className:"mr-2",children:e.emoji}),e.title]})}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.slug}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:new Date(e.publish_time).toLocaleStr
1ing()}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,r.jsx)("span",{className:"px-2 inline-flex text-xs leading-5 font-semibold rounded-full ".concat(!e.is_draft&&e.is_published?"bg-green-100 text-green-800 dark:bg-green-900/50 dark:text-green-300":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/50 dark:text-yellow-300"),children:!e.is_draft&&e.is_published?"Published":"Draft"})}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.shared_on_social?"Yes":"No"}),(0,r.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{onClick:()=>t.push("/admin/blog/".concat(e.pk)),className:"text-green-600 hover:text-green-800 dark:text-green-400 dark:hover:text-green-300 hover:underline",children:"Edit"}),(0,r.jsx)("button",{onClick:()=>handleDelete(e),disabled:k===e.pk,className:"text-red-600 hover:text-red-800 dark:text-red-400 dark:hover:text-red-300 hover:underline disabled:opacity-50 disabled:cursor-not-allowed",children:k===e.pk?"Deleting...":"Delete"})]})})]},e.pk))})]})}),u<y&&(0,r.jsx)("div",{className:"mt-4 text-center",children:(0,r.jsx)("button",{onClick:()=>{u<y&&loadPosts(u+1,!0)},disabled:x,className:"px-6 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 disabled:bg-gray-400 disabled:cursor-not-allowed transition-colors",children:x?"Loading...":"Load More (Page ".concat(u," of ").concat(y,")")})}),a.length>0&&(0,r.jsxs)("div",{className:"mt-2 text-center text-sm text-gray-500 dark:text-gray-400",children:["Showing ",a.length," posts"]})]})})}}},function(e){e.O(0,[9894,9253,4819,9774,2888,179],function(){return e(e.s=98214)}),_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.