{"size": 10375, "ext": "js", "max_stars_repo_path": "client/build/static/js/main.8221f5d0.chunk.js", "max_stars_repo_name": "ruben-ruiz/gamelog-tracker", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/build/static/js/main.8221f5d0.chunk.js", "max_issues_repo_name": "ruben-ruiz/gamelog-tracker", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/build/static/js/main.8221f5d0.chunk.js", "max_forks_repo_name": "ruben-ruiz/gamelog-tracker", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 5187.5, "max_line_length": 10327, "alphanum_fraction": 0.6755662651}
(this["webpackJsonpgamelog-tracker"]=this["webpackJsonpgamelog-tracker"]||[]).push([[0],{104:function(e,t,n){},105:function(e,t,n){"use strict";n.r(t);var c=n(1),a=n.n(c),r=n(17),o=n.n(r),i=n(8),s=n(108),l=n(109),u=n(110),j=n(111),g=n(112),b=n(113),d=n(114),O=n(11),h=n.n(O),f=n(21),m=n(2);var x=function(e){var t=e.checkLogin,n={marginLeft:"0.5rem",outline:"none",color:"white",background:"none",fontSize:"1.8rem",border:"none",cursor:"pointer"};return Object(m.jsx)(f.GoogleLogin,{clientId:"742413594674-i998hv5n1t54g1m1pi2n3brc6cpuhpdh.apps.googleusercontent.com",buttonText:"Login",onSuccess:function(e){h()({method:"POST",url:"/api/googlelogin",data:{tokenId:e.tokenId}}).then((function(e){return t(e.data.user.picture)})).catch((function(e){console.log(e)}))},onFailure:function(e){h()({method:"POST",url:"/api/googlelogin",data:{tokenId:e.tokenId}}).then((function(e){return console.log(e)})).catch((function(e){console.log(e)}))},cookiePolicy:"single_host_origin",render:function(e){return Object(m.jsx)("button",{className:"login-btn",onClick:e.onClick,style:n,children:"Login"})},isSignedIn:!0})},p=n(106),y=n(123),v=n(124),k=n(107);var S=function(e){var t=e.checkLogin,n=e.userImage,a=Object(c.useState)(!1),r=Object(i.a)(a,2),o=r[0],s=r[1],l=Object(f.useGoogleLogout)({clientId:"836968365888-6tdvb8sji32an3pf99uds3v88p1g47sm.apps.googleusercontent.com",onLogoutSuccess:function(){h.a.delete("/api/googlelogout").then(t()).catch((function(e){return console.log(e)}))}}).signOut;return Object(m.jsxs)(p.a,{isOpen:o,toggle:function(){return s((function(e){return!e}))},className:"logout-dropdown",children:[Object(m.jsx)(y.a,{children:Object(m.jsx)("img",{className:"profileImg",src:n,alt:"User Avatar"})}),Object(m.jsx)(v.a,{children:Object(m.jsx)(k.a,{onClick:l,children:"Logout"})})]})},L=function(e){var t=e.userImage,n=e.isLoggedIn,a=e.checkLogin,r=Object(c.useState)(!1),o=Object(i.a)(r,2),O=o[0],h=o[1];return Object(m.jsxs)(s.a,{expand:"md",children:[Object(m.jsx)(l.a,{href:"/",children:"Gamelog Tracker"}),Object(m.jsx)(u.a,{onClick:function(){return h(!O)}}),Object(m.jsx)(j.a,{isOpen:O,navbar:!0,children:Object(m.jsxs)(g.a,{className:"mr-auto",navbar:!0,children:[Object(m.jsx)(b.a,{children:Object(m.jsx)(d.a,{href:"/",children:"Search"})}),Object(m.jsx)(b.a,{children:Object(m.jsx)(d.a,{href:"/library",children:"Library"})}),n?Object(m.jsx)(S,{userImage:t,checkLogin:a}):Object(m.jsx)(x,{checkLogin:a})]})})]})},w=n(115),C=n(116),I=n(117),N=n(54),A=function(e){var t=e.searchGames,n=Object(c.useState)([]),a=Object(i.a)(n,2),r=a[0],o=a[1],s=Object(c.useState)([]),l=Object(i.a)(s,2),u=l[0],j=l[1],g=Object(c.useState)(""),b=Object(i.a)(g,2),d=b[0],O=b[1],f=Object(c.useState)(""),x=Object(i.a)(f,2),p=x[0],y=x[1],v=Object(c.useState)(""),k=Object(i.a)(v,2),S=k[0],L=k[1];Object(c.useEffect)((function(){h.a.get("/api/genres").then((function(e){return o(e.data)})).catch((function(e){return console.log("err")}))}),[]),Object(c.useEffect)((function(){h.a.get("/api/platforms").then((function(e){return j(e.data)})).catch((function(e){return console.log("err")}))}),[]);return Object(m.jsxs)(w.a,{className:"search-form",onSubmit:function(e){return function(e){e.preventDefault();var n=d.split(" ").join("-").toLowerCase(),c=p.split(" ").join("-").toLowerCase(),a=S.split(" ").join("-").toLowerCase();t(n,c,a)}(e)},children:[Object(m.jsx)(C.a,{className:"search-input",children:Object(m.jsx)(I.a,{type:"text",name:"titles",id:"titleSearch",placeholder:"search games by title",onChange:function(e){return O(e.target.value)}})}),Object(m.jsx)(C.a,{className:"search-dropdown",children:Object(m.jsxs)(I.a,{type:"select",name:"genre-select",id:"genreSelect",onChange:function(e){return y(e.target.value)},children:[Object(m.jsx)("option",{children:"All Genres"}),r?r.map((function(e,t){return Object(m.jsx)("option",{value:e.slug,children:e.name},t)})):Object(m.jsx)(m.Fragment,{})]})}),Object(m.jsx)(C.a,{className:"search-dropdown",children:Object(m.jsxs)(I.a,{type:"select",name:"platform-select",id:"platformSelect",onChange:function(e){return L(e.target.value)},children:[Object(m.jsx)("option",{children:"All Platforms"}),u?u.map((function(e,t){return Object(m.jsx)("option",{value:e.id,children:e.name},t)})):Object(m.jsx)(m.Fragment,{})]})}),Object(m.jsx)(N.a,{className:"search-submit",type:"submit",children:"Submit"})]})},E=n(118),_=n(119),F=n(120),P=n(121),G=n(122),R=function(e){var t=e.game,n=e.libraryCard,r=Object(c.useState)(""),o=Object(i.a)(r,2),s=o[0],l=o[1],u=Object(c.useState)(""),j=Object(i.a)(u,2),g=j[0],b=j[1],d=Object(c.useState)(!1),O=Object(i.a)(d,2),f=O[0],x=O[1],S=a.a.useCallback((function(e){var c="card-btn ";e&&"Remove"!==e?(c+="card-btn-".concat(e),l(e),b(c),n&&n(t.status,e)):(l("Add to Library"),b(c),n&&n(t.status,""))}),[t.status,n]);function L(e){var n=e.currentTarget.textContent;if(""===s||"Add to Library"===s){if("Remove"===n)return;h.a.post("/api/library",{id:t.id,slug:t.slug,name:t.name,released:t.released,background_image:t.background_image,rating:t.rating,rating_top:t.rating_top,genres:w,status:n}).then(S(n)).catch((function(e){return console.log(e)}))}else"Remove"===n?h.a.delete("/api/library",{params:{id:t._id}}).then(S(n)).catch((function(e){return console.log(e)})):h.a.put("/api/library",{id:t.id,status:n}).then(S(n)).catch((function(e){return console.log(e)}))}Object(c.useEffect)((function(){S(t.status)}),[t.status,S]);var w=t.genres;return Array.isArray(t.genres)&&(w=t.genres.map((function(e){return e.name})).join(", ")),Object(m.jsxs)(E.a,{children:[Object(m.jsx)(_.a,{src:t.background_image,alt:"Card image cap"}),Object(m.jsxs)(F.a,{children:[Object(m.jsx)(P.a,{tag:"h5",children:t.name}),Object(m.jsxs)(G.a,{children:["Released: ",t.released]}),Object(m.jsxs)(G.a,{children:["Rating: ",t.rating,"/",t.rating_top]}),Object(m.jsx)(G.a,{children:w}),Object(m.jsxs)(p.a,{isOpen:f,toggle:function(){return x((function(e){return!e}))},direction:"up",children:[Object(m.jsx)(y.a,{caret:!0,className:g,children:s}),Object(m.jsxs)(v.a,{children:[Object(m.jsx)(k.a,{onClick:function(e){return L(e)},children:"Backlog"}),Object(m.jsx)(k.a,{onClick:function(e){return L(e)},children:"Playing"}),Object(m.jsx)(k.a,{onClick:function(e){return L(e)},children:"Completed"}),"Add to Library"!==s?Object(m.jsx)(k.a,{onClick:function(e){return L(e)},children:"Remove"}):Object(m.jsx)(m.Fragment,{})]})]})]})]})},B=function(e){var t=e.games,n=Object(c.useState)([]),a=Object(i.a)(n,2),r=a[0],o=a[1],s=Object(c.useState)(!0),l=Object(i.a)(s,2),u=l[0],j=l[1];return Object(c.useEffect)((function(){h.a.get("/api/library/getAll").then((function(e){if(!Array.isArray(e.data))throw new Error("not logged in");o(e.data)})).then(j(!1)).catch((function(e){return console.log(e)}))}),[]),Object(m.jsx)("div",{className:"games-display",children:u?Object(m.jsx)(m.Fragment,{}):t.results.map((function(e,t){if(e){for(var n=0;n<r.length;n++)if(r[n].id===e.id)return e._id=r[n]._id,e.status=r[n].status,Object(m.jsx)(R,{game:e},t);return e.status="",Object(m.jsx)(R,{game:e},t)}return Object(m.jsx)(m.Fragment,{})}))})},T=function(){var e=Object(c.useState)({}),t=Object(i.a)(e,2),n=t[0],a=t[1];function r(e,t,n){h.a.get("/api/games",{params:{query:e,genres:t,platforms:n}}).then((function(e){return a(e.data)})).catch((function(e){return console.log(e)}))}return Object(c.useEffect)((function(){r()}),[]),Object(c.useEffect)((function(){if(0!==Object.entries(n).length){window.addEventListener("scroll",(function e(){window.innerHeight+window.scrollY>=document.body.offsetHeight-10&&(h.a.get("/api/games/next",{params:{query:n.next}}).then((function(e){return e.data})).then((function(e){a((function(t){return{results:t.results.concat(e.results),next:e.next}}))})).catch((function(e){return console.log(e)})),window.removeEventListener("scroll",e))}))}}),[n]),0===Object.keys(n).length?Object(m.jsx)("div",{className:"main"}):Object(m.jsxs)("div",{className:"main",children:[Object(m.jsx)(A,{searchGames:r}),Object(m.jsx)(B,{games:n})]})},q=function(e){var t=e.isLoggedIn,n=Object(c.useState)([]),r=Object(i.a)(n,2),o=r[0],s=r[1],l=Object(c.useState)([]),u=Object(i.a)(l,2),j=u[0],g=u[1],b=Object(c.useState)([]),d=Object(i.a)(b,2),O=d[0],f=d[1];var x=a.a.useCallback((function(){!0===t&&(h.a.get("/api/library/getBacklog").then((function(e){if(!Array.isArray(e.data))throw new Error("not logged in");s(e.data)})).catch((function(e){return console.log(e)})),h.a.get("/api/library/getPlaying").then((function(e){if(!Array.isArray(e.data))throw new Error("not logged in");g(e.data)})).catch((function(e){return console.log(e)})),h.a.get("/api/library/getCompleted").then((function(e){if(!Array.isArray(e.data))throw new Error("not logged in");f(e.data)})).catch((function(e){return console.log(e)})))}),[t]);function p(e,t){e!==t&&("Backlog"===e&&s([]),"Playing"===e&&g([]),"Completed"===e&&f([]),x())}return Object(c.useEffect)((function(){x()}),[x]),Object(m.jsx)("div",{className:"library",children:t?Object(m.jsxs)(m.Fragment,{children:[Object(m.jsxs)("div",{className:"library-category backlog",children:[Object(m.jsx)("h2",{children:"Backlog"}),o?o.map((function(e,t){return Object(m.jsx)(R,{game:e,libraryCard:p},t)})):Object(m.jsx)(m.Fragment,{})]}),Object(m.jsxs)("div",{className:"library-category playing",children:[Object(m.jsx)("h2",{children:"Currently Playing"}),j?j.map((function(e,t){return Object(m.jsx)(R,{game:e,libraryCard:p},t)})):Object(m.jsx)(m.Fragment,{})]}),Object(m.jsxs)("div",{className:"library-category completed",children:[Object(m.jsx)("h2",{children:"Completed"}),O?O.map((function(e,t){return Object(m.jsx)(R,{game:e,libraryCard:p},t)})):Object(m.jsx)(m.Fragment,{})]})]}):Object(m.jsx)("div",{className:"library-notLoggedIn",children:"Login to view your library"})})};var H=function(){var e=Object(c.useState)(!1),t=Object(i.a)(e,2),n=t[0],r=t[1],o=Object(c.useState)(""),s=Object(i.a)(o,2),l=s[0],u=s[1],j=a.a.useCallback((function(e){e?(u(e),r(!0)):(u(""),r(!1))}),[]);Object(c.useEffect)((function(){j()}),[j]);var g=window.location.pathname;return Object(m.jsxs)("div",{className:"App",children:[Object(m.jsx)(L,{userImage:l,isLoggedIn:n,checkLogin:j}),"/library"===g?Object(m.jsx)(q,{isLoggedIn:n}):Object(m.jsx)(T,{isLoggedIn:n})]})};n(103),n(104);o.a.render(Object(m.jsx)(H,{}),document.getElementById("root"))}},[[105,1,2]]]);
//# sourceMappingURL=main.8221f5d0.chunk.js.map