1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3230],{64730:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/admin/community",function(){return t(81507)}])},93987:function(e,n,t){"use strict";var i=t(85893),r=(t(67294),t(80471));n.Z=function(e){var n=e.children,t=e.classes,s=e.type,c=e.isSubmitting;return(0,i.jsx)("button",{className:"".concat(t," button"),disabled:c,type:s||"button",children:c?(0,i.jsx)(r.frZ,{size:"1.2em",className:"animate animate-spin mx-auto"}):n})}},43977:function(e,n,t){"use strict";var i=t(85893);t(67294);n.Z=function(e){var n=e.children;return(0,i.jsx)("div",{className:"text-sm text-red-500 my-1",children:n})}},88362:function(e,n,t){"use strict";var i=t(85893),r=(t(67294),t(80471));n.Z=function(){return(0,i.jsx)("div",{className:"py-8 px-4 border border-slate-300 rounded-lg bg-white",children:(0,i.jsx)(r.frZ,{size:"1.5em",className:"animate animate-spin mx-auto"})})}},81507:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return k}});var i=t(85893),r=t(67294),s=t(80575),c=t(88767),a=t(40611),o=t(88362),u=t(34051),d=t.n(u),l=t(82175),m=t(74231),f=t(43977),h=t(93987),x=t(74931);function p(e,n,t,i,r,s,c){try{var a=e[s](c),o=a.value}catch(u){return void t(u)}a.done?n(o):Promise.resolve(o).then(i,r)}function v(e){return function(){var n=this,t=arguments;return new Promise((function(i,r){var s=e.apply(n,t);function c(e){p(s,i,r,c,a,"next",e)}function a(e){p(s,i,r,c,a,"throw",e)}c(void 0)}))}}var j=m.Ry().shape({title:m.Z_().required("Title is required").max(64),description:m.Z_().required("Description is required").max(512)});var b=function(e){var n=e.communityId,t=void 0===n?null:n,r=e.setShowForm,s=void 0===r?null:r,o=(0,c.useQueryClient)(),u=(0,c.useMutation)({mutationFn:function(){var e=v(d().mark((function e(n){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.Z.post("/api/cms/communities",n).then((function(e){return e.data})).catch((function(e){console.log(e)}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),onSuccess:function(e){x.ZP.success("Community created successfully"),s(!1)},onSettled:function(){o.invalidateQueries("admin.communities")}});return(0,i.jsxs)("div",{className:"p-8 bg-white border border-slate-200 rounded-lg drop-shadow-sm",children:[(0,i.jsx)("h4",{className:"title text-2xl font-black",children:t?"Update Community":"Add Community"}),(0,i.jsx)("hr",{className:"mb-4"}),(0,i.jsx)(l.J9,{initialValues:{title:"",description:""},validationSchema:j,onSubmit:function(){var e=v(d().mark((function e(n){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.mutateAsync(n);case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),children:function(e){var n=e.errors,r=e.touched,s=e.isSubmitting;return(0,i.jsxs)(l.l0,{children:[(0,i.jsxs)("div",{className:"field",children:[(0,i.jsx)("label",{children:"Community Title"}),(0,i.jsx)(l.gN,{name:"title",placeholder:"eg. Real estate and law",className:"".concat(n.title&&r.title?"has-error":""," input")}),(0,i.jsx)(l.Bc,{name:"title",component:f.Z})]}),(0,i.jsxs)("div",{className:"field",children:[(0,i.jsx)("label",{children:"Description"}),(0,i.jsx)(l.gN,{name:"description",as:"textarea",placeholder:"Write a brief description about this community",className:"".concat(n.description&&r.description?"has-error":""," input")}),(0,i.jsx)(l.Bc,{name:"description",component:f.Z})]}),(0,i.jsx)("div",{className:"field",children:(0,i.jsx)(h.Z,{type:"submit",classes:"primary",isSubmitting:s,children:t?"Update":"Create"})})]})}})]})},y=t(80471),N=t(89583),w=t(41664);function g(e,n,t,i,r,s,c){try{var a=e[s](c),o=a.value}catch(u){return void t(u)}a.done?n(o):Promise.resolve(o).then(i,r)}var Z=function(e){var n=e.community,t=(0,c.useQuery)("community.".concat(n.id),(function(){return a.Z.get("/api/cms/communities/".concat(n.id,"/topics/count")).then((function(e){return e.data})).catch((function(e){console.log(e)}))})),r=t.data,s=t.isLoading,o=(0,c.useMutation)({mutationFn:function(){return a.Z.delete("/api/cms/communities/".concat(n.id))},onSuccess:function(){x.ZP.success("Deleted successfully")}}),u=function(){var e,n=(e=d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!window.confirm("Are you sure you want to delete this item? This action cannot be undone")){e.next=3;break}return e.next=3,o.mutateAsync();case 3:case"end":return e.stop()}}),e)})),function(){var n=this,t=arguments;return new Promise((function(i,r){var s=e.apply(n,t);function c(e){g(s,i,r,c,a,"next",e)}function a(e){g(s,i,r,c,a,"throw",e)}c(void 0)}))});return function(){return n.apply(this,arguments)}}();return(0,i.jsxs)("div",{className:"p-4 bg-white flex items-center justify-between",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h4",{className:"font-bold",children:(0,i.jsx)(w.default,{href:"/dashboard/forum/".concat(n.id),children:(0,i.jsx)("a",{children:n.title})})}),s?(0,i.jsx)(y.frZ,{className:"animate-spin"}):(0,i.jsx)("div",{className:"text-sm",children:r&&(0,i.jsxs)("span",{children:[r.count," Topic",r.count>1?"s":""]})})]}),(0,i.jsx)("div",{className:"flex items-center space-x-3",children:(0,i.jsx)("button",{onClick:u,children:(0,i.jsx)(N.AMf,{})})})]})};var _=function(){var e=(0,r.useState)(!1),n=e[0],t=e[1],s=(0,c.useQuery)("admin.communities",(function(){return a.Z.get("/api/cms/communities").then((function(e){return e.data}
1)).catch((function(e){console.log(e)}))})),u=s.data;return s.isLoading?(0,i.jsx)(o.Z,{}):(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"mb-6",children:[(0,i.jsx)("button",{type:"button",className:"button",onClick:function(){return t(!n)},children:"Add Community"}),n&&(0,i.jsx)("div",{className:"mt-8",children:(0,i.jsx)(b,{setShowForm:t})})]}),u&&u.length>0?(0,i.jsx)("div",{className:"divide-y divide-slate-200 border border-slate-200 rounded-lg overflow-hidden",children:u.map((function(e){return(0,i.jsx)(Z,{community:e},e.id)}))}):(0,i.jsx)("div",{className:"p-6 rounded-xl bg-white text-red-600 font-bold border border-red-200",children:"No communities yet, click add community to create one"})]})};var k=function(){return(0,i.jsx)(s.Z,{title:"Community",isAdmin:!0,children:(0,i.jsx)("div",{children:(0,i.jsx)(_,{})})})}}},function(e){e.O(0,[5445,2013,9866,955,3874,4617,3276,2175,6653,4231,575,9774,2888,179],(function(){return n=64730,e(e.s=n);var n}));var n=e.O();_N_E=n}]);
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.