exercise 1.8 and 1.9
This commit is contained in:
parent
f9bfc61e6c
commit
3fa32ec57c
1 changed files with 34 additions and 15 deletions
|
|
@ -32,6 +32,39 @@ const App = () => {
|
|||
return good / computeTotalCount();
|
||||
};
|
||||
|
||||
const isThereAnyFeedback = () => {
|
||||
return computeTotalCount() !== 0;
|
||||
};
|
||||
|
||||
let feedbackSection;
|
||||
if (isThereAnyFeedback()) {
|
||||
feedbackSection = (
|
||||
<>
|
||||
<StatisticDisplay statisticName="good" statisticValue={good} />
|
||||
<StatisticDisplay statisticName="neutral" statisticValue={neutral} />
|
||||
<StatisticDisplay statisticName="bad" statisticValue={bad} />
|
||||
<StatisticDisplay
|
||||
statisticName="count"
|
||||
statisticValue={computeTotalCount()}
|
||||
/>
|
||||
<StatisticDisplay
|
||||
statisticName="average"
|
||||
statisticValue={computeAverage()}
|
||||
/>
|
||||
<StatisticDisplay
|
||||
statisticName="positive"
|
||||
statisticValue={computePercentagePositive() * 100 + "%"}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
feedbackSection = (
|
||||
<>
|
||||
<p>No feedback given.</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Header headerText="give feedback" />
|
||||
|
|
@ -54,21 +87,7 @@ const App = () => {
|
|||
buttonText="bad"
|
||||
/>
|
||||
<Header headerText="statistics" />
|
||||
<StatisticDisplay statisticName="good" statisticValue={good} />
|
||||
<StatisticDisplay statisticName="neutral" statisticValue={neutral} />
|
||||
<StatisticDisplay statisticName="bad" statisticValue={bad} />
|
||||
<StatisticDisplay
|
||||
statisticName="count"
|
||||
statisticValue={computeTotalCount()}
|
||||
/>
|
||||
<StatisticDisplay
|
||||
statisticName="average"
|
||||
statisticValue={computeAverage()}
|
||||
/>
|
||||
<StatisticDisplay
|
||||
statisticName="positive"
|
||||
statisticValue={computePercentagePositive() * 100 + "%"}
|
||||
/>
|
||||
{feedbackSection}
|
||||
</div>
|
||||
);
|
||||
// Buttons
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue