diff --git a/parts/1/notes.md b/parts/1/notes.md index 9767352..dfe47dc 100644 --- a/parts/1/notes.md +++ b/parts/1/notes.md @@ -12,7 +12,7 @@ Exercises: * [X] 1.8 * [X] 1.9 * [X] 1.10 -* [ ] 1.11 +* [X] 1.11 * [ ] 1.12 * [ ] 1.13 * [ ] 1.14 diff --git a/parts/1/uniCafe/src/App.jsx b/parts/1/uniCafe/src/App.jsx index 7155b64..6d84222 100644 --- a/parts/1/uniCafe/src/App.jsx +++ b/parts/1/uniCafe/src/App.jsx @@ -8,16 +8,50 @@ const Button = (props) => { return ; }; -const StatisticDisplay = (props) => { +const StatisticsTable = (props) => { + if (props.isThereAnyFeedback) { + return ( + <> + + + + + + + + + +
+ + ); + } else { + return ( + <> +

No feedback given.

+ + ); + } +} + +const StatisticTableRowDisplay = (props) => { return ( -

- {props.statisticName} {props.statisticValue} -

+ + {props.statisticName} + {props.statisticValue} + ); }; const App = () => { - // save clicks of each button to its own state const [good, setGood] = useState(0); const [neutral, setNeutral] = useState(0); const [bad, setBad] = useState(0); @@ -36,33 +70,14 @@ const App = () => { return computeTotalCount() !== 0; }; - let feedbackSection; - if (isThereAnyFeedback()) { - feedbackSection = ( - <> - - - - - - - - ); - } else { - feedbackSection = ( - <> -

No feedback given.

- - ); + const feedbackStatisticsSnapshot = { + good: good, + neutral: neutral, + bad: bad, + totalCount: computeTotalCount(), + average: computeAverage(), + percentagePositive: computePercentagePositive(), + isThereAnyFeedback: isThereAnyFeedback() } return ( @@ -87,7 +102,8 @@ const App = () => { buttonText="bad" />
- {feedbackSection} + + ); // Buttons