1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3175],{63883:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/articles",function(){return r(31596)}])},38171:function(e,t,r){"use strict";var n=r(34051),a=r.n(n),s=r(85893),i=r(11510),c=r(25675),l=r(41664),o=(r(67294),r(40611)),u=r(88767),d=r(80471),h=r(89583),x=r(74931);function f(e,t,r,n,a,s,i){try{var c=e[s](i),l=c.value}catch(o){return void r(o)}c.done?t(l):Promise.resolve(l).then(n,a)}function m(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function i(e){f(s,n,a,i,c,"next",e)}function c(e){f(s,n,a,i,c,"throw",e)}i(void 0)}))}}t.Z=function(e){var t,r=e.article,n=e.user,f=void 0===n?null:n,v=(0,u.useQuery)("user.".concat(r.author),m(a().mark((function e(){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.Z.get("/api/users/".concat(r.author)).then((function(e){return e.data})).catch((function(e){return console.log(e)}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))),p=v.data,b=v.isLoading,j=(0,u.useMutation)({mutationFn:m(a().mark((function e(){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.Z.delete("/api/cms/articles/".concat(r.slug));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),onSuccess:function(){x.ZP.success("Article deleted successfully")}}),g=function(){var e=m(a().mark((function e(){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!window.confirm("Are you sure you want to delete this article? This action cannot be undone")){e.next=3;break}return e.next=3,j.mutateAsync();case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return(0,s.jsxs)("div",{className:"relative pb-16 border border-slate-300 rounded-lg bg-white hover:drop-shadow-lg md:mb-0 mb-4",children:[(0,s.jsxs)("div",{className:"md:p-4 p-4",children:[(0,s.jsx)("p",{className:"text-slate-500 mb-1",children:(0,i.Z)(new Date(r.createdAt),"PPP")}),(0,s.jsx)(l.default,{href:"/articles/".concat(r.slug),children:(0,s.jsxs)("a",{className:"hover:no-underline",target:"_blank",rel:"noreferrer",children:[(0,s.jsx)("h2",{className:"font-bold text-2xl mb-2 text-slate-800",children:r.title}),(0,s.jsx)("p",{dangerouslySetInnerHTML:{__html:(t=r.description,t?t.replace(/(<([^>]+)>)/gi,"").slice(0,128)+"...":"")},className:"text-slate-600"})]})})]}),b?(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0 border-t border-slate-300 px-4 py-2",children:(0,s.jsx)(d.frZ,{className:"animate-spin"})}):(0,s.jsx)(s.Fragment,{children:p&&(0,s.jsxs)("div",{className:"absolute flex justify-between items-center bottom-0 left-0 right-0 border-t border-slate-300 px-4 py-2",children:[(0,s.jsx)("div",{children:(0,s.jsx)(l.default,{href:"/".concat(p.username),children:(0,s.jsxs)("a",{target:"_blank",className:"inline-flex items-center space-x-2 text-slate-800",rel:"noreferrer",children:[(0,s.jsx)("span",{className:" top-1 relative",children:(0,s.jsx)(c.default,{src:p.avatar||"/images/avatar.png",alt:p.fullName,width:30,height:30,className:"object-cover rounded-full"})}),(0,s.jsx)("span",{children:p.fullName})]})})}),f&&"admin"===f.role?(0,s.jsx)("div",{children:(0,s.jsx)("button",{onClick:g,className:"text-red-600 hover:text-red-500",children:(0,s.jsx)(h.AMf,{})})}):null]})})]})}},24205:function(e,t,r){"use strict";var n=r(34051),a=r.n(n),s=r(85893),i=(r(41664),r(67294),r(40611)),c=r(38171),l=r(88362),o=r(88767),u=r(80471);function d(e,t,r,n,a,s,i){try{var c=e[s](i),l=c.value}catch(o){return void r(o)}c.done?t(l):Promise.resolve(l).then(n,a)}t.Z=function(e){e.title;var t=e.query,r=e.user,n=void 0===r?null:r,h=(0,o.useInfiniteQuery)("articles",{queryFn:function(){var e,r=(e=a().mark((function e(r){var n,s;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.pageParam,s=void 0===n?1:n,e.next=3,i.Z.get("/api/cms/articles/",{params:{limit:12,page:s,search:t||null}}).then((function(e){return e.data})).catch((function(e){console.log(e)}));case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e)})),function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function i(e){d(s,n,a,i,c,"next",e)}function c(e){d(s,n,a,i,c,"throw",e)}i(void 0)}))});return function(e){return r.apply(this,arguments)}}(),getNextPageParam:function(e,t){var r;return(null===e||void 0===e||null===(r=e.next)||void 0===r?void 0:r.page)||void 0}}),x=h.data,f=h.isLoading,m=h.hasNextPage,v=h.isFetchingNextPage,p=h.fetchNextPage;return f?(0,s.jsx)(l.Z,{}):(0,s.jsxs)("div",{children:[t&&(0,s.jsxs)("h1",{className:"mb-4 text-xl",children:["Search results for: ",t]}),x&&x.pages.length>0?(0,s.jsxs)("div",{children:[x.pages.map((function(e,t){return(0,s.jsx)("div",{className:"md:grid grid-cols-3 gap-8 mb-8",children:e.data.map((function(e){return(0,s.jsx)(c.Z,{article:e,user:n},e.id)}))},"page_".concat(t))})),m?(0,s.jsx)("button",{onClick:p,disabled:v,className:"button primary",children:v?(0,s.jsxs)("span",{className:"flex items-center space-x-2",children:[(0,s.jsx)("span",{children:"Loading "}),(0,s.jsx)(u.frZ,{className:"animate-spin relative top-0.5"})]}):(0,s.jsx)("span",{children:"Load more"})}):null]}):(0,s.jsx)("div",{children:t?(0,s.jsx)("div",{className:"p-4 rounded-md text-red-600 border border-red-200",children:"We couldn't find any article that matched your search query, please try a different search term"}):null})]})}},88362:function(e,t,r){"use strict";var n=r(85893),a=(r(67294),r(80471));t.Z=function(){return(0,n.jsx)("div",{className:"py-8 px-4 border border-slate-300 rounded-lg bg-white",children:(0,n.jsx)(a.frZ,{size:"1.5em",className:"animate animate-spin mx-auto"})})}},31596:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return v}});var n=r(85893),a=r(80575),s=r(34051),i=r.n(s),c=r(41664),l=r(67294),o=r(40611),u=r(11510);function d(e,t,r,n,a,s,i){try{var c=e[s](i),l=c.value}catch(o){return void r(o)}c.done?t(l):Promise.resolve(l).then(n,a)}var h=function(){var e,t=(0,l.useState)(null),r=t[0],a=t[1],s=(0,l.useState)(!0),h=s[0],x=s[1];(0,l.useEffect)((function(){o.Z.get("/api/cms/articles/me").then((function(e){a(e.data)})).catch((function(e){return console.log(e)})).then((function(){x(!1)}))}),[h]);var f=function(){var e,t=(e=i().mark((function e(t){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!window.confirm("Are you sure you want to delete this article? This action cannot be undone")){e.next=13;break}return e.prev=1,e.next=4,o.Z.delete("/api/cms/articles/".concat(t.slug));case 4:e.sent.data,(n=Array.from(r)).slice(n.indexOf(t),1),a(n),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),console.log(e.t0);case 13:case"end":return e.stop()}}),e,null,[[1,10]])})),function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function i(e){d(s,n,a,i,c,"next",e)}function c(e){d(s,n,a,i,c,"throw",e)}i(void 0)}))});return function(e){return t.apply(this,arguments)}}();return(0,n.jsx)("div",{children:h?null:(0,n.jsx)(n.Fragment,{children:(null===r||void 0===r||null===(e=r.data)||void 0===e?void 0:e.length)>0?(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"font-bold mb-3",children:"Your article"}),(0,n.jsx)("div",{className:"divide-y divide-slate-300 bg-white border border-slate-300 rounded-md overflow-hidden",children:r.data.map((function(e){return(0,n.jsx)("div",{className:"p-5 py-3 flex justify-between hover:bg-slate-50",children:(0,n.jsx)("div",{children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h4",{className:"font-bold",children:(0,n.jsx)(c.default,{href:"/articles/".concat(e.slug),children:(0,n.jsx)("a",{className:"text-slate-700 hover:text-slate-700 text-lg",children:e.title})})}),(0,n.jsxs)("ul",{className:"flex items-center space-x-4 text-sm mt-1",children:[(0,n.jsx)("li",{children:(0,u.Z)(new Date(e.createdAt),"PPP")}),(0,n.jsx)("li",{children:(0,n.jsx)(c.default,{href:"/dashboard/articles/".concat(e.slug,"/edit"),children:(0,n.jsx)("a",{children:"Edit article"})})}),(0,n.jsx)("li",{children:(0,n.jsx)("button",{type:"button",className:"text-red-600",onClick:function(){return f(e)},children:"Delete article"})})]})]})})},e.id)}))})]}):(0,n.jsxs)("div",{className:"text-center bg-white border border-slate-300 md:p-8 p-4 rounded-md",children:[(0,n.jsx)("h2",{className:"md:text-4xl text-2xl font-bold text-red-600 mb-2",children:"No articles found"}),(0,n.jsx)("p",{children:"You have not written any articles, click below to get started"}),(0,n.jsx)(c.default,{href:"/dashboard/articles/new",children:(0,n.jsx)("a",{className:"inline-block py-2 px-6 rounded-md border border-blue-300 text-blue-500 hover:border-blue-800 hover:no-underline hover:text-blue-900 drop-shadow-md bg-white",children:"Write an article"})})]})})})}
1,x=r(24205),f=r(88362),m=r(2282);function v(){var e=(0,m.a)(),t=e.user;return e.loading?(0,n.jsx)(f.Z,{}):(0,n.jsxs)(a.Z,{title:"Articles",action:"/dashboard/articles/new",actionTitle:"New article",children:[(0,n.jsx)(h,{user:t||null}),(0,n.jsx)("br",{}),(0,n.jsx)("br",{}),(0,n.jsx)(x.Z,{user:t||null})]})}}},function(e){e.O(0,[5445,2013,9866,955,3874,4617,3276,6653,1510,575,9774,2888,179],(function(){return t=63883,e(e.s=t);var t}));var t=e.O();_N_E=t}]);
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.