text: (this["webpackJsonpreact-mini-project"]=this["webpackJsonpreact-mini-project"]||[]).push([[0],{111:function(e,t,c){},112:function(e,t,c){},116:function(e,t,c){},117:function(e,t,c){},124:function(e,t,c){},136:function(e,t,c){},137:function(e,t,c){"use strict";c.r(t);var n=c(0),s=c(1),a=c.n(s),o=c(22),l=c.n(o),i=(c(58),c(6)),r=(c(59),c(16)),j=c(7),b=c(27),u=c.n(b),d="https://jobs.github.com/positions",m=u.a.CancelToken,O=a.a.createContext({jobdesc:"",setJobdesc:function(e){},location:"",setLocation:function(e){},fulltime:!1,setFulltime:function(e){},searchNow:!1,setSearchNow:function(e){}}),h=c(21),x=c.n(h),f=c(31),p=c.n(f),g=c(9),v=c.n(g),N=(c(93),c(24)),y=c(25),w=function(){function e(){Object(N.a)(this,e)}return Object(y.a)(e,null,[{key:"getDatesDiffInDays",value:function(e,t){var c=Math.abs(e.getTime()-t.getTime());return Math.ceil(c/864e5)}}]),e}(),L=function(e){var t=Object(s.useState)(),c=Object(i.a)(t,2),a=c[0],o=c[1],l=Object(s.useContext)(O),j=l.jobdesc,b=l.location,u=l.fulltime,d=l.searchNow,m=l.setSearchNow;Object(s.useEffect)((function(){console.log("use effect called"),o(e.jobList)}),[e.jobList]),Object(s.useEffect)((function(){d&&(!function(){var t,c,n;t=""!==j?e.jobList.filter((function(e){return e.description.toLocaleLowerCase().includes(j)})):e.jobList,c=""!==b?t.filter((function(e){return e.location.toLocaleLowerCase().includes(b)})):t,console.log("fulltime?",u),n=u?c.filter((function(e){return e.type.toLocaleLowerCase().includes("full time")})):c,console.log("filter result",n),o(n)}(),m(!1))}),[u,j,b,e.jobList,d,m]);var h=Object(s.useCallback)((function(){if(a){var e=[];return a.forEach((function(t){e.push(Object(n.jsx)(r.b,{to:"/job-desc/".concat(t.id),children:Object(n.jsxs)(p.a.Item,{className:"job-entry",children:[Object(n.jsxs)(v.a,{className:"job-upper-row",children:[Object(n.jsx)(v.a.Column,{className:"job-column-left",children:Object(n.jsx)("p",{className:"job-title job-entry-left",children:t.title})}),Object(n.jsx)(v.a.Column,{className:"job-column-right",children:Object(n.jsx)("p",{className:"job-location job-entry-right",children:t.location})})]}),Object(n.jsxs)(v.a,{className:"job-lower-row",children:[Object(n.jsx)(v.a.Column,{className:"job-column-left",children:Object(n.jsxs)("p",{className:"job-subtitle job-entry-left",children:[t.company," - ",Object(n.jsx)("b",{children:t.type})]})}),Object(n.jsx)(v.a.Column,{className:"job-column-right",children:Object(n.jsxs)("p",{className:" job-subtitle job-entry-right",children:[w.getDatesDiffInDays(new Date,new Date(t.created_at))," days ago"]})})]})]})},t.id))})),e}}),[a]);return Object(n.jsxs)(x.a,{children:[Object(n.jsx)("h1",{className:"job-list-title",children:"Job List"}),Object(n.jsx)(p.a,{hoverable:!0,children:h()})]})},C=c(12),I=c(34),S=(c(111),function(e){var t=Object(s.useState)({jobdesc:"",location:"",fulltime:!1}),c=Object(i.a)(t,2),a=c[0],o=c[1],l=Object(s.useContext)(O),r=l.setJobdesc,j=l.setLocation,b=l.setFulltime,u=l.setSearchNow;return Object(n.jsx)(n.Fragment,{children:Object(n.jsxs)(v.a,{className:"is-vcentered",children:[Object(n.jsx)(v.a.Column,{size:4,children:Object(n.jsxs)("div",{className:"control searchbar-text",children:[Object(n.jsx)(I.Label,{className:"searchbar-text",children:"Job Description"}),Object(n.jsx)("input",{className:"input searchbar-text is-primary",type:"text",placeholder:"Filter by title, benefits, companies, expertise",value:a.jobdesc,onInput:function(e){var t=e.target;o(Object(C.a)(Object(C.a)({},a),{},{jobdesc:t.value}))}})]})}),Object(n.jsx)(v.a.Column,{size:4,children:Object(n.jsxs)("div",{className:"control",children:[Object(n.jsx)(I.Label,{className:"searchbar-text",children:"Location"}),Object(n.jsx)("input",{className:"input searchbar-text is-primary",type:"text",value:a.location,placeholder:"Filter by location",onInput:function(e){var t=e.target;o(Object(C.a)(Object(C.a)({},a),{},{location:t.value}))}})]})}),Object(n.jsx)(v.a.Column,{size:2,children:Object(n.jsxs)("label",{className:"checkbox",children:[Object(n.jsx)("input",{className:"searchbar-text",type:"checkbox",value:a.fulltime,onChange:function(){o(Object(C.a)(Object(C.a)({},a),{},{fulltime:!a.fulltime}))}}),Object(n.jsx)("span",{className:"searchbar-text",children:"\xa0Full-time only"})]})}),Object(n.jsx)(v.a.Column,{size:2,children:Object(n.jsx)("div",{className:"control",children:Object(n.jsx)("div",{className:"searchbar-text search-button button is-info",onClick:function(){r(a.jobdesc.toLocaleLowerCase()),j(a.location.toLocaleLowerCase()),b(a.fulltime),u(!0)},children:"Search"})})})]})})}),k=(c(112),function(){var e=Object(s.useState)([]),t=Object(i.a)(e,2),c=t[0],a=t[1],o=Object(s.useState)(""),l=Object(i.a)(o,2),r=l[0],j=l[1],b=Object(s.useState)(""),h=Object(i.a)(b,2),x=h[0],f=h[1],p=Object(s.useState)(!1),g=Object(i.a)(p,2),v=g[0],N=g[1],y=Object(s.useState)(!1),w=Object(i.a)(y,2),C=w[0],I=w[1];return Object(s.useEffect)((function(){var e=function(){var e;return{request:u()({url:"".concat(d,".json"),method:"get",cancelToken:new m((function(t){e=t}))}).then((function(e){return e.data})),cancel:e}}(),t=e.cancel;return e.request.then((function(e){a(e)})).catch((function(e){console.log(e)})),function(){t()}}),[]),Object(n.jsx)(O.Provider,{value:{jobdesc:r,setJobdesc:j,location:x,searchNow:C,setLocation:f,fulltime:v,setFulltime:N,setSearchNow:I},children:Object(n.jsxs)("div",{className:"joblist-container",children:[Object(n.jsx)(S,{jobList:c}),Object(n.jsx)(L,{jobList:c})]})})}),F=c(48),E=c.n(F),M=c(35),T=c.n(M),U=(c(116),function(e){var t=Object(j.h)(),c=Object(s.useState)(),a=Object(i.a)(c,2),o=a[0],l=a[1];Object(s.useEffect)((function(){var e=function(e){var t;return{request:u()({url:"".concat(d,"/").concat(e,".json"),method:"get",cancelToken:new m((function(e){t=e}))}).then((function(e){return e.data})),cancel:t}}(t.id),c=e.cancel;return e.request.then((function(e){l(e)})).catch((function(e){console.log(e)})),function(){c()}}),[t.id]);return Object(n.jsx)("div",{children:Object(n.jsxs)(x.a,{children:[function(){if(o)return Object(n.jsxs)("div",{children:[Object(n.jsxs)("h3",{className:"jobdesc-subtitle",children:[o.type," / ",o.location]}),Object(n.jsx)("h1",{className:"jobdesc-title",children:o.title}),Object(n.jsx)("hr",{})]})}(),function(){if(o)return Object(n.jsxs)(v.a,{className:"jobdesc-content",children:[Object(n.jsx)(v.a.Column,{size:8,children:Object(n.jsx)("div",{className:"job-desc-content",dangerouslySetInnerHTML:{__html:T.a.sanitize(o.description,{})}})}),Object(n.jsxs)(v.a.Column,{size:4,children:[Object(n.jsx)(v.a,{className:"jobdesc-right-boxes",children:Object(n.jsxs)(x.a,{className:"jobdesc-logobox",children:[Object(n.jsx)("div",{className:"jobdesc-company-name",children:o.company}),Object(n.jsx)(x.a,{className:"jobdesc-company-logo-container",children:Object(n.jsx)(E.a,{className:"jobdesc-company-logo",src:o.company_logo})}),Object(n.jsx)("div",{className:"jobdesc-company-url",children:o.company_url})]})}),Object(n.jsx)(v.a,{className:"jobdesc-right-boxes",children:Object(n.jsxs)(x.a,{className:"jobdesc-logobox jobdesc-yellow-boxes",children:[Object(n.jsx)("div",{className:"jobdesc-company-name",children:"How to apply"}),Object(n.jsx)("div",{className:"job-desc-content",dangerouslySetInnerHTML:{__html:T.a.sanitize(o.how_to_apply,{})}})]})})]})]})}()]})})}),D=(c(117),c(26)),A=c.n(D),P=a.a.createContext({isLoggedIn:!1,setIsLoggedIn:function(e){},username:"",setUsername:function(e){},imageUrl:"",setImageUrl:function(e){}}),_=a.a.createContext({loginFailAlert:!1,setLoginFailAlert:function(e){}}),z=c(20),J=function(){var e=Object(j.g)(),t=Object(s.useContext)(P),c=t.setUsername,a=t.setIsLoggedIn,o=Object(s.useContext)(_).setLoginFailAlert,l=Object(s.useState)(!1),r=Object(i.a)(l,2),b=r[0],u=r[1],d="abcdef@gmail.com",m="123456",O=Object(s.useState)({username:"",password:""}),h=Object(i.a)(O,2),x=h[0],f=h[1];return Object(n.jsx)("section",{className:"login-form hero is-primary is-fullheight",children:Object(n.jsx)("div",{className:"hero-body",children:Object(n.jsx)("div",{className:"container",children:Object(n.jsx)("div",{className:"columns is-centered",children:Object(n.jsx)("div",{className:"column is-5-tablet is-4-desktop is-3-widescreen",children:Object(n.jsxs)("form",{action:"",className:"box",children:[Object(n.jsxs)("div",{className:"field",children:[Object(n.jsx)("label",{className:"label",children:"Email"}),Object(n.jsxs)("div",{className:"control has-icons-left",children:[Object(n.jsx)("input",{type:"email",placeholder:"e.g. bobsmith@gmail.com",className:"input",required:!0,value:x.jobdesc,onInput:function(e){var t=e.target;f(Object(C.a)(Object(C.a)({},x),{},{username:t.value}))}}),Object(n.jsx)("span",{className:"icon is-small is-left",children:Object(n.jsx)("i",{className:"fa fa-envelope"})})]})]}),Object(n.jsxs)("div",{className:"field",children:[Object(n.jsx)("label",{className:"label",children:"Password"}),Object(n.jsxs)("div",{className:"control has-icons-left",children:[Object(n.jsx)("input",{type:"password",placeholder:"*******",className:"input",value:x.password,onInput:function(e){var t=e.target;f(Object(C.a)(Object(C.a)({},x),{},{password:t.value}))},required:!0}),Object(n.jsx)("span",{className:"icon is-small is-left",children:Object(n.jsx)("i",{className:"fa fa-lock"})})]})]}),Object(n.jsx)("div",{className:"field",children:Object(n.jsxs)("label",{className:"checkbox",children:[Object(n.jsx)("input",{type:"checkbox",onChange:function(){u(!b)}}),Object(n.jsx)("p",{className:"login-text",children:"\xa0 Remember me"})]})}),Object(n.jsx)("div",{className:"field",children:Object(n.jsx)(A.a,{className:"is-success",type:"button",onClick:function(){console.log(x.username,x.password,d,m),x.username===d&&x.password===m?(console.log("redirecting..."),a(!0),c(x.username),b&&(console.log("REMEMBERING THE USER"),(new z.a).set("loggedInUser",x.username,{path:"/"})),e.replace("/job-list")):o(!0)},children:"Login"})})]})})})})})})},B=c(51),q=function(){var e=Object(s.useContext)(P).isLoggedIn,t=(new z.a).get("loggedInUser");return t&&""!==t?(console.log("cookies exist!"),!0):(console.log("Logged in?",e),e)},H=function(e){var t=e.component,c=Object(B.a)(e,["component"]),s=q();return Object(n.jsx)(j.b,Object(C.a)(Object(C.a)({},c),{},{render:function(e){return s?Object(n.jsx)(t,Object(C.a)({},e)):Object(n.jsx)(j.a,{to:{pathname:"/login",state:{from:e.location}}})}}))},R=c(36),G=c.n(R),W=c(49),K=c(50),Q=c.n(K),V=c(139),X=function(){function e(){Object(N.a)(this,e)}return Object(y.a)(e,null,[{key:"randomIntFromInterval",value:function(e,t){return Math.floor(Math.random()*(t-e+1)+e)}},{key:"randomFloatFromInterval",value:function(e,t){return Math.random()*(t-e)+e}},{key:"roundToNDecimal",value:function(e,t){return Math.round((e+Number.EPSILON)*Math.pow(10,t))/Math.pow(10,t)}},{key:"delay",value:function(e){return new Promise((function(t){return setTimeout(t,e)}))}}]),e}(),Y=function(){var e=Object(s.useContext)(_),t=e.loginFailAlert,c=e.setLoginFailAlert;return Object(n.jsx)(V.a,{in:t,timeout:{enter:300,exit:400},classNames:"alert",unmountOnExit:!0,onEnter:Object(W.a)(G.a.mark((function e(){return G.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,X.delay(2e3);case 2:c(!1);case 3:case"end":return e.stop()}}),e)}))),children:Object(n.jsxs)(Q.a,{color:"danger",children:["Wrong credentials! Please try again.",Object(n.jsx)(A.a,{remove:!0,onClick:function(){c(!1)}})]})})},Z=(c(124),function(){return Object(n.jsx)("div",{className:"alerts-parent",children:Object(n.jsx)(Y,{})})}),$=c(18),ee=c.n($),te=(c(136),function(){var e=Object(s.useContext)(P),t=e.username,c=e.setIsLoggedIn,a=Object(s.useState)(!1),o=Object(i.a)(a,2),l=o[0],b=o[1],u=Object(j.g)();return Object(n.jsxs)(ee.a,{color:"black",fixed:"top",active:l,transparent:!1,children:[Object(n.jsxs)(ee.a.Brand,{className:"brand",active:(!1).toString(),children:[Object(n.jsxs)("h1",{className:"title",children:[Object(n.jsx)("b",{children:"GITHUB"})," JOBS"]}),Object(n.jsx)(ee.a.Burger,{onClick:function(){return b(!l)}})]}),Object(n.jsx)(ee.a.Menu,{className:"navbar-menu",children:Object(n.jsxs)(ee.a.Container,{position:"end",children:[Object(n.jsx)("div",{className:"navbar-item",children:Object(n.jsx)(r.b,{to:"/job-list",children:"All jobs"})}),""!==t?Object(n.jsxs)(ee.a.Item,{dropdown:!0,hoverable:!0,children:[Object(n.jsxs)(ee.a.Item,{arrowless:!1,className:"navbar-username",children:["Hello there, \xa0",Object(n.jsx)("b",{children:t})]}),Object(n.jsx)(ee.a.Dropdown,{className:"is-right",children:Object(n.jsx)(ee.a.Item,{className:"navbar-item-drop",onClick:function(){(new z.a).remove("loggedInUser"),c(!1),u.replace("/login")},children:"Logout"})})]}):Object(n.jsx)("div",{className:"navbar-item",children:Object(n.jsx)(r.b,{to:"/login",children:"Login"})})]})})]})});var ce=function(){var e=Object(s.useState)(""),t=Object(i.a)(e,2),c=t[0],a=t[1],o=Object(s.useState)(""),l=Object(i.a)(o,2),b=l[0],u=l[1],d=Object(s.useState)(!1),m=Object(i.a)(d,2),O=m[0],h=m[1],x=Object(s.useState)(!1),f=Object(i.a)(x,2),p=f[0],g=f[1];return Object(s.useEffect)((function(){var e=(new z.a).get("loggedInUser");e&&""!==e&&(console.log("cookies exist setting credentials!"),a(e),h(!0))}),[]),Object(n.jsx)("div",{className:"App",children:Object(n.jsx)("header",{className:"App-header",children:Object(n.jsx)(_.Provider,{value:{loginFailAlert:p,setLoginFailAlert:g},children:Object(n.jsxs)(P.Provider,{value:{username:c,setUsername:a,imageUrl:b,setImageUrl:u,isLoggedIn:O,setIsLoggedIn:h},children:[Object(n.jsx)(Z,{}),Object(n.jsxs)(r.a,{children:[Object(n.jsx)(te,{}),Object(n.jsxs)(j.d,{children:[Object(n.jsx)(H,{path:"/",component:k,exact:!0}),Object(n.jsx)(j.b,{path:"/login",children:Object(n.jsx)(J,{})}),Object(n.jsx)(H,{path:"/job-list",component:k,exact:!0}),Object(n.jsx)(H,{path:"/job-desc/:id",component:U,exact:!0})]})]})]})})})})},ne=function(e){e&&e instanceof Function&&c.e(3).then(c.bind(null,140)).then((function(t){var c=t.getCLS,n=t.getFID,s=t.getFCP,a=t.getLCP,o=t.getTTFB;c(e),n(e),s(e),a(e),o(e)}))};l.a.render(Object(n.jsx)(a.a.StrictMode,{children:Object(n.jsx)(ce,{})}),document.getElementById("root")),ne()},58:function(e,t,c){},59:function(e,t,c){},93:function(e,t,c){}},[[137,1,2]]]);
  //# sourceMappingURL=main.8d0db9e5.chunk.js.map