text: (this["webpackJsonpmern-stack-client"]=this["webpackJsonpmern-stack-client"]||[]).push([[0],{106:function(e,t,a){e.exports=a(143)},141:function(e,t,a){},142:function(e,t,a){},143:function(e,t,a){"use strict";a.r(t);var n=a(0),r=a.n(n),l=a(8),c=a.n(l),o=a(18),i=a(30),s=a(80),u=a(96),m=a(11),p=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{authData:null},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"AUTH":return localStorage.setItem("profile",JSON.stringify(Object(m.a)({},null===t||void 0===t?void 0:t.data))),Object(m.a)(Object(m.a)({},e),{},{authData:t.data,loading:!1,errors:null});case"LOGOUT":return localStorage.clear(),Object(m.a)(Object(m.a)({},e),{},{authData:null,loading:!1,errors:null});default:return e}},d=Object(i.c)({posts:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"FETCH_ALL":return t.payload;case"LIKE":return e.map((function(e){return e._id===t.payload._id?t.payload:e}));case"CREATE":return[].concat(Object(u.a)(e),[t.payload]);case"UPDATE":return e.map((function(e){return e._id===t.payload._id?t.payload:e}));case"DELETE":return e.filter((function(e){return e._id!==t.payload}));default:return e}},auth:p}),f=a(185),g=a(28),v=a(12),h=a(26),b=a(191),E=a(184),y=a(14),x=a.n(y),j=a(23),O=a(81),w=a.n(O).a.create({baseURL:"https://klez-sap.herokuapp.com"});w.interceptors.request.use((function(e){return localStorage.getItem("profile")&&(e.headers.Authorization="Bearer ".concat(JSON.parse(localStorage.getItem("profile")).token)),e}));var N=function(e){return w.patch("/posts/".concat(e,"/likePost"))},k=function(e,t){return w.patch("/posts/".concat(e),t)},C=function(e){return w.delete("/posts/".concat(e))},S=function(e){return w.post("/user/signin",e)},I=function(e){return w.post("/user/signup",e)},A=function(e){return function(){var t=Object(j.a)(x.a.mark((function t(a){var n,r;return x.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,l=e,w.post("/posts",l);case 3:n=t.sent,r=n.data,a({type:"CREATE",payload:r}),t.next=11;break;case 8:t.prev=8,t.t0=t.catch(0),console.log(t.t0);case 11:case"end":return t.stop()}var l}),t,null,[[0,8]])})));return function(e){return t.apply(this,arguments)}}()},D=function(e,t){return function(){var a=Object(j.a)(x.a.mark((function a(n){var r,l;return x.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,k(e,t);case 3:r=a.sent,l=r.data,n({type:"UPDATE",payload:l}),a.next=11;break;case 8:a.prev=8,a.t0=a.catch(0),console.log(a.t0);case 11:case"end":return a.stop()}}),a,null,[[0,8]])})));return function(e){return a.apply(this,arguments)}}()},T=a(183),F=a(177),_=a(178),z=a(145),L=a(179),P=a(180),B=a(181),U=a(87),W=a.n(U),J=a(89),H=a.n(J),M=a(88),R=a.n(M),q=a(62),G=a.n(q),K=a(82),Q=a.n(K),V=a(173),Y=Object(V.a)({media:{height:0,paddingTop:"56.25%",backgroundColor:"rgba(0, 0, 0, 0.5)",backgroundBlendMode:"darken"},border:{border:"solid"},fullHeightCard:{height:"100%"},card:{display:"flex",flexDirection:"column",justifyContent:"space-between",height:"100%",position:"relative"},overlay:{position:"absolute",top:"20px",left:"20px",color:"white"},overlay2:{position:"absolute",top:"20px",right:"20px",color:"white"},grid:{display:"flex"},details:{display:"flex",justifyContent:"space-between",margin:"20px"},title:{padding:"0 16px"},cardActions:{padding:"0 16px 8px 16px",display:"flex",justifyContent:"space-between"}}),X=function(e){var t,a,n,l,c=e.post,i=e.setCurrentId,s=Object(o.b)(),u=Y(),m=JSON.parse(localStorage.getItem("profile")),p=function(){return c.likes.length>0?c.likes.find((function(e){var t,a;return e===((null===m||void 0===m||null===(t=m.result)||void 0===t?void 0:t.googleId)||(null===m||void 0===m||null===(a=m.result)||void 0===a?void 0:a._id))}))?r.a.createElement(r.a.Fragment,null,r.a.createElement(W.a,{fontSize:"small"}),"\xa0",c.likes.length>2?"You and ".concat(c.likes.length-1," others"):"".concat(c.likes.length," accepted").concat((c.likes.length,""))):r.a.createElement(r.a.Fragment,null,r.a.createElement(G.a,{fontSize:"small"}),"\xa0",c.likes.length," ",(c.likes.length,"Accepted")):r.a.createElement(r.a.Fragment,null,r.a.createElement(G.a,{fontSize:"small"}),"\xa0Accept")};return r.a.createElement(F.a,{className:u.card},r.a.createElement(_.a,{className:u.media,image:c.selectedFile||"https://user-images.githubusercontent.com/194400/49531010-48dad180-f8b1-11e8-8d89-1e61320e1d82.png",title:c.title}),r.a.createElement("div",{className:u.overlay},r.a.createElement(z.a,{variant:"h6"},c.name),r.a.createElement(z.a,{variant:"body2"},Q()(c.createdAt).fromNow())),((null===m||void 0===m||null===(t=m.result)||void 0===t?void 0:t.googleId)===(null===c||void 0===c?void 0:c.creator)||(null===m||void 0===m||null===(a=m.result)||void 0===a?void 0:a._id)===(null===c||void 0===c?void 0:c.creator))&&r.a.createElement("div",{className:u.overlay2},r.a.createElement(L.a,{onClick:function(){return i(c._id)},style:{color:"white"},size:"small"},r.a.createElement(R.a,{fontSize:"default"}))),r.a.createElement("div",{className:u.details},r.a.createElement(z.a,{variant:"body2",color:"textSecondary",component:"h2"},c.tags.map((function(e){return"#".concat(e," ")})))),r.a.createElement(z.a,{className:u.title,gutterBottom:!0,variant:"h5",component:"h2"},c.title),r.a.createElement(P.a,null,r.a.createElement(z.a,{variant:"body2",color:"textSecondary",component:"p"},c.message)),r.a.createElement(B.a,{className:u.cardActions},r.a.createElement(L.a,{size:"small",color:"primary",disabled:!(null===m||void 0===m?void 0:m.result),onClick:function(){return s((e=c._id,function(){var t=Object(j.a)(x.a.mark((function t(a){var n,r,l;return x.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=JSON.parse(localStorage.getItem("profile")),t.prev=1,t.next=4,N(e,null===n||void 0===n||n.token);case 4:r=t.sent,l=r.data,a({type:"LIKE",payload:l}),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(1),console.log(t.t0);case 12:case"end":return t.stop()}}),t,null,[[1,9]])})));return function(e){return t.apply(this,arguments)}}()));var e}},r.a.createElement(p,null)),((null===m||void 0===m||null===(n=m.result)||void 0===n?void 0:n.googleId)===(null===c||void 0===c?void 0:c.creator)||(null===m||void 0===m||null===(l=m.result)||void 0===l?void 0:l._id)===(null===c||void 0===c?void 0:c.creator))&&r.a.createElement(L.a,{size:"small",color:"secondary",onClick:function(){return s((e=c._id,function(){var t=Object(j.a)(x.a.mark((function t(a){return x.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,C(e);case 3:a({type:"DELETE",payload:e}),t.next=9;break;case 6:t.prev=6,t.t0=t.catch(0),console.log(t.t0);case 9:case"end":return t.stop()}}),t,null,[[0,6]])})));return function(e){return t.apply(this,arguments)}}()));var e}},r.a.createElement(H.a,{fontSize:"small"})," Delete")))},Z=a(38),$=a(182),ee=Object(V.a)((function(e){var t;return t={mainContainer:{borderRadius:15,margin:"30px 0",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:"10px 50px"},heading:{color:"rgba(0,183,255, 1)",textDecoration:"none"},image:{marginLeft:"15px"},toolbar:{display:"flex",justifyContent:"flex-end",width:"400px"},profile:{display:"flex",justifyContent:"space-between",width:"400px"},userName:{display:"flex",alignItems:"center"},brandContainer:{display:"flex",alignItems:"center"},smMargin:{margin:e.spacing(1)},purple:{color:e.palette.getContrastText($.a[500]),backgroundColor:$.a[500]}},Object(Z.a)(t,e.breakpoints.down("sm"),{appBar:{padding:"10px 20px"},heading:{display:"none"},userName:{display:"none"},image:{marginLeft:"5px"},toolbar:{display:"flex",justifyContent:"flex-end",width:"160px"}}),Object(Z.a)(t,"actionDiv",{textAlign:"center"}),t})),te=function(e){var t=e.setCurrentId,a=Object(o.c)((function(e){return e.posts})),n=ee();return a.length?r.a.createElement(E.a,{className:n.container,container:!0,alignItems:"stretch",spacing:3},a.map((function(e){return r.a.createElement(E.a,{key:e._id,item:!0,xs:12,sm:6,md:6},r.a.createElement(X,{post:e,setCurrentId:t}))}))):r.a.createElement(T.a,null)},ae=a(98),ne=a(190),re=a(90),le=a.n(re),ce=Object(V.a)((function(e){return{root:{"& .MuiTextField-root":{margin:e.spacing(1)}},paper:{padding:e.spacing(2)},form:{display:"flex",flexWrap:"wrap",justifyContent:"center"},fileInput:{width:"97%",margin:"10px 0"},buttonSubmit:{marginBottom:10}}})),oe=function(e){var t,a=e.currentId,l=e.setCurrentId,c=Object(n.useState)({title:"",message:"",tags:"",selectedFile:""}),i=Object(h.a)(c,2),s=i[0],u=i[1],p=Object(o.c)((function(e){return a?e.posts.find((function(e){return e._id===a})):null})),d=Object(o.b)(),f=ce(),g=JSON.parse(localStorage.getItem("profile"));Object(n.useEffect)((function(){p&&u(p)}),[p]);var v=function(){l(0),u({title:"",message:"",tags:"",selectedFile:""})},b=function(){var e=Object(j.a)(x.a.mark((function e(t){var n,r;return x.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.preventDefault(),0===a?(d(A(Object(m.a)(Object(m.a)({},s),{},{name:null===g||void 0===g||null===(n=g.result)||void 0===n?void 0:n.name}))),v()):(d(D(a,Object(m.a)(Object(m.a)({},s),{},{name:null===g||void 0===g||null===(r=g.result)||void 0===r?void 0:r.name}))),v());case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return(null===g||void 0===g||null===(t=g.result)||void 0===t?void 0:t.name)?r.a.createElement(ae.a,{className:f.paper},r.a.createElement("form",{autoComplete:"off",noValidate:!0,className:"".concat(f.root," ").concat(f.form),onSubmit:b},r.a.createElement(z.a,{variant:"h6"},a?'Editing "'.concat(p.title,'"'):"Create a Request"),r.a.createElement(ne.a,{name:"title",variant:"outlined",label:"Title",fullWidth:!0,value:s.title,onChange:function(e){return u(Object(m.a)(Object(m.a)({},s),{},{title:e.target.value}))}}),r.a.createElement(ne.a,{name:"message",variant:"outlined",label:"Message",fullWidth:!0,multiline:!0,rows:4,value:s.message,onChange:function(e){return u(Object(m.a)(Object(m.a)({},s),{},{message:e.target.value}))}}),r.a.createElement(ne.a,{name:"tags",variant:"outlined",label:"Tags (coma separated)",fullWidth:!0,value:s.tags,onChange:function(e){return u(Object(m.a)(Object(m.a)({},s),{},{tags:e.target.value.split(",")}))}}),r.a.createElement("div",{className:f.fileInput},r.a.createElement(le.a,{type:"file",multiple:!1,onDone:function(e){var t=e.base64;return u(Object(m.a)(Object(m.a)({},s),{},{selectedFile:t}))}})),r.a.createElement(L.a,{className:f.buttonSubmit,variant:"contained",color:"primary",size:"large",type:"submit",fullWidth:!0},"Submit"),r.a.createElement(L.a,{variant:"contained",color:"secondary",size:"large",onClick:v,fullWidth:!0},"Clear"))):r.a.createElement(ae.a,{className:f.paper},r.a.createElement(z.a,{variant:"h6",align:"center"},"Please Sign In to make your own requests."))},ie=function(){var e=Object(n.useState)(0),t=Object(h.a)(e,2),a=t[0],l=t[1],c=Object(o.b)();return Object(n.useEffect)((function(){c(function(){var e=Object(j.a)(x.a.mark((function e(t){var a,n;return x.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,w.get("/posts");case 3:a=e.sent,n=a.data,t({type:"FETCH_ALL",payload:n}),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),console.log(e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(t){return e.apply(this,arguments)}}())}),[a,c]),r.a.createElement(b.a,{in:!0},r.a.createElement(f.a,null,r.a.createElement(E.a,{container:!0,justify:"space-between",alignItems:"stretch",spacing:3},r.a.createElement(E.a,{item:!0,xs:12,sm:7},r.a.createElement(te,{setCurrentId:l})),r.a.createElement(E.a,{item:!0,xs:12,sm:4},r.a.createElement(oe,{currentId:a,setCurrentId:l})))))},se=a(186),ue=a(187),me=a(192),pe=a(91),de=a(58),fe=a.n(de),ge=Object(V.a)((function(e){return{appBar:{margin:"30px 0",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:"10px 50px",backgroundColor:"transparent",boxShadow:"none"},heading:{color:"aliceblue",textDecoration:"none",fontSize:"36px"},toolbar:{display:"flex",justifyContent:"flex-end",width:"400px"},profile:{display:"flex",justifyContent:"space-between",width:"400px"},userName:{display:"flex",alignItems:"center"},brandContainer:{display:"flex",alignItems:"center"},purple:{color:e.palette.getContrastText($.a[500]),backgroundColor:$.a[500]}}})),ve=function(){var e=Object(n.useState)(JSON.parse(localStorage.getItem("profile"))),t=Object(h.a)(e,2),a=t[0],l=t[1],c=Object(o.b)(),i=Object(v.g)(),s=Object(v.f)(),u=ge(),m=function(){c({type:"LOGOUT"}),s.push("/auth"),l(null)};return Object(n.useEffect)((function(){var e=null===a||void 0===a?void 0:a.token;e&&(1e3*Object(pe.a)(e).exp<(new Date).getTime()&&m());l(JSON.parse(localStorage.getItem("profile")))}),[i]),r.a.createElement(se.a,{className:u.appBar,position:"static",color:"inherit"},r.a.createElement("div",{className:u.brandContainer},r.a.createElement(z.a,{component:g.b,to:"/",className:u.heading,variant:"h2",align:"center"},"klez.sap"),r.a.createElement("img",{className:u.image,src:fe.a,alt:"icon",height:"60"})),r.a.createElement(ue.a,{className:u.toolbar},(null===a||void 0===a?void 0:a.result)?r.a.createElement("div",{className:u.profile},r.a.createElement(me.a,{className:u.purple,alt:null===a||void 0===a?void 0:a.result.name,src:null===a||void 0===a?void 0:a.result.imageUrl},null===a||void 0===a?void 0:a.result.name.charAt(0)),r.a.createElement(z.a,{className:u.userName,variant:"h6"},null===a||void 0===a?void 0:a.result.name),r.a.createElement(L.a,{variant:"contained",className:u.logout,color:"secondary",onClick:m},"Logout")):r.a.createElement(L.a,{component:g.b,to:"/auth",variant:"contained",color:"primary"},"Sign In")))},he=a(94),be=a.n(he),Ee=Object(V.a)((function(e){return{paper:{marginTop:e.spacing(8),display:"flex",flexDirection:"column",alignItems:"center",padding:e.spacing(2)},root:{"& .MuiTextField-root":{margin:e.spacing(1)}},avatar:{margin:e.spacing(1),backgroundColor:e.palette.secondary.main},form:{width:"100%",marginTop:e.spacing(3)},submit:{margin:e.spacing(3,0,2)},googleButton:{marginBottom:e.spacing(2)}}})),ye=a(188),xe=a(189),je=a(92),Oe=a.n(je),we=a(93),Ne=a.n(we),ke=function(e){var t=e.name,a=e.handleChange,n=e.label,l=e.half,c=e.autoFocus,o=e.type,i=e.handleShowPassword;return r.a.createElement(E.a,{item:!0,xs:12,sm:l?6:12},r.a.createElement(ne.a,{name:t,onChange:a,variant:"outlined",required:!0,fullWidth:!0,label:n,autoFocus:c,type:o,InputProps:"password"===t?{endAdornment:r.a.createElement(ye.a,{position:"end"},r.a.createElement(xe.a,{onClick:i},"password"===o?r.a.createElement(Oe.a,null):r.a.createElement(Ne.a,null)))}:null}))},Ce={firstName:"",lastName:"",email:"",password:"",confirmPassword:""},Se=function(){var e=Object(n.useState)(Ce),t=Object(h.a)(e,2),a=t[0],l=t[1],c=Object(n.useState)(!1),i=Object(h.a)(c,2),s=i[0],u=i[1],p=Object(o.b)(),d=Object(v.f)(),g=Ee(),b=Object(n.useState)(!1),y=Object(h.a)(b,2),O=y[0],w=y[1],N=function(e){return l(Object(m.a)(Object(m.a)({},a),{},Object(Z.a)({},e.target.name,e.target.value)))};return r.a.createElement(f.a,{component:"main",maxWidth:"xs"},r.a.createElement(ae.a,{className:g.paper,elevation:3},r.a.createElement(me.a,{className:g.avatar},r.a.createElement(be.a,null)),r.a.createElement(z.a,{component:"h1",variant:"h5"},s?"Sign up":"Sign in"),r.a.createElement("form",{className:g.form,onSubmit:function(e){var t,n;e.preventDefault(),p(s?(t=a,n=d,function(){var e=Object(j.a)(x.a.mark((function e(a){var r,l;return x.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,I(t);case 3:r=e.sent,l=r.data,a({type:"AUTH",data:l}),n.push("/home"),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),console.log(e.t0);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t){return e.apply(this,arguments)}}()):function(e,t){return function(){var a=Object(j.a)(x.a.mark((function a(n){var r,l;return x.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,S(e);case 3:r=a.sent,l=r.data,n({type:"AUTH",data:l}),t.push("/home"),a.next=12;break;case 9:a.prev=9,a.t0=a.catch(0),console.log(a.t0);case 12:case"end":return a.stop()}}),a,null,[[0,9]])})));return function(e){return a.apply(this,arguments)}}()}(a,d))}},r.a.createElement(E.a,{container:!0,spacing:2},s&&r.a.createElement(r.a.Fragment,null,r.a.createElement(ke,{name:"firstName",label:"First Name",handleChange:N,autoFocus:!0,half:!0}),r.a.createElement(ke,{name:"lastName",label:"Last Name",handleChange:N,half:!0})),r.a.createElement(ke,{name:"email",label:"Email Address",handleChange:N,type:"email"}),r.a.createElement(ke,{name:"password",label:"Password",handleChange:N,type:O?"text":"password",handleShowPassword:function(){return w(!O)}}),s&&r.a.createElement(ke,{name:"confirmPassword",label:"Repeat Password",handleChange:N,type:"password"})),r.a.createElement(L.a,{type:"submit",fullWidth:!0,variant:"contained",color:"primary",className:g.submit},s?"Sign Up":"Sign In"),r.a.createElement(E.a,{container:!0,justify:"flex-end"},r.a.createElement(E.a,{item:!0},r.a.createElement(L.a,{onClick:function(){l(Ce),u((function(e){return!e})),w(!1)}},s?"Already have an account? Sign in":"Don't have an account? Sign Up"))))))},Ie=a(95),Ae=a.n(Ie);a(141);var De=function(){return r.a.createElement("div",{className:"lan-body"},r.a.createElement("div",{className:"lan-navbar"},r.a.createElement("ul",null,r.a.createElement("div",null,r.a.createElement("li",{className:"lan-title"},"klez.sap",r.a.createElement("img",{src:fe.a,alt:"icon",height:"55"}))),r.a.createElement("div",{className:"lan-contents"},r.a.createElement("li",null,"Home"),r.a.createElement("a",{href:"https://www.linkedin.com/pulse/service-management-system-prasanth-gunnam/?trackingId=dAwShkEtQo%2Bz%2BIL0lN4e%2BA%3D%3D",target:"_blank"},r.a.createElement("li",null,"About")),r.a.createElement("a",{href:"https://github.com/Audacity21/SDP-1-Project",target:"_blank"},r.a.createElement("li",null,"Github")),r.a.createElement("li",null,"Contact")))),r.a.createElement("div",{className:"lan-desc"},r.a.createElement("div",{className:"lan-info"},r.a.createElement("h1",null,"Matching security specialists",r.a.createElement("br",null),"with great companies."),r.a.createElement("div",{className:"lan-login"},r.a.createElement("div",{className:"lan-security"},r.a.createElement("h3",null,"For Security"),r.a.createElement("p",null,"Sign Up as a cyber security expert to find services that are posted by people and contact them using our interface and offer your service"),r.a.createElement(g.b,{to:"/auth",className:"lan-btn1"},"Start services")),r.a.createElement("div",{className:"lan-customer"},r.a.createElement("h3",null,"For Customers"),r.a.createElement("p",null,"Sign Up as a customer to post your problems into our app so that professionals can find out your posts and come forward to offer their services"),r.a.createElement(g.b,{to:"/auth",className:"lan-btn2"},"Sign up & search")))),r.a.createElement("div",{className:"lan-img"},r.a.createElement("img",{src:Ae.a,alt:"no image"}))),r.a.createElement("div",{className:"lan-footer"},r.a.createElement("p",null,"Copyright \xa9 2021 Audacity21",r.a.createElement("br",null),"Privacy Policy")))},Te=function(){return r.a.createElement(g.a,null,r.a.createElement(f.a,{maxWidth:"lg"},r.a.createElement(ve,null),r.a.createElement(v.c,null,r.a.createElement(v.a,{path:"/",exact:!0,component:De}),r.a.createElement(v.a,{path:"/auth",exact:!0,component:Se}),r.a.createElement(v.a,{path:"/home",exact:!0,component:ie}))))},Fe=(a(142),Object(i.e)(d,Object(i.d)(Object(i.a)(s.a))));c.a.render(r.a.createElement(o.a,{store:Fe},r.a.createElement(Te,null)),document.getElementById("root"))},58:function(e,t,a){e.exports=a.p+"static/media/logo.86a93392.png"},95:function(e,t,a){e.exports=a.p+"static/media/lan.dfff6b16.png"}},[[106,1,2]]]);
  //# sourceMappingURL=main.aadb3aaa.chunk.js.map