Skip to content

Commit

Permalink
Move maximum rating in feedback from 10 to 5 [Fixes #990] (#987)
Browse files Browse the repository at this point in the history
* Move maximum rating in feedbacks from 10 to 5

* Fix failing tests
  • Loading branch information
EshaanAgg authored Oct 14, 2023
1 parent 12f210b commit 18e6ed9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Testing Average Rating Card', () => {
);

await waitFor(() =>
expect(queryByText('Rated 5.00 / 10')).toBeInTheDocument()
expect(queryByText('Rated 5.00 / 5')).toBeInTheDocument()
);
});
});
6 changes: 3 additions & 3 deletions src/components/EventStats/Statistics/AverageRating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type ModalPropType = {
data: {
event: {
_id: string;
averageFeedbackScore: number | null;
averageFeedbackScore: number;
feedback: FeedbackType[];
};
};
Expand Down Expand Up @@ -41,12 +41,12 @@ export const AverageRating = ({ data }: ModalPropType): JSX.Element => {
<h4>Average Review Score</h4>
</Card.Title>
<Typography component="legend">
Rated {(data.event.averageFeedbackScore || 0).toFixed(2)} / 10
Rated {data.event.averageFeedbackScore.toFixed(2)} / 5
</Typography>
<StyledRating
name="customized-color"
precision={0.5}
max={10}
max={5}
readOnly
value={data.event.averageFeedbackScore}
icon={<FavoriteIcon fontSize="inherit" />}
Expand Down
9 changes: 2 additions & 7 deletions src/components/EventStats/Statistics/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@ type FeedbackType = {
export const FeedbackStats = ({ data }: ModalPropType): JSX.Element => {
const ratingColors = [
'#57bb8a', // Green
'#73b87e',
'#94bd77',
'#b0be6e',
'#d4c86a',
'#f5ce62',
'#e9b861',
'#ecac67',
'#e79a69',
'#e2886c',
'#dd776e', // Red
];

Expand All @@ -45,13 +40,13 @@ export const FeedbackStats = ({ data }: ModalPropType): JSX.Element => {
});

const chartData = [];
for (let rating = 0; rating <= 10; rating++) {
for (let rating = 0; rating <= 5; rating++) {
if (rating in count)
chartData.push({
id: rating,
value: count[rating],
label: `${rating} (${count[rating]})`,
color: ratingColors[10 - rating],
color: ratingColors[5 - rating],
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/EventStats/Statistics/Review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const ReviewStats = ({ data }: ModalPropType): JSX.Element => {
reviews.map((review) => (
<div className="card user-review m-1" key={review._id}>
<div className="card-body">
<Rating name="read-only" value={review.rating / 2} readOnly />
<Rating name="read-only" value={review.rating} readOnly />
<p className="card-text">{review.review}</p>
</div>
</div>
Expand Down

0 comments on commit 18e6ed9

Please sign in to comment.