Skip to content

Commit

Permalink
Move maximum rating in feedbacks from 10 to 5
Browse files Browse the repository at this point in the history
  • Loading branch information
EshaanAgg committed Oct 11, 2023
1 parent 12f210b commit e6bf83d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
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 e6bf83d

Please sign in to comment.