Skip to content

Commit

Permalink
Show report abuse button when user not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperL1218 committed Dec 4, 2024
1 parent 4b4b335 commit 65cc6f0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions frontend/src/components/Review/Review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,15 @@ const ReviewComponent = ({
setDeleteModalOpen(true);
};

const handleReportModalOpen = async () => {
if (user) {
setReportModalOpen(true);
} else {
let user = await getUser(true);
setUser(user);
}
};

/**
* handleReportModalClose - Handles the closing of the report modal and processes the report if confirmed.
*
Expand Down Expand Up @@ -583,7 +592,7 @@ const ReviewComponent = ({
const reportAbuseButton = () => {
return (
<Grid item>
<Button onClick={() => setReportModalOpen(true)} className={button} size="small">
<Button onClick={handleReportModalOpen} className={button} size="small">
Report Abuse
</Button>
</Grid>
Expand Down Expand Up @@ -701,11 +710,10 @@ const ReviewComponent = ({
{`Helpful (${review.likes})`}
</Button>
</Grid>
{user &&
review.userId &&
review.userId !== user?.uid &&
review.status !== 'PENDING' &&
reportAbuseButton()}
{/* If user is logged in and the review is not theirs, show report abuse button.
* If user is not logged in, show report abuse button.
*/}
{((user && review.userId && review.userId !== user?.uid) || !user) && reportAbuseButton()}
</Grid>
</CardActions>
{Modals}
Expand Down

0 comments on commit 65cc6f0

Please sign in to comment.