text: (this["webpackJsonptweeter-web"]=this["webpackJsonptweeter-web"]||[]).push([[0],{13:function(e,t,c){},14:function(e,t,c){},15:function(e,t,c){"use strict";c.r(t);var n=c(0),s=c(1),a=c.n(s),r=c(6),i=c.n(r),o=(c(13),c.p+"static/media/logo.103b5fa1.svg"),l=(c(14),c(7)),j=c(2);function b(e){var t=a.a.createRef(),c=Object(s.useState)([]),r=Object(j.a)(c,2),i=r[0],o=r[1];return Object(n.jsxs)("div",{className:e.className,children:[Object(n.jsx)("div",{className:"col-12 mb-3",children:Object(n.jsxs)("form",{onSubmit:function(e){e.preventDefault();var c=t.current.value,n=Object(l.a)(i);n.unshift({content:c,likes:0,id:12313}),o(n),t.current.value=""},children:[Object(n.jsx)("textarea",{ref:t,required:!0,className:"form-control",name:"tweet"}),Object(n.jsx)("button",{type:"submit",className:"btn btn-primary my-3",children:"Tweet"})]})}),Object(n.jsx)(u,{newTweets:i})]})}function u(e){var t=Object(s.useState)([]),c=Object(j.a)(t,2),a=c[0],r=c[1],i=Object(s.useState)([]),o=Object(j.a)(i,2),b=o[0],u=o[1];return Object(s.useEffect)((function(){var t=Object(l.a)(e.newTweets).concat(a);t.length!==b.length&&u(t)}),[e.newTweets,b,a]),Object(s.useEffect)((function(){!function(e){var t=new XMLHttpRequest;t.responseType="json",t.open("GET","http://localhost:8000/api/tweets/"),t.onload=function(){e(t.response,t.status)},t.onerror=function(t){console.log(t),e({message:"The request was an error"},400)},t.send()}((function(e,t){200===t&&r(e)}))}),[]),b.map((function(e,t){return Object(n.jsx)(p,{tweet:e,className:"my-5 py-5 border bg-white text-dark"},"".concat(t,"-{item.id}"))}))}function d(e){var t=e.tweet,c=e.action,a=Object(s.useState)(t.likes?t.likes:0),r=Object(j.a)(a,2),i=r[0],o=r[1],l=Object(s.useState)(!0===t.userLike),b=Object(j.a)(l,2),u=b[0],d=b[1],p=e.className?e.className:"btn btn-primary btn-sm",O=c.display?c.display:"Action",m="like"===c.type?"".concat(i," ").concat(O):O;return Object(n.jsx)("button",{className:p,onClick:function(e){e.preventDefault(),"like"===c.type&&(!0===u?(o(i-1),d(!1)):(o(t.likes+1),d(!0)))},children:m})}function p(e){var t=e.tweet,c=e.className?e.className:"col-10 mx-auto col-md-6";return Object(n.jsxs)("div",{className:c,children:[Object(n.jsxs)("p",{children:[t.id," - ",t.content]}),Object(n.jsxs)("div",{className:"btn btn-group",children:[Object(n.jsx)(d,{tweet:t,action:{type:"like",display:"Likes"}}),Object(n.jsx)(d,{tweet:t,action:{type:"unlike",display:"Unlike"}}),Object(n.jsx)(d,{tweet:t,action:{type:"retweet",display:"Retweet"}})]})]})}var O=function(){return Object(n.jsx)("div",{className:"App",children:Object(n.jsxs)("header",{className:"App-header",children:[Object(n.jsx)("img",{src:o,className:"App-logo",alt:"logo"}),Object(n.jsxs)("p",{children:["Edit ",Object(n.jsx)("code",{children:"src/App.js"})," and save to reload."]}),Object(n.jsx)("div",{children:Object(n.jsx)(b,{})}),Object(n.jsx)("a",{className:"App-link",href:"https://reactjs.org",target:"_blank",rel:"noopener noreferrer",children:"Learn React"})]})})},m=function(e){e&&e instanceof Function&&c.e(3).then(c.bind(null,16)).then((function(t){var c=t.getCLS,n=t.getFID,s=t.getFCP,a=t.getLCP,r=t.getTTFB;c(e),n(e),s(e),a(e),r(e)}))},f=document.getElementById("root");f&&i.a.render(Object(n.jsx)(a.a.StrictMode,{children:Object(n.jsx)(O,{})}),f);var h=document.getElementById("tweeter");h&&i.a.render(Object(n.jsx)(a.a.StrictMode,{children:Object(n.jsx)(b,{})}),h),m()}},[[15,1,2]]]);
  //# sourceMappingURL=main.4ac8cd6c.chunk.js.map