Skip to content

AdminReview

CasperL1218 edited this page Feb 25, 2025 · 4 revisions

AdminReview Component

Description

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.

Usage

Use the AdminReview component within administrative interfaces where review moderation is needed. The component fetches associated apartment and landlord data automatically when mounted.

Props Interface

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;
};

Example Usage

function AdminPage() {
  return (
    <AdminReviewComponent
      review={reviewData}
      setToggle={setToggleState}
      showDecline={true}
      showApprove={true}
      triggerPhotoCarousel={(photos, index) => handlePhotoDisplay(photos, index)}
    />
  );
}

Features

  • 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

Expected Behavior

Data Loading

  • Fetches apartment data if aptId is provided
  • Fetches landlord data using landlordId
  • Automatically loads on component mount

User Interaction

  • Clickable photos that trigger photo carousel
  • Administrative buttons that update review status
  • Links to apartment/landlord pages

Status Management

  • Status changes trigger parent component refresh via setToggle
  • Requires authenticated user for status changes
  • Supports multiple status types: APPROVED, DECLINED, DELETED

Edge Cases

  • Handles missing apartment/landlord data gracefully
  • Manages empty photo arrays
  • Handles missing bedroom/price information
  • Processes invalid dates
  • Manages authentication failures during status updates

Implementation Details

The component uses Material-UI for styling and layout, with custom styling applied through makeStyles.

Runtime Analysis

  • Component initialization: O(1)
  • Data fetching: O(n) - One API call for each review
  • Photo rendering: O(n) where n is number of photos
  • Status updates: O(1)
Clone this wiki locally