Skip to content

Commit

Permalink
Merge pull request #98 from Kruthik111/main
Browse files Browse the repository at this point in the history
Solved the issue in Patients.jsx #97 and improved the code a little bit
  • Loading branch information
yazdanhaider authored Oct 25, 2024
2 parents ed129ae + c79483e commit 0015e80
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Frontend/src/components/Patients.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,21 @@ const Patients = () => {

useEffect(() => {
async function getPatients() {
const response = await axios.get("/api/patients/get-patients");
setPatients(response?.data?.data);
axios.get("/api/patients/get-patients")
.then(response => {
response.data.data && setPatients(response?.data?.data);
})
.catch(error => {
console.error("Error fetching patients:", error);
});
}

getPatients();
}, [showForm, patients]);

const filteredPatients = patients.filter((patient) =>
const filteredPatients = patients?.filter((patient) =>
patient.name.toLowerCase().includes(searchTerm.toLowerCase())
);
) || patients;

return (
<div className="bg-light min-h-screen p-4 sm:p-8">
Expand Down Expand Up @@ -193,7 +198,7 @@ const Patients = () => {
)}

<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{filteredPatients.map((patient, index) => (
{filteredPatients && filteredPatients.length > 0 && filteredPatients.map((patient, index) => (
<motion.div
key={index}
className={`bg-white p-6 rounded-lg shadow-lg ${
Expand Down

0 comments on commit 0015e80

Please sign in to comment.