From c468372a19542eec194ff9d4882f2a87c3ae6c72 Mon Sep 17 00:00:00 2001 From: Cyrus Irani Date: Sun, 22 Oct 2023 13:54:55 -0400 Subject: [PATCH 1/8] migrating changes --- frontend/src/colors.js | 1 + .../src/components/Review/ReviewHeader.tsx | 2 +- .../utils/LabeledLinearProgress.tsx | 57 ++++-- frontend/src/pages/ApartmentPage.tsx | 179 +++++++++--------- 4 files changed, 133 insertions(+), 106 deletions(-) diff --git a/frontend/src/colors.js b/frontend/src/colors.js index 3569e748..d8447c4d 100644 --- a/frontend/src/colors.js +++ b/frontend/src/colors.js @@ -9,6 +9,7 @@ export const colors = { gray1: '#5D5D5D', gray2: '#898989', gray3: '#F9F9F9', + gray4: '#C4C4C4', white: '#FFFFFF', landlordCardRed: '#F3664B', green1: '#68BB59', diff --git a/frontend/src/components/Review/ReviewHeader.tsx b/frontend/src/components/Review/ReviewHeader.tsx index 4e75c1d5..18361a0d 100644 --- a/frontend/src/components/Review/ReviewHeader.tsx +++ b/frontend/src/components/Review/ReviewHeader.tsx @@ -20,7 +20,7 @@ export default function ReviewHeader({ aveRatingInfo }: Props): ReactElement { {feature.charAt(0).toUpperCase() + feature.slice(1)} - + diff --git a/frontend/src/components/utils/LabeledLinearProgress.tsx b/frontend/src/components/utils/LabeledLinearProgress.tsx index a9f10ec8..900b9f14 100644 --- a/frontend/src/components/utils/LabeledLinearProgress.tsx +++ b/frontend/src/components/utils/LabeledLinearProgress.tsx @@ -1,8 +1,6 @@ import React, { ReactElement } from 'react'; -import Box from '@material-ui/core/Box'; -import LinearProgress from '@material-ui/core/LinearProgress'; +import { colors } from '../../colors'; import Typography from '@material-ui/core/Typography'; -import styles from '../Review/Review.module.scss'; import { makeStyles } from '@material-ui/core'; type Props = { @@ -10,25 +8,48 @@ type Props = { }; const useStyles = makeStyles((theme) => ({ - bar: { - width: '90%', + barContainer: { + display: 'flex', + alignItems: 'center', + }, + barSegment: { + flex: 1, + height: '8px', // Adjust the height as needed + borderRadius: '4px', // Adjust the border radius as needed + marginRight: '4px', // Add a small gap between segments + }, + aveRating: { + marginLeft: '8px', // Add spacing between the segments and the rating }, })); export default function LabeledLinearProgress({ value }: Props): ReactElement { - const { bar } = useStyles(); + const { barContainer, barSegment, aveRating } = useStyles(); + let rating_value = value * 2; + rating_value = Math.round(rating_value); + rating_value = rating_value / 2 - 1; + console.log(rating_value); + const segments = Array.from({ length: 5 }, (_, index) => ( +
rating_value && rating_value + 0.5 === index + ? `linear-gradient(to right, ${colors.red1} 0%, ${colors.red1} 50%, ${colors.gray4} 50%, ${colors.gray4} 100%)` + : colors.gray4, + }} + >
+ )); + return ( - - - - - - {`${value.toFixed(1)}`} - - +
+ {segments} + + {`${value.toFixed(1)}`} + +
); } diff --git a/frontend/src/pages/ApartmentPage.tsx b/frontend/src/pages/ApartmentPage.tsx index cef77917..67a5d25e 100644 --- a/frontend/src/pages/ApartmentPage.tsx +++ b/frontend/src/pages/ApartmentPage.tsx @@ -156,10 +156,9 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { } }, [isMobile, reviewData.length]); - // Increase the number of results to show when the "Show More" button is clicked. - const handleShowMore = () => { - setResultsToShow(resultsToShow + 5); - }; + // const handleShowMore = () => { + // setResultsToShow(resultsToShow + 5); + // }; // Set 'notFound' to true when a page is not found. const handlePageNotFound = () => { @@ -176,7 +175,6 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { container, expand, expandOpen, - horizontalLine, } = useStyles(); // Set the page title based on whether apartment data is loaded. @@ -364,9 +362,11 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { ); const Header = ( + // Header section with review count, average rating, and leave review button + <> - + Reviews ({reviewData.length}) {reviewData.length === 0 && ( @@ -375,7 +375,7 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { {reviewData.length > 0 && ( - + @@ -388,6 +388,18 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { )} + + + + {landlordData && landlordData.photos.length > 0 && ( @@ -403,42 +415,8 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { - - - - - - - Sort by: - - - { - setSortBy('date'); - }, - }, - { - item: 'Helpful', - callback: () => { - setSortBy('likes'); - }, - }, - ]} - /> - - - + + @@ -560,9 +538,8 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { ); - const InfoSection = landlordData && ( - + { ); return notFound ? ( + // Display Not Found page if the apartment is not found ) : !loaded ? ( + // Display Not Found page if the apartment is not found ) : ( + // Display Not Found page if the apartment is not found <> {landlordData && ( @@ -591,7 +571,7 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { - + {isMobile ? MobileHeader : Header} {!isMobile && {InfoSection}} {showConfirmation && ( @@ -610,51 +590,76 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { time={toastTime} /> )} - - {sortReviews(reviewData, sortBy) - .slice(0, resultsToShow) - .map((review, index) => ( - - + + + {!isMobile && ( + + + Sort by: + + + { + setSortBy('date'); + }, + }, + { + item: 'Helpful', + callback: () => { + setSortBy('likes'); + }, + }, + ]} + /> + - ))} - - - {isMobile && reviewData.length > resultsToShow && ( - - -
+ )} + {/* Rest of your Review List content */} + + {sortReviews(reviewData, sortBy) + .slice(0, resultsToShow) + .map((review, index) => ( + + + + ))} - - + + + {/* Second Grid item (InfoSection) */} + {isMobile && ( + + + {InfoSection} + + + )} + + + {InfoSection} -
- )} + +
- {isMobile && {InfoSection}} - {InfoSection}
{Modals} From fc7e186bad2ca415e13724d85d42ddebd9d0f7c5 Mon Sep 17 00:00:00 2001 From: Cyrus Irani Date: Sun, 22 Oct 2023 15:02:40 -0400 Subject: [PATCH 2/8] specification --- .../src/components/utils/LabeledLinearProgress.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/src/components/utils/LabeledLinearProgress.tsx b/frontend/src/components/utils/LabeledLinearProgress.tsx index 900b9f14..2f6521bc 100644 --- a/frontend/src/components/utils/LabeledLinearProgress.tsx +++ b/frontend/src/components/utils/LabeledLinearProgress.tsx @@ -30,6 +30,18 @@ export default function LabeledLinearProgress({ value }: Props): ReactElement { rating_value = rating_value / 2 - 1; console.log(rating_value); const segments = Array.from({ length: 5 }, (_, index) => ( + /** + * This JSX code represents a rendering of a bar segment for a rating display. The rating value is used to determine the visual appearance of the segment. + * + * @param {number} index - The index of the segment within the rating bar. + * @param {string} barSegment - The CSS class name for styling the segment. + * @param {number} rating_value - The rating value to be displayed. + * + * The background style of the div is set based on the index and rating value: + * - If the index is less than or equal to the rating_value, the background is set to colors.red1. + * - If the index is greater than the rating_value and is exactly 0.5 more than the rating_value, a gradient background is applied. The gradient transitions from colors.red1 to colors.gray4, creating a partial fill effect. + * - For all other cases, the background is set to colors.gray4. + */
Date: Mon, 6 Nov 2023 16:15:03 -0500 Subject: [PATCH 3/8] fixed precentage of segment --- .../components/utils/LabeledLinearProgress.tsx | 15 +++++++++------ frontend/src/pages/ApartmentPage.tsx | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/utils/LabeledLinearProgress.tsx b/frontend/src/components/utils/LabeledLinearProgress.tsx index 2f6521bc..12e93a0a 100644 --- a/frontend/src/components/utils/LabeledLinearProgress.tsx +++ b/frontend/src/components/utils/LabeledLinearProgress.tsx @@ -25,10 +25,8 @@ const useStyles = makeStyles((theme) => ({ export default function LabeledLinearProgress({ value }: Props): ReactElement { const { barContainer, barSegment, aveRating } = useStyles(); - let rating_value = value * 2; - rating_value = Math.round(rating_value); - rating_value = rating_value / 2 - 1; - console.log(rating_value); + let rating_value = value - 1; + const segments = Array.from({ length: 5 }, (_, index) => ( /** * This JSX code represents a rendering of a bar segment for a rating display. The rating value is used to determine the visual appearance of the segment. @@ -42,6 +40,9 @@ export default function LabeledLinearProgress({ value }: Props): ReactElement { * - If the index is greater than the rating_value and is exactly 0.5 more than the rating_value, a gradient background is applied. The gradient transitions from colors.red1 to colors.gray4, creating a partial fill effect. * - For all other cases, the background is set to colors.gray4. */ + /** + * Make it so the segments fill, and when there is a decimal leftover, the segment gets filled to that decimal. + */
rating_value && rating_value + 0.5 === index - ? `linear-gradient(to right, ${colors.red1} 0%, ${colors.red1} 50%, ${colors.gray4} 50%, ${colors.gray4} 100%)` + : index > rating_value && index - 1 < rating_value + ? `linear-gradient(to right, ${colors.red1} ${(rating_value - index + 1 / 1) * 100}%, ${ + colors.gray4 + } 0%)` : colors.gray4, }} >
diff --git a/frontend/src/pages/ApartmentPage.tsx b/frontend/src/pages/ApartmentPage.tsx index 67a5d25e..117769ce 100644 --- a/frontend/src/pages/ApartmentPage.tsx +++ b/frontend/src/pages/ApartmentPage.tsx @@ -570,7 +570,7 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { )} - + {isMobile ? MobileHeader : Header} {!isMobile && {InfoSection}} From 93a853c843fbacb8e093e8f9804cdfab9bfe7c35 Mon Sep 17 00:00:00 2001 From: Cyrus Irani Date: Tue, 7 Nov 2023 13:50:57 -0500 Subject: [PATCH 4/8] adjust spacing --- frontend/src/pages/ApartmentPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/ApartmentPage.tsx b/frontend/src/pages/ApartmentPage.tsx index 117769ce..20f2453d 100644 --- a/frontend/src/pages/ApartmentPage.tsx +++ b/frontend/src/pages/ApartmentPage.tsx @@ -422,7 +422,7 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { {reviewData && reviewData.length > 0 && ( - + )} @@ -570,7 +570,7 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { )} - + {isMobile ? MobileHeader : Header} {!isMobile && {InfoSection}} From 6b88cfec5d7d08921ae293abe02363179192865a Mon Sep 17 00:00:00 2001 From: Cyrus Irani Date: Fri, 10 Nov 2023 14:49:38 -0500 Subject: [PATCH 5/8] fixed bug --- frontend/src/pages/ApartmentPage.tsx | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/frontend/src/pages/ApartmentPage.tsx b/frontend/src/pages/ApartmentPage.tsx index c1e136da..7075941a 100644 --- a/frontend/src/pages/ApartmentPage.tsx +++ b/frontend/src/pages/ApartmentPage.tsx @@ -550,13 +550,10 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { ); return notFound ? ( - // Display Not Found page if the apartment is not found ) : !loaded ? ( - // Display Not Found page if the apartment is not found ) : ( - // Display Not Found page if the apartment is not found <> {landlordData && ( @@ -623,33 +620,16 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { ]} /> - - - {sortReviews(reviewData, sortBy) - .slice(0, resultsToShow) - .map((review, index) => ( - - - )} - {/* Rest of your Review List content */} - + + {sortReviews(reviewData, sortBy) .slice(0, resultsToShow) .map((review, index) => ( Date: Mon, 13 Nov 2023 15:33:02 -0500 Subject: [PATCH 6/8] fixed bug --- frontend/src/components/utils/LabeledLinearProgress.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/utils/LabeledLinearProgress.tsx b/frontend/src/components/utils/LabeledLinearProgress.tsx index 12e93a0a..c6c835a7 100644 --- a/frontend/src/components/utils/LabeledLinearProgress.tsx +++ b/frontend/src/components/utils/LabeledLinearProgress.tsx @@ -63,7 +63,7 @@ export default function LabeledLinearProgress({ value }: Props): ReactElement {
{segments} - {`${value.toFixed(1)}`} + {value !== null && value !== undefined ? value.toFixed(1) : ''}
); From 23f5e4df71911ec1493173e43fc7e853ab7f7a75 Mon Sep 17 00:00:00 2001 From: Cyrus Irani Date: Mon, 13 Nov 2023 16:08:09 -0500 Subject: [PATCH 7/8] fixed sizing --- frontend/src/components/Review/ReviewHeader.tsx | 14 +++++++++++++- frontend/src/pages/ApartmentPage.tsx | 4 ---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Review/ReviewHeader.tsx b/frontend/src/components/Review/ReviewHeader.tsx index 18361a0d..a81a1d5e 100644 --- a/frontend/src/components/Review/ReviewHeader.tsx +++ b/frontend/src/components/Review/ReviewHeader.tsx @@ -3,12 +3,24 @@ import { Grid, Typography } from '@material-ui/core'; import styles from './Review.module.scss'; import LabeledLinearProgress from '../utils/LabeledLinearProgress'; import { RatingInfo } from '../../pages/LandlordPage'; +import { useEffect, useState } from 'react'; type Props = { readonly aveRatingInfo: RatingInfo[]; }; export default function ReviewHeader({ aveRatingInfo }: Props): ReactElement { + const [isMobile, setIsMobile] = useState(false); + + useEffect(() => { + const handleResize = () => { + setIsMobile(window.innerWidth <= 750); + }; + handleResize(); + window.addEventListener('resize', handleResize); + return () => window.removeEventListener('resize', handleResize); + }, []); + return (
@@ -20,7 +32,7 @@ export default function ReviewHeader({ aveRatingInfo }: Props): ReactElement { {feature.charAt(0).toUpperCase() + feature.slice(1)} - + diff --git a/frontend/src/pages/ApartmentPage.tsx b/frontend/src/pages/ApartmentPage.tsx index 7075941a..05390e3b 100644 --- a/frontend/src/pages/ApartmentPage.tsx +++ b/frontend/src/pages/ApartmentPage.tsx @@ -156,10 +156,6 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { } }, [isMobile, reviewData.length]); - // const handleShowMore = () => { - // setResultsToShow(resultsToShow + 5); - // }; - // Set 'notFound' to true when a page is not found. const handlePageNotFound = () => { setNotFound(true); From 7d0eb92095a02aaf0fc8095094ebf411cd18b8a6 Mon Sep 17 00:00:00 2001 From: thuypham03 Date: Mon, 13 Nov 2023 18:48:44 -0500 Subject: [PATCH 8/8] size of landlord info --- frontend/src/pages/ApartmentPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/ApartmentPage.tsx b/frontend/src/pages/ApartmentPage.tsx index e765b796..a08afffb 100644 --- a/frontend/src/pages/ApartmentPage.tsx +++ b/frontend/src/pages/ApartmentPage.tsx @@ -535,7 +535,7 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { ); const InfoSection = landlordData && ( - + Landlord