-
Notifications
You must be signed in to change notification settings - Fork 3
AdminReview
CasperL1218 edited this page Feb 25, 2025
·
4 revisions
The AdminReview component displays a review card with administrative controls for managing review content. It shows detailed review information including ratings, text content, photos, and associated apartment/landlord details, along with buttons for administrators to approve, decline, delete, or ignore reviews.
Use the AdminReview component within administrative interfaces where review moderation is needed. The component fetches associated apartment and landlord data automatically when mounted.
type Props = {
/** The review to be displayed */
readonly review: ReviewWithId;
/** Function to toggle the display */
readonly setToggle: React.Dispatch<React.SetStateAction<boolean>>;
/** Indicates whether to show decline button */
readonly showDecline?: boolean;
/** Indicates whether to show delete button */
readonly showDelete?: boolean;
/** Indicates whether to show ignore button for reported reviews */
readonly showIgnore?: boolean;
/** Indicates whether to show approve button for pending reviews */
readonly showApprove?: boolean;
/** Function to trigger the photo carousel */
readonly triggerPhotoCarousel: (photos: readonly string[], startIndex: number) => void;
};function AdminPage() {
return (
<AdminReviewComponent
review={reviewData}
setToggle={setToggleState}
showDecline={true}
showApprove={true}
triggerPhotoCarousel={(photos, index) => handlePhotoDisplay(photos, index)}
/>
);
}- Displays overall rating with heart icons
- Shows detailed ratings for specific features (location, safety, value, etc.)
- Presents review text and associated photos
- Links to apartment/landlord pages
- Shows bedroom count and price range
- Provides administrative action buttons based on props
- Supports photo carousel integration
- Displays formatted date of review
- Fetches apartment data if
aptIdis provided - Fetches landlord data using landlordId
- Automatically loads on component mount
- Clickable photos that trigger photo carousel
- Administrative buttons that update review status
- Links to apartment/landlord pages
- Status changes trigger parent component refresh via setToggle
- Requires authenticated user for status changes
- Supports multiple status types:
APPROVED,DECLINED,DELETED
- Handles missing apartment/landlord data gracefully
- Manages empty photo arrays
- Handles missing bedroom/price information
- Processes invalid dates
- Manages authentication failures during status updates
The component uses Material-UI for styling and layout, with custom styling applied through makeStyles.
- Component initialization: O(1)
- Data fetching: O(1) - Single API call each for apartment and landlord
- Photo rendering: O(n) where n is number of photos
- Status updates: O(1)