From 0f21d2afff875089616d008e2493acf28891af98 Mon Sep 17 00:00:00 2001 From: Ankit Lakkapragada Date: Sun, 24 Sep 2023 16:19:35 -0400 Subject: [PATCH] Implement Delete Button to Admin Page --- backend/src/app.ts | 2 +- frontend/src/components/Admin/AdminReview.tsx | 14 +++++++++++++- frontend/src/pages/AdminPage.tsx | 12 ++++++++++-- yarn.lock | 6 +++--- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/backend/src/app.ts b/backend/src/app.ts index a7a3613a..51ba7aba 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -300,7 +300,7 @@ app.post('/api/remove-like', authenticate, likeHandler(true)); app.put('/api/update-review-status/:reviewDocId/:newStatus', async (req, res) => { const { reviewDocId, newStatus } = req.params; - const statusList = ['PENDING', 'APPROVED', 'DECLINED']; + const statusList = ['PENDING', 'APPROVED', 'DECLINED', 'DELETED']; try { if (!statusList.includes(newStatus)) { res.status(400).send('Invalid status type'); diff --git a/frontend/src/components/Admin/AdminReview.tsx b/frontend/src/components/Admin/AdminReview.tsx index f48b046b..e530870c 100644 --- a/frontend/src/components/Admin/AdminReview.tsx +++ b/frontend/src/components/Admin/AdminReview.tsx @@ -28,6 +28,7 @@ import axios from 'axios'; type Props = { readonly review: ReviewWithId; readonly setToggle: React.Dispatch>; + readonly declinedSection: boolean; }; export type RatingInfo = { @@ -61,7 +62,7 @@ const useStyles = makeStyles(() => ({ }, })); -const AdminReviewComponent = ({ review, setToggle }: Props): ReactElement => { +const AdminReviewComponent = ({ review, setToggle, declinedSection }: Props): ReactElement => { const { detailedRatings, overallRating, date, reviewText, photos } = review; const formattedDate = format(new Date(date), 'MMM dd, yyyy').toUpperCase(); const { root, dateText, ratingInfo, photoStyle, photoRowStyle } = useStyles(); @@ -169,6 +170,17 @@ const AdminReviewComponent = ({ review, setToggle }: Props): ReactElement => { + {declinedSection && ( + + + + )}