-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #464 from nishant0708/Feedbacks
Feat:Canteen Should able to see Feedback Given to Them by User (UI +Integration) #448
- Loading branch information
Showing
4 changed files
with
87 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useState, useEffect, useContext } from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import axios from "axios"; | ||
import Loader from "../components/Loader/Loader"; | ||
import { ThemeContext } from "../themeContext"; | ||
|
||
const FeedbackList = () => { | ||
const { _id } = useParams(); | ||
const { theme } = useContext(ThemeContext); | ||
const [feedbacks, setFeedbacks] = useState([]); | ||
const [loading, setLoading] = useState(false); | ||
|
||
useEffect(() => { | ||
const fetchFeedbacks = async () => { | ||
setLoading(true); | ||
try { | ||
const response = await axios.get(`${process.env.REACT_APP_BASE_URL}/feedbacks/${_id}`); | ||
setFeedbacks(response.data); | ||
} catch (error) { | ||
console.error("Error fetching feedbacks:", error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
fetchFeedbacks(); | ||
}, [_id]); | ||
|
||
if (loading) return <Loader />; | ||
|
||
return ( | ||
<div className={`min-h-screen ${theme === "dark" ? "bg-[#131b33] text-white" : "bg-white text-gray-900"}`}> | ||
<h1 className="text-4xl font-bold mb-8 text-center">Feedbacks</h1> | ||
{feedbacks.length > 0 ? ( | ||
feedbacks.map((feedback) => ( | ||
<div key={feedback._id} className="border border-gray-300 rounded p-4 mb-4"> | ||
<p>{feedback.message}</p> | ||
<p className="text-gray-500">User ID: {feedback.userId}</p> | ||
</div> | ||
)) | ||
) : ( | ||
<p className="text-center">No feedback available.</p> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default FeedbackList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters