diff --git a/src/components/App.jsx b/src/components/App.jsx
index 4bd5c32..19a4337 100644
--- a/src/components/App.jsx
+++ b/src/components/App.jsx
@@ -11,12 +11,27 @@ export class App extends Component {
bad: 0,
};
+ handleFeedback = e => {
+ if (e === 'Good') {
+ this.setState({ good: this.state.good + 1 });
+ } else if (e === 'Neutral') {
+ this.setState({ neutral: this.state.neutral + 1 });
+ } else if (e === 'Bad') {
+ this.setState({ bad: this.state.bad + 1 });
+ }
+ };
+
countTotalFeedback = () => {
let total = this.state.good + this.state.neutral + this.state.bad;
return total;
};
- countPositiveFeedbackPercentage = () => {};
+ countPositiveFeedbackPercentage = () => {
+ if (this.countTotalFeedback() === 0) {
+ return 0;
+ }
+ return Math.round((this.state.good / this.countTotalFeedback()) * 100);
+ };
render() {
return (
@@ -24,6 +39,7 @@ export class App extends Component {
style={{
height: '100vh',
display: 'flex',
+ flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
fontSize: 40,
@@ -31,11 +47,24 @@ export class App extends Component {
}}
>