diff --git a/Frontend/src/components/DoctorProfile.jsx b/Frontend/src/components/DoctorProfile.jsx index 049beaa..839b102 100644 --- a/Frontend/src/components/DoctorProfile.jsx +++ b/Frontend/src/components/DoctorProfile.jsx @@ -1,60 +1,41 @@ -import React from "react"; -import { useParams, Link, useNavigate } from "react-router-dom"; -import { FaUserMd, FaCalendar, FaCertificate, FaUsers, FaCalendarPlus } from "react-icons/fa"; +import React from 'react'; +import { FaCalendarPlus } from 'react-icons/fa'; +import { useNavigate } from 'react-router-dom'; -const DoctorProfile = ({ doctors }) => { - const { id } = useParams(); - const navigate = useNavigate(); - const doctor = doctors.find(d => d.id === parseInt(id)); +const DoctorModal = ({ doctor, onClose, isOpen }) => { + const navigate = useNavigate(); // Initialize useNavigate - if (!doctor) { - return
Doctor not found
; - } + if (!isOpen) return null; // Return null if the modal is not open - const handleBookAppointment = () => { - navigate(`/appointments?doctorId=${doctor.id}`); - }; + const handleBookAppointment = () => { + navigate(`/appointments?doctorId=${doctor.id}`); // Navigate to the appointments page + onClose(); // Close the modal after navigating + }; - return ( -
- ← Back to Doctors -
-
- {doctor.name} -
-

{doctor.name}

-

{doctor.specialty}

-
+ return ( +
+
+ +
+ {doctor.name} +

{doctor.name}

+

{doctor.specialty}

+

Experience: {doctor.experience} years

+

Patients: {doctor.patients}

+

{doctor.bio}

+ +
+
-
-
- - Experience: {doctor.experience} years -
-
- - Appointments: {doctor.appointments} -
-
- - Qualifications: {doctor.qualifications} -
-
- - Patients: {doctor.patients} -
-
-

{doctor.bio}

- -
-
- ); + ); }; -export default DoctorProfile; +export default DoctorModal; diff --git a/Frontend/src/components/Doctors.jsx b/Frontend/src/components/Doctors.jsx index 0a3accc..8900d18 100644 --- a/Frontend/src/components/Doctors.jsx +++ b/Frontend/src/components/Doctors.jsx @@ -1,19 +1,28 @@ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { motion } from 'framer-motion'; -import { FaUserMd, FaSearch, FaEye, FaCalendarPlus } from 'react-icons/fa'; +import { FaSearch, FaCalendarPlus, FaInfoCircle } from 'react-icons/fa'; +import DoctorModal from './DoctorProfile'; // Import the modal component const Doctors = ({ doctors }) => { const navigate = useNavigate(); const [searchTerm, setSearchTerm] = useState(''); + const [selectedDoctor, setSelectedDoctor] = useState(null); // State to manage selected doctor + const [isModalOpen, setIsModalOpen] = useState(false); // State to manage modal visibility const filteredDoctors = doctors.filter(doctor => doctor.name.toLowerCase().includes(searchTerm.toLowerCase()) || doctor.specialty.toLowerCase().includes(searchTerm.toLowerCase()) ); - const handleBookAppointment = (doctorId) => { - navigate(`/appointments?doctorId=${doctorId}`); + const handleOpenModal = (doctor) => { + setSelectedDoctor(doctor); + setIsModalOpen(true); // Open the modal + }; + + const handleCloseModal = () => { + setIsModalOpen(false); + setSelectedDoctor(null); // Reset the selected doctor }; return ( @@ -34,11 +43,11 @@ const Doctors = ({ doctors }) => {
- {filteredDoctors.map((doctor, index) => ( + {filteredDoctors.map((doctor) => ( handleOpenModal(doctor)} // Open modal when clicking on the card > {doctor.name}

{doctor.name}

@@ -47,29 +56,73 @@ const Doctors = ({ doctors }) => { Patients: {doctor.patients} Experience: {doctor.experience} years
-
- navigate(`/doctor/${doctor.id}`)} - > - - View Profile - + + {/* Book Appointment button */} +
handleBookAppointment(doctor.id)} + onClick={(e) => { + e.stopPropagation(); // Prevent triggering the card click event + navigate(`/appointments?doctorId=${doctor.id}`); + }} > Book Appointment
+ + {/* 'i' button in bottom-right corner */} + { + e.stopPropagation(); // Prevent triggering the card click event + handleOpenModal(doctor); // Open modal on 'i' button click + }} + > + + ))}
+ + {/* Doctor Modal */} + {isModalOpen && selectedDoctor && ( +
+
e.stopPropagation()} // Prevent click events from closing the modal + > + +
+ {selectedDoctor.name} +

{selectedDoctor.name}

+

{selectedDoctor.specialty}

+

Experience: {selectedDoctor.experience} years

+

Patients: {selectedDoctor.patients}

+

{selectedDoctor.bio}

+ +
+
+
+ )} ); };