Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto scrolling upward when clicking on another apartment #300

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion frontend/src/components/Review/PropertyInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const useStyles = makeStyles({
card: {
borderRadius: '10px',
backgroundColor: colors.red6,
cursor: 'pointer', // Add cursor pointer to make it clickable
},
reviewNum: {
fontWeight: 700,
Expand All @@ -39,14 +40,26 @@ const PropertyCard = ({ buildingData, numReviews, company }: CardProps): ReactEl
const { id, name, address } = buildingData;
const [reviewData, setReviewData] = useState<ReviewWithId[]>([]);

/**
* Handles clicking on the Apartment card. Scrolls up on the window, upward
* to reach the top with a smooth behavior. The top is defined as 0 since this is
* where we want to reach.
*/
const handleCardClick = () => {
window.scrollTo({
top: 0,
behavior: 'smooth',
});
};

useEffect(() => {
get<ReviewWithId[]>(`/api/review/aptId/${id}/APPROVED`, {
callback: setReviewData,
});
}, [id]);

return (
<Card className={card}>
<Card className={card} onClick={handleCardClick}>
<CardContent>
<Grid container direction="row" alignItems="center">
<Grid item>
Expand Down
Loading