text: (this["webpackJsonpgoit-react-hw-04-hooks-feedback"]=this["webpackJsonpgoit-react-hw-04-hooks-feedback"]||[]).push([[0],{12:function(e,t,n){},13:function(e,t,n){"use strict";n.r(t);var a=n(1),c=n.n(a),s=n(6),o=n.n(s),i=n(3),r=n(2),b=n.n(r),u=n(0),d=function(e){var t=e.good,n=e.neutral,a=e.bad,c=e.total,s=e.positivePercentage;return Object(u.jsxs)("ul",{className:b.a.box,children:[Object(u.jsxs)("li",{className:b.a.options,children:[" Good:",t," "]}),Object(u.jsxs)("li",{className:b.a.options,children:[" Neutral:",n," "]}),Object(u.jsxs)("li",{className:b.a.options,children:[" Bad:",a," "]}),Object(u.jsxs)("li",{className:b.a.options,children:[" Total:",c," "]}),Object(u.jsxs)("li",{className:b.a.options,children:["Positive feedback: ",s,"%"]})]})},l=n(5),j=n.n(l),O=function(e){var t=e.options,n=e.onLeaveFeedback;return Object(u.jsx)("div",{className:j.a.buttonContainer,children:t.map((function(e){return Object(u.jsx)("button",{className:j.a.buttonContainerItem,type:"button","data-feedback":e,onClick:n,children:e},e)}))})};function h(e){var t=e.message;return Object(u.jsx)("p",{children:t})}var x=function(e){var t=e.title,n=e.children;return Object(u.jsxs)("section",{children:[Object(u.jsx)("h2",{children:t}),n]})},f=["good","neutral","bad"];function p(){var e=Object(a.useState)(0),t=Object(i.a)(e,2),n=t[0],c=t[1],s=Object(a.useState)(0),o=Object(i.a)(s,2),r=o[0],b=o[1],l=Object(a.useState)(0),j=Object(i.a)(l,2),p=j[0],k=j[1],m=n+r+p,v=function(){var e=100*n/m;return m?Math.round(e):0}();return Object(u.jsxs)(u.Fragment,{children:[Object(u.jsx)(x,{title:"Please leave feedback",children:Object(u.jsx)(O,{options:f,onLeaveFeedback:function(e){switch(e.target.dataset.feedback){case"good":c((function(e){return e+1}));break;case"neutral":b((function(e){return e+1}));break;case"bad":k((function(e){return e+1}));break;default:return}}})}),Object(u.jsxs)(x,{title:"Statistics",children:[m>0&&Object(u.jsx)(d,{good:n,neutral:r,bad:p,total:m,positivePercentage:v}),!m>0&&Object(u.jsx)(h,{message:"No feedback given"})]})]})}n(12);o.a.render(Object(u.jsx)(c.a.StrictMode,{children:Object(u.jsx)(p,{})}),document.getElementById("root"))},2:function(e,t,n){e.exports={box:"Statistics_box__1sasP",options:"Statistics_options__1t-4Q"}},5:function(e,t,n){e.exports={buttonContainer:"FeedbackOptions_buttonContainer__3soyM",buttonContainerItem:"FeedbackOptions_buttonContainerItem__2Q7yu"}}},[[13,1,2]]]);
  //# sourceMappingURL=main.b4565ac0.chunk.js.map