Skip to content

Commit

Permalink
apartmentPage redesign to fit figma
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrus14 committed Oct 2, 2023
1 parent 96d095b commit 9d0e2db
Showing 1 changed file with 83 additions and 80 deletions.
163 changes: 83 additions & 80 deletions frontend/src/pages/ApartmentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => {
const Header = (
<>
<Grid container alignItems="center">
<Grid container spacing={1}>
<Grid container alignItems="center" justifyContent="space-between">
<Grid item>
<Typography variant="h6">Reviews ({reviewData.length})</Typography>
{reviewData.length === 0 && (
Expand All @@ -362,6 +362,18 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => {
</Grid>
</Grid>
)}

<Grid item style={{ marginLeft: 'auto' }}>
<Button
color="primary"
className={reviewButton}
variant="contained"
disableElevation
onClick={openReviewModal}
>
Leave a Review
</Button>
</Grid>
</Grid>

{landlordData && landlordData.photos.length > 0 && (
Expand All @@ -377,42 +389,8 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => {

<Grid item className={leaveReviewContainer} xs={12}>
<Grid container spacing={1} alignItems="center" justifyContent="space-between">
<Grid item>
<Button
color="primary"
className={reviewButton}
variant="contained"
disableElevation
onClick={openReviewModal}
>
Leave a Review
</Button>
</Grid>
<Grid item>
<Grid container spacing={1} direction="row" alignItems="center">
<Grid item>
<Typography>Sort by:</Typography>
</Grid>
<Grid item className={sortByButton}>
<DropDown
menuItems={[
{
item: 'Recent',
callback: () => {
setSortBy('date');
},
},
{
item: 'Helpful',
callback: () => {
setSortBy('likes');
},
},
]}
/>
</Grid>
</Grid>
</Grid>
<Grid item></Grid>
<Grid item></Grid>
</Grid>
</Grid>
</Grid>
Expand Down Expand Up @@ -535,7 +513,7 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => {
</>
);
const InfoSection = landlordData && (
<Grid item xs={12} sm={4}>
<Grid item xs={12}>
<AptInfo
landlord={landlordData.name}
contact={landlordData.contact}
Expand Down Expand Up @@ -564,7 +542,7 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => {

<Container className={container}>
<Grid container spacing={5} justifyContent="center" style={{ marginBottom: '20px' }}>
<Grid item xs={12} sm={8}>
<Grid item xs={12}>
{isMobile ? MobileHeader : Header}
{!isMobile && <Hidden smUp>{InfoSection}</Hidden>}
{showConfirmation && (
Expand All @@ -583,51 +561,76 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => {
time={toastTime}
/>
)}
<Grid container item spacing={3}>
{sortReviews(reviewData, sortBy)
.slice(0, resultsToShow)
.map((review, index) => (
<Grid item xs={12} key={index}>
<ReviewComponent
review={review}
liked={likedReviews[review.id]}
likeLoading={likeStatuses[review.id]}
addLike={addLike}
removeLike={removeLike}
setToggle={setToggle}
user={user}
setUser={setUser}
/>
<Grid container alignItems="flex-start" justifyContent="center" spacing={3}>
<Grid item xs={12} sm={8}>
{!isMobile && (
<Grid
container
spacing={1}
direction="row"
alignItems="center"
justifyContent="flex-end"
style={{ paddingBottom: '10px' }}
>
<Grid item>
<Typography>Sort by:</Typography>
</Grid>
<Grid item className={sortByButton}>
<DropDown
menuItems={[
{
item: 'Recent',
callback: () => {
setSortBy('date');
},
},
{
item: 'Helpful',
callback: () => {
setSortBy('likes');
},
},
]}
/>
</Grid>
</Grid>
))}
</Grid>

{isMobile && reviewData.length > resultsToShow && (
<Box textAlign="center">
<Grid item xs={12}>
<hr className={horizontalLine} />
)}
{/* Rest of your Review List content */}
<Grid container spacing={3}>
{sortReviews(reviewData, sortBy)
.slice(0, resultsToShow)
.map((review, index) => (
<Grid item xs={12} key={index}>
<ReviewComponent
review={review}
liked={likedReviews[review.id]}
likeLoading={likeStatuses[review.id]}
addLike={addLike}
removeLike={removeLike}
setToggle={setToggle}
user={user}
setUser={setUser}
/>
</Grid>
))}
</Grid>
<Grid item style={{ padding: '30px' }}>
<Button
style={{
backgroundColor: 'white',
border: '1px solid #A3A3A3',
borderRadius: '9px',
width: '10em',
textTransform: 'initial',
}}
variant="contained"
disableElevation
onClick={handleShowMore}
>
Show More
</Button>
</Grid>

{/* Second Grid item (InfoSection) */}
{isMobile && (
<Hidden smUp>
<Grid item xs={12}>
{InfoSection}
</Grid>
</Hidden>
)}
<Hidden xsDown>
<Grid item xs={4}>
{InfoSection}
</Grid>
</Box>
)}
</Hidden>
</Grid>
</Grid>
{isMobile && <Hidden smUp>{InfoSection}</Hidden>}
<Hidden xsDown>{InfoSection}</Hidden>
</Grid>
</Container>
{Modals}
Expand Down

0 comments on commit 9d0e2db

Please sign in to comment.