1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5791],{62030:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});var n=s(67926),r=s(13882);function a(e,t){return(0,r.Z)(1,arguments),(0,n.Z)(e,Date.now(),t)}},33527:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/questions/[slug]",function(){return s(34619)}])},97207:function(e,t,s){"use strict";var n=s(85893),r=(s(67294),s(80471));t.Z=function(e){var t=e.children,s=e.classes,a=e.isSubmitting;return(0,n.jsx)("button",{className:"".concat(s," button"),disabled:a,type:"submit",children:a?(0,n.jsx)(r.frZ,{size:"1.2em",className:"animate animate-spin mx-auto"}):t})}},10115:function(e,t,s){"use strict";var n=s(34051),r=s.n(n),a=s(85893),i=s(25675),c=s(41664),o=s(67294),u=s(40611),l=s(11510),d=s(27856),m=s.n(d),h=s(66653),f=s(74931);function p(e,t,s,n,r,a,i){try{var c=e[a](i),o=c.value}catch(u){return void s(u)}c.done?t(o):Promise.resolve(o).then(n,r)}function x(e){return function(){var t=this,s=arguments;return new Promise((function(n,r){var a=e.apply(t,s);function i(e){p(a,n,r,i,c,"next",e)}function c(e){p(a,n,r,i,c,"throw",e)}i(void 0)}))}}t.Z=function(e){var t=e.response,s=e.question,n=e.user,d=(0,o.useState)(null),p=d[0],v=d[1],b=(0,o.useState)(null),j=b[0],w=b[1],g=(0,o.useState)(t.upvotes.length||0),N=g[0],y=g[1];(0,o.useEffect)((function(){var e=m().sanitize(t.answer);w(e)}),[j]),(0,o.useEffect)((function(){function e(){return(e=x(r().mark((function e(){var s;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,u.Z.get("/api/users/".concat(t.user));case 3:s=e.sent.data,v(s),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.log(e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[null===p||void 0===p?void 0:p.id]),(0,o.useEffect)((function(){}),[N]);var _=function(){var e=x(r().mark((function e(){var a;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,u.Z.post("/api/questions/".concat(s.id,"/responses/").concat(t._id,"/upvote"));case 3:a=e.sent.data,y(a.upvotes.length),a.upvotes.filter((function(e){return n.id===e.user})).length>0?f.ZP.success("Upvoted"):f.ZP.success("Upvote removed"),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(0),console.log(e.t0),f.ZP.error("Upvote Error: Please try again");case 13:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(){return e.apply(this,arguments)}}();return(0,a.jsxs)("div",{className:"p-6",children:[p&&(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(i.default,{src:p.avatar||"/images/avatar.png",alt:p.fullname,width:36,height:36,className:"object-cover rounded-full"}),(0,a.jsxs)("div",{className:"ml-3",children:[(0,a.jsx)("h4",{className:"flex items-end",children:(0,a.jsx)(c.default,{href:"/".concat(p.username),children:(0,a.jsx)("a",{target:"_blank",className:"text-slate-800 font-bold",children:p.fullName})})}),(0,a.jsxs)("span",{className:"block text-sm text-slate-500",children:["Answered ",(0,l.Z)(new Date(t.createdAt),"PPP")]})]})]}),(0,a.jsx)("div",{className:"mt-4 whitespace-pre-line",dangerouslySetInnerHTML:{__html:j}}),(0,a.jsx)("div",{className:"mt-6",children:(0,a.jsxs)("button",{onClick:_,type:"button",className:"flex rounded-full py-1 px-3 items-center space-x-3 border border-slate-200 text-sm text-slate-800 bg-slate-100 hover:bg-slate-200",children:[(0,a.jsx)(h.KhA,{size:"1.2em",className:"mr-1"})," ",N," Upvote"]})}),(0,a.jsx)("span",{className:"text-xs text-slate-400 block mt-3 italic",children:"DISCLAIMER: This response is not legal advice. To obtain legal advice please consult a lawyer"})]})}},43977:function(e,t,s){"use strict";var n=s(85893);s(67294);t.Z=function(e){var t=e.children;return(0,n.jsx)("div",{className:"text-sm text-red-500 my-1",children:t})}},34619:function(e,t,s){"use strict";s.r(t),s.d(t,{__N_SSP:function(){return E},default:function(){return A}});var n=s(85893),r=s(11163),a=s(67294),i=s(41664),c=s(80575),o=s(40611),u=s(62030),l=s(63750),d=s(34051),m=s.n(d),h=s(82175),f=(s(88133),s(97207)),p=s(43977),x=s(74231),v=s(74931);function b(e,t,s,n,r,a,i){try{var c=e[a](i),o=c.value}catch(u){return void s(u)}c.done?t(o):Promise.resolve(o).then(n,r)}function j(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function w(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},n=Object.keys(s);"function"===typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter((function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}
1)))),n.forEach((function(t){j(e,t,s[t])}))}return e}var g=x.Ry().shape({answer:x.Z_().min(20,"Minimum of 20 characters").max(2e3,"Maximum of 2000 characters").required("Answer is required")});var N=function(e){var t=e.question,s=e.setQuestion;return(0,n.jsx)("div",{children:(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(h.J9,{initialValues:{answer:""},validationSchema:g,onSubmit:function(){var e,n=(e=m().mark((function e(n,r){var a,i,c;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=r.resetForm,e.prev=1,e.next=4,o.Z.post("/api/questions/".concat(t.id,"/responses"),n);case 4:i=e.sent.data,(c=w({},t)).responses.push(i),s(c),v.ZP.success("Answer submitted successfully"),a(),e.next=16;break;case 12:e.prev=12,e.t0=e.catch(1),console.log(e.t0),v.ZP.error("Error submitting answer, please try again");case 16:case"end":return e.stop()}}),e,null,[[1,12]])})),function(){var t=this,s=arguments;return new Promise((function(n,r){var a=e.apply(t,s);function i(e){b(a,n,r,i,c,"next",e)}function c(e){b(a,n,r,i,c,"throw",e)}i(void 0)}))});return function(e,t){return n.apply(this,arguments)}}(),children:function(e){var t=e.errors,s=e.touched,r=e.isSubmitting;return(0,n.jsxs)(h.l0,{children:[(0,n.jsx)("h4",{className:"font-bold",children:"Have an answer to this question?"}),(0,n.jsx)("p",{className:"text-slate-600 text-sm",children:"Please submit it below"}),(0,n.jsxs)("div",{className:"field",children:[(0,n.jsx)(h.gN,{as:"textarea",name:"answer",rows:4,className:"".concat(t.answer&&s.answer?"has-error":""," input"),placeholder:"Start typing your answer ...."}),(0,n.jsx)(h.Bc,{name:"answer",component:p.Z})]}),(0,n.jsx)("div",{className:"field",children:(0,n.jsx)(f.Z,{type:"submit",classes:"primary",isSubmitting:r,children:"Submit answer"})})]})}})})})},y=s(10115),_=s(2282),Z=s(27856),P=s.n(Z),S=s(86492),k=s.n(S),q=s(89583),E=!0;function A(e){var t=e.q,s=(0,a.useState)(t),o=s[0],d=s[1],m=(0,a.useState)([]),h=m[0],f=(m[1],(0,_.a)()),p=f.user,x=f.loading;(0,r.useRouter)();return(0,n.jsxs)(c.Z,{children:[(0,n.jsx)(i.default,{href:"/dashboard/questions",children:(0,n.jsxs)("a",{className:"flex items-center font-bold",children:[(0,n.jsx)(l.And,{className:"mr-2"})," Questions"]})}),!x&&p&&(null===o||void 0===o?void 0:o.id)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"bg-white relative border border-slate-300 md:p-8 p-6 rounded-md mt-4",children:[(0,n.jsxs)("h4",{className:"mb-2",children:[(0,n.jsx)("strong",{className:"text-3xl",children:o.name?o.name:"Anonymous"})," ",(0,n.jsxs)("i",{className:"text-slate-600 text-sm",children:["asked"," ",(0,u.Z)(new Date(o.createdAt),{addSuffix:!0})]})]}),(0,n.jsx)("p",{dangerouslySetInnerHTML:{__html:P().sanitize(k().decode(o.question))},className:"font-medium text-lg"}),(0,n.jsx)("div",{className:"absolute right-4 top-4 md:text-3xl opacity-20",children:(0,n.jsx)(q.MXt,{})})]}),o.responses.length>0?(0,n.jsxs)("div",{className:"mt-6",children:[(0,n.jsxs)("h4",{className:"font-medium mb-3 md:text-3xl",children:[o.responses.length," Answer",h.length>1?"s":""]}),(0,n.jsx)("div",{className:"bg-white rounded-md divide-y divide-slate-300 border border-slate-300",children:o.responses.map((function(e){return(0,n.jsx)(y.Z,{response:e,question:o,user:p},e._id)}))})]}):(0,n.jsx)("div",{className:"bg-white border border-slate-200 p-6 rounded-md mt-6 text-red-600",children:"There are no responses to this question, be the first to submit an answer"}),(0,n.jsx)("div",{className:"bg-white border border-slate-300 p-6 rounded-md mt-4",children:(0,n.jsx)(N,{question:o,setQuestion:d})})]}):(0,n.jsx)("div",{className:"bg-white border border-slate-200 p-6 rounded-md mt-8",children:"Question not found"})]})}}},function(e){e.O(0,[5445,2013,9866,955,3874,4617,3276,2175,6653,4231,1510,7856,6492,7926,575,9774,2888,179],(function(){return t=33527,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.