diff --git a/admin/src/pages/UsersFeedbacks.tsx b/admin/src/pages/UsersFeedbacks.tsx
index 5811e17..5d3c8f2 100644
--- a/admin/src/pages/UsersFeedbacks.tsx
+++ b/admin/src/pages/UsersFeedbacks.tsx
@@ -54,6 +54,21 @@ const GetFeedbacks = () => {
}
};
+ const handleDeleteFeedback = async (feedbackId: string) => {
+ try {
+ await axios.delete(`/api/v1/admin/deletefeedback/${feedbackId}`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ });
+ toast.success("Feedback deleted successfully");
+ setFeedbacks(feedbacks.filter(feedback => feedback.id !== feedbackId));
+ } catch (error) {
+ console.error("Error deleting feedback:", error);
+ toast.error("Error deleting feedback");
+ }
+ };
+
return (
@@ -95,12 +110,18 @@ const GetFeedbacks = () => {
{feedback.comment} |
{feedback.rating} |
{new Date(feedback.createdAt).toLocaleDateString()} |
-
- |
diff --git a/backend/src/routes/admin/controller.ts b/backend/src/routes/admin/controller.ts
index 78f0365..ab37e3e 100644
--- a/backend/src/routes/admin/controller.ts
+++ b/backend/src/routes/admin/controller.ts
@@ -1107,4 +1107,19 @@ export const deleteContactMessage = async (req: Request, res: Response) => {
error: "An error occurred while deleting the contact message!",
});
}
+};
+
+export const deleteFeedback = async (req: Request, res: Response) => {
+ const { id } = req.params;
+
+ try {
+ const feedback = await prisma.feedback.delete({
+ where: { id },
+ });
+
+ res.status(200).json({ message: 'Feedback deleted successfully', feedback });
+ } catch (error) {
+ console.error('Error deleting feedback:', error);
+ res.status(500).json({ error: 'An unexpected error occurred!' });
+ }
};
\ No newline at end of file
diff --git a/backend/src/routes/admin/route.ts b/backend/src/routes/admin/route.ts
index 6388864..29a203b 100644
--- a/backend/src/routes/admin/route.ts
+++ b/backend/src/routes/admin/route.ts
@@ -1,5 +1,5 @@
import {Router} from 'express';
-import { getPostReactionsController,getFavoritesController,adminLoginController, adminProfileController, allUserForAdmin, blockUserController, unblockUserController, getAdminPostsController, getAdminTrendingPostsController, getAdminStatsController, getGraphsStatsController, updatePostController, deletePostController, getPostByIdController, getAllContactMessages, deleteCommentController, downloadReportController, getFeedbacks, toggleFeedbackVisibility, downloadCommentsReportController, downloadFavoritesReportController, downloadReactionsReportController, downloadUsersReportController, downloadContactMessagesReportController, downloadPostsReportController, deleteContactMessage } from './controller';
+import { getPostReactionsController,getFavoritesController,adminLoginController, adminProfileController, allUserForAdmin, blockUserController, unblockUserController, getAdminPostsController, getAdminTrendingPostsController, getAdminStatsController, getGraphsStatsController, updatePostController, deletePostController, getPostByIdController, getAllContactMessages, deleteCommentController, downloadReportController, getFeedbacks, toggleFeedbackVisibility, downloadCommentsReportController, downloadFavoritesReportController, downloadReactionsReportController, downloadUsersReportController, downloadContactMessagesReportController, downloadPostsReportController, deleteContactMessage, deleteFeedback } from './controller';
import { isAdmin } from '../../middleware/adminAuth';
const adminRouter = Router();
@@ -56,4 +56,6 @@ adminRouter.get("/downloadusersreactionreport", downloadReactionsReportControlle
adminRouter.delete("/deletecontactmessage/:id", isAdmin, deleteContactMessage);
+adminRouter.delete('/deletefeedback/:id', isAdmin, deleteFeedback);
+
export default adminRouter;
\ No newline at end of file