Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

[Client] Reviews Display - Completed #90

Merged
merged 10 commits into from
Nov 18, 2023
Merged

Conversation

Cassianky
Copy link
Owner

@Cassianky Cassianky commented Nov 16, 2023

  • Filter activities by ratings
    image
  • Completed UI of reviews on activity details page
    image

@Cassianky
Copy link
Owner Author

Cassianky commented Nov 17, 2023

Completed reviews

image

@Cassianky Cassianky linked an issue Nov 17, 2023 that may be closed by this pull request
7 tasks
@Cassianky Cassianky changed the title [Client] Reviews Display [Client] Reviews Display - Completed Nov 17, 2023
@ayangler ayangler self-requested a review November 18, 2023 05:29
],
});

if (foundActivity.reviews.length > 0 && foundActivity.reviews) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall! One thing is that the admin can hide reviews from the activity page in the admin FE
image

Once an admin hides a review I feel we can exclude it from calculation?
Maybe something like this will work

      if (foundActivity.reviews.length > 0 && foundActivity.reviews) {
        const visibleReviews = foundActivity.reviews.filter(review => !review.hidden);
      
        if (visibleReviews.length > 0) {
          const totalRatings = visibleReviews.reduce(
            (sum, review) => sum + review.rating,
            0
          );
          foundActivity.averageRating = totalRatings / visibleReviews.length;
        } else {
          foundActivity.averageRating = 0;
        }
      
        for (const review of visibleReviews) {
          let preSignedPhoto = await s3GetImages(review.client.photo);
          review.client.preSignedPhoto = preSignedPhoto;
        }

        foundActivity.reviews = visibleReviews
      } else {
        foundActivity.averageRating = 0;
      }

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okie resolved

select: "-booking",
});

function findAverageRating(activity) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async function findAverageRating(activity) {
  if (activity.reviews && activity.reviews.length > 0) {
    const visibleReviews = activity.reviews.filter(review => !review.hidden);

    if (visibleReviews.length > 0) {
      const totalRatings = visibleReviews.reduce(
        (sum, review) => sum + review.rating,
        0
      );
      return totalRatings / visibleReviews.length;
    } else {
      return 0;
    }
  } else {
    return 0;
  }
}

if you're using the nested reviews here as well prolly need to update the attribute to the actual visibleReviews

@Cassianky Cassianky merged commit d2367f4 into develop Nov 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Client] A.5 Booking Management View Reviews of an Activity
2 participants