text: (window.webpackJsonp=window.webpackJsonp||[]).push([[0],{34:function(e,t,a){e.exports=a(67)},39:function(e,t,a){},40:function(e,t,a){},62:function(e,t,a){},63:function(e,t,a){},64:function(e,t,a){},65:function(e,t,a){},66:function(e,t,a){},67:function(e,t,a){"use strict";a.r(t);var n=a(0),o=a.n(n),l=a(31),i=a.n(l),s=(a(39),a(6)),c=a(7),r=a(9),h=a(8),u=a(10),d=a(16),m=a(12),p=a(11),v=(a(40),function(e){return o.a.createElement("div",{className:"card"},o.a.createElement("div",{className:"card-content"},o.a.createElement("p",{className:"is-3",id:"search"},o.a.createElement("strong",null,"Book:")),o.a.createElement("div",{className:"field has-addons"},o.a.createElement("p",{className:"control"},o.a.createElement("input",{type:"text",name:"bookInput",id:"bookInput",form:"bookSearch",onChange:function(t){return e.handleChange(t)},className:"input",size:"144",placeholder:"Enter Title and hit Search Button",required:!0})),o.a.createElement("p",{className:"control"},o.a.createElement("button",{type:"submit",onClick:function(t){return e.handleSearchClick(t)},className:"button is-dark"},"Search")))))}),k=a(15),f=a.n(k),b={getBooks:function(){return f.a.get("/api/books")},searchBooks:function(e){return f.a.post("/search",{title:e})},addBookToDB:function(e){return f.a.post("/api/books",e)},deleteBook:function(e){return f.a.delete("/api/books/".concat(e))}},E=function(e){function t(e){var a;return Object(s.a)(this,t),(a=Object(r.a)(this,Object(h.a)(t).call(this,e))).handleSaveClick=function(e){this.setState({saved:!0});var t={title:this.props.title,authors:this.props.authors,link:this.props.link,img:this.props.img,description:this.props.description};e.preventDefault(),b.addBookToDB(t).then(function(e){console.log(e)}).catch(function(e){console.log(e)})},a.state={saved:!1,deleted:!1},a.handleSaveClick=a.handleSaveClick.bind(Object(p.a)(a)),a.handleDeleteClick=a.handleDeleteClick.bind(Object(p.a)(a)),a}return Object(u.a)(t,e),Object(c.a)(t,[{key:"handleDeleteClick",value:function(e){var t=this;this.setState({deleted:!0}),e.preventDefault(),b.deleteBook(this.props.id).then(function(e){console.log(e),d.a.dispatch(t.props.location,null)}).catch(function(e){console.log(e)})}},{key:"render",value:function(){return o.a.createElement("div",{className:"card",id:this.props.id?this.props.id:null,style:{display:this.state.deleted?"none":"block"}},o.a.createElement("div",{className:"card-content"},o.a.createElement("nav",{className:"level"},o.a.createElement("div",{className:"level-left"},o.a.createElement("p",{className:"level-item"},o.a.createElement("h1",{className:"title is-4"},o.a.createElement("strong",null,this.props.title)))),o.a.createElement("div",{className:"level-right"},o.a.createElement("div",{className:"level-item"},o.a.createElement("div",{className:"field"},this.props.link?o.a.createElement("a",{href:this.props.link,target:"_blank",rel:"noopener noreferrer"},o.a.createElement("button",{className:"button is-small is-dark is-outlined",type:"button",name:"view"},"View")):null," ","/"===this.props.path?o.a.createElement("button",{className:"button is-small is-dark is-outlined",type:"button",name:"save",onClick:this.handleSaveClick,disabled:this.state.saved},this.state.saved?"Saved":"Save"):o.a.createElement("button",{className:"button is-small is-dark is-outlined",type:"button",name:"Delete",onClick:this.handleDeleteClick,disabled:this.state.deleted},"Delete"))))),o.a.createElement("p",{id:"author"},"Written by ",o.a.createElement("strong",null,this.props.authors?this.props.authors.join(", "):"N/A")),o.a.createElement("div",{className:"columns"},o.a.createElement("div",{className:"column is-2"},this.props.img?o.a.createElement("img",{src:this.props.img.smallThumbnail?this.props.img.smallThumbnail:this.props.img.thumbnail?this.props.img.thumbnail:"",alt:"book cover"}):null),o.a.createElement("div",{className:"column is-10"},o.a.createElement("p",{id:"description"},this.props.description?this.props.description:"N/A")))))}}]),t}(o.a.Component);a(62);var g=function(e){return"/"===e.path?o.a.createElement("div",{className:"card"},o.a.createElement("div",{className:"card-content"},o.a.createElement("p",{className:"is-3",id:"search"},o.a.createElement("strong",null,"Results:")),e.bookData.map(function(t){var a=t.volumeInfo;return o.a.createElement(E,{title:a.title,authors:a.authors,description:a.description,link:a.canonicalVolumeLink,img:a.imageLinks,path:e.path,key:t.id})}))):"/saved"===e.path?e.savedBooks.length>0?o.a.createElement("div",{className:"card"},o.a.createElement("div",{className:"card-content"},o.a.createElement("p",{className:"is-3",id:"search"},o.a.createElement("strong",null,"Saved Books")),e.savedBooks.map(function(t){return o.a.createElement(E,{title:t.title,authors:t.authors,description:t.description,link:t.link,img:t.img,id:t._id,path:e.path,key:t._id})}))):o.a.createElement("div",{className:"card"},o.a.createElement("div",{className:"card-content"},o.a.createElement("p",{className:"is-3",id:"search"},o.a.createElement("strong",null,"Saved Books")),o.a.createElement("p",null,"No saved books."))):void 0},N=function(e){function t(e){var a;return Object(s.a)(this,t),(a=Object(r.a)(this,Object(h.a)(t).call(this,e))).state={bookInput:"",bookData:[]},a.handleSearchClick=a.handleSearchClick.bind(Object(p.a)(a)),a.handleChange=a.handleChange.bind(Object(p.a)(a)),a}return Object(u.a)(t,e),Object(c.a)(t,[{key:"handleChange",value:function(e){e.preventDefault(),this.setState({bookInput:e.target.value})}},{key:"handleSearchClick",value:function(e){var t=this;e.preventDefault(),b.searchBooks(this.state.bookInput).then(function(e){t.setState({bookData:e.data}),t.setState({bookInput:""})})}},{key:"render",value:function(){return o.a.createElement("main",null,o.a.createElement(v,{handleChange:this.handleChange,handleSearchClick:this.handleSearchClick}),this.state.bookData.length>0?o.a.createElement(g,{bookData:this.state.bookData,path:this.props.match.path}):null)}}]),t}(o.a.Component),S=function(e){function t(e){var a;return Object(s.a)(this,t),(a=Object(r.a)(this,Object(h.a)(t).call(this,e))).state={savedBooks:[]},a}return Object(u.a)(t,e),Object(c.a)(t,[{key:"componentWillMount",value:function(){var e=this;b.getBooks().then(function(t){e.setState({savedBooks:t.data})}).catch(function(e){console.log(e)})}},{key:"render",value:function(){return console.log(this.state.savedBooks),o.a.createElement("main",null,o.a.createElement(g,{savedBooks:this.state.savedBooks,path:this.props.match.path}))}}]),t}(o.a.Component),C=(a(63),function(e){return o.a.createElement("nav",{class:"navbar is-white is-fixed-top"},o.a.createElement("div",{class:"navbar-brand"},o.a.createElement("a",{id:"main",class:"navbar-item",href:"/"},o.a.createElement("h1",null,"BookShelf"))),o.a.createElement("div",{class:"navbar-menu is-active"},o.a.createElement("div",{class:"navbar-start"},o.a.createElement("a",{href:"/",class:"navbar-item"},"Search"),o.a.createElement("a",{href:"/saved",class:"navbar-item"},"Saved"))))}),j=(a(64),function(e){return o.a.createElement("section",{className:"hero"},o.a.createElement("div",{className:"hero-body"},o.a.createElement("div",{className:"container"},o.a.createElement("h1",{id:"google",className:"title is-3"},o.a.createElement("strong",null,"ReactJS - Google Books Search")),o.a.createElement("h2",{className:"is-4"},"Search for and Save Books of Interest"))))}),w=(a(65),function(e){return o.a.createElement("footer",null,o.a.createElement("div",null,o.a.createElement("p",null,"Enjoy this app? Get to know the\xa0",o.a.createElement("a",{href:"https://sergioardz.github.io/Portfolio/",target:"_blank"},"Author")," and checkout the\xa0",o.a.createElement("a",{href:"https://github.com/sergioardz/books-search",target:"_blank"},"Github")," Repository.")))}),B=(a(66),function(e){function t(){return Object(s.a)(this,t),Object(r.a)(this,Object(h.a)(t).apply(this,arguments))}return Object(u.a)(t,e),Object(c.a)(t,[{key:"render",value:function(){return o.a.createElement(d.a,null,o.a.createElement("div",{className:"block"},o.a.createElement(C,null),o.a.createElement(j,null),o.a.createElement(m.c,null,o.a.createElement(m.a,{exact:!0,path:"/",component:N}),o.a.createElement(m.a,{path:"/saved",component:S})),o.a.createElement(w,null)))}}]),t}(n.Component)),y=Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function O(e){navigator.serviceWorker.register(e).then(function(e){e.onupdatefound=function(){var t=e.installing;t.onstatechange=function(){"installed"===t.state&&(navigator.serviceWorker.controller?console.log("New content is available; please refresh."):console.log("Content is cached for offline use."))}}}).catch(function(e){console.error("Error during service worker registration:",e)})}i.a.render(o.a.createElement(B,null),document.getElementById("root")),function(){if("serviceWorker"in navigator){if(new URL("",window.location).origin!==window.location.origin)return;window.addEventListener("load",function(){var e="".concat("","/service-worker.js");y?function(e){fetch(e).then(function(t){404===t.status||-1===t.headers.get("content-type").indexOf("javascript")?navigator.serviceWorker.ready.then(function(e){e.unregister().then(function(){window.location.reload()})}):O(e)}).catch(function(){console.log("No internet connection found. App is running in offline mode.")})}(e):O(e)})}}()}},[[34,1,2]]]);
  //# sourceMappingURL=main.6d9be4ed.chunk.js.map