Skip to content

Commit

Permalink
Merge branch 'main' into add-price-bedroom-attr
Browse files Browse the repository at this point in the history
  • Loading branch information
ggsawatyanon authored Apr 22, 2024
2 parents fc4dbaf + 6751b38 commit c85295d
Show file tree
Hide file tree
Showing 16 changed files with 718 additions and 227 deletions.
2 changes: 2 additions & 0 deletions backend/scripts/add_reviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const formatReview = (data: any): Review => ({
aptId: data.aptId.toString(),
reviewText: data.reviewText,
overallRating: data.overallRating,
bedrooms: data.bedrooms,
price: data.price,
detailedRatings: {
location: data['detailedRatings.location'],
safety: data['detailedRatings.safety'],
Expand Down
2 changes: 2 additions & 0 deletions backend/scripts/add_reviews_nodups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const formatReview = (data: any): Review => ({
aptId: data.aptId === null ? null : data.aptId.toString(),
reviewText: data.reviewText,
overallRating: data.overallRating,
bedrooms: data.bedrooms,
price: data.price,
detailedRatings: {
location: data['detailedRatings.location'],
safety: data['detailedRatings.safety'],
Expand Down
4 changes: 2 additions & 2 deletions common/types/db-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export type Review = {
readonly date: Date;
readonly detailedRatings: DetailedRating;
readonly landlordId: string;
readonly bedrooms: number;
readonly price: number;
readonly overallRating: number;
readonly photos: readonly string[];
readonly reviewText: string;
readonly status?: 'PENDING' | 'APPROVED' | 'DECLINED' | 'DELETED';
readonly userId?: string | null;
readonly price?: number;
readonly bedrooms?: number;
};

export type ReviewWithId = Review & Id;
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/assets/bed-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/src/assets/money-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/src/assets/xIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 21 additions & 2 deletions frontend/src/components/Admin/AdminReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { get } from '../../utils/call';
import { Link as RouterLink } from 'react-router-dom';
import ReviewHeader from '../Review/ReviewHeader';
import axios from 'axios';
import getPriceRange from '../../utils/priceRange';
import { createAuthHeaders, getUser } from '../../utils/firebase';

/**
Expand Down Expand Up @@ -55,6 +56,12 @@ const useStyles = makeStyles(() => ({
dateText: {
color: colors.gray1,
},
bedroomsPriceText: {
marginTop: '10px',
marginBottom: '10px',
display: 'flex',
gap: '30px',
},
ratingInfo: {
marginTop: '10px',
marginBottom: '30px',
Expand All @@ -81,9 +88,9 @@ const useStyles = makeStyles(() => ({
* @returns The rendered component.
*/
const AdminReviewComponent = ({ review, setToggle, declinedSection }: Props): ReactElement => {
const { detailedRatings, overallRating, date, reviewText, photos } = review;
const { detailedRatings, overallRating, bedrooms, price, date, reviewText, photos } = review;
const formattedDate = format(new Date(date), 'MMM dd, yyyy').toUpperCase();
const { root, dateText, ratingInfo, photoStyle, photoRowStyle } = useStyles();
const { root, dateText, bedroomsPriceText, ratingInfo, photoStyle, photoRowStyle } = useStyles();
const [apt, setApt] = useState<ApartmentWithId[]>([]);
const [landlord, setLandlord] = useState<Landlord>();

Expand Down Expand Up @@ -172,6 +179,18 @@ const AdminReviewComponent = ({ review, setToggle, declinedSection }: Props): Re
<Typography className={dateText}>{formattedDate}</Typography>
</Grid>

<Grid item xs={12} className={bedroomsPriceText}>
{bedrooms > 0 && (
<Typography style={{ fontWeight: '600' }}>Bedroom(s): {bedrooms}</Typography>
)}
{price > 0 && (
<Typography style={{ fontWeight: '600' }}>
{' '}
Price: {getPriceRange(price) || 0}
</Typography>
)}
</Grid>

<Grid item xs={12} className={ratingInfo}>
<ReviewHeader aveRatingInfo={getRatingInfo(detailedRatings)} />
</Grid>
Expand Down
Loading

0 comments on commit c85295d

Please sign in to comment.