Changeset a64c772 for frontend/src/pages/appointments/AppointmentList.js
- Timestamp:
- 05/25/26 13:43:53 (4 months ago)
- Branches:
- master
- Children:
- f18b11b
- Parents:
- 84249b1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/pages/appointments/AppointmentList.js
r84249b1 ra64c772 47 47 await appointmentService.cancelAppointment(id); 48 48 setAppointments(appointments.map(apt => 49 apt.appointmentId === id ? { ...apt, status: 'CANCELLED' } : apt49 apt.appointmentId === id ? { ...apt, status: 'CANCELLED' } : apt 50 50 )); 51 51 } catch (err) { … … 58 58 59 59 return ( 60 <div>61 <div className="flex justify-between items-center mb-6">62 <h1 className="text-3xl font-bold" style={{ color: '#7c3aed' }}>63 {patientId ? 'Patient Appointments' : doctorId ? 'My Appointments' : 'All Appointments'}64 </h1>65 <Link to="/appointments/new" style={{66 display: 'inline-block',67 background: '#bfdbfe',68 color: '#1e1035',69 padding: '8px 16px',70 borderRadius: '6px',71 textDecoration: 'none',72 fontSize: '14px',73 fontWeight: '400'74 }} onMouseEnter={(e) => e.currentTarget.style.background = '#93c5fd'} onMouseLeave={(e) => e.currentTarget.style.background = '#bfdbfe'}>75 New Appointment76 </Link>77 </div>60 <div> 61 <div className="flex justify-between items-center mb-6"> 62 <h1 className="text-3xl font-bold" style={{ color: '#7c3aed' }}> 63 {patientId ? 'Patient Appointments' : doctorId ? 'My Appointments' : 'All Appointments'} 64 </h1> 65 <Link to="/appointments/new" style={{ 66 display: 'inline-block', 67 background: '#bfdbfe', 68 color: '#1e1035', 69 padding: '8px 16px', 70 borderRadius: '6px', 71 textDecoration: 'none', 72 fontSize: '14px', 73 fontWeight: '400' 74 }} onMouseEnter={(e) => e.currentTarget.style.background = '#93c5fd'} onMouseLeave={(e) => e.currentTarget.style.background = '#bfdbfe'}> 75 New Appointment 76 </Link> 77 </div> 78 78 79 {error && <ErrorAlert message={error} onClose={() => setError(null)} />}79 {error && <ErrorAlert message={error} onClose={() => setError(null)} />} 80 80 81 <div className="bg-white rounded-lg shadow overflow-hidden">82 <table className="w-full">83 <thead className="bg-gray-100">81 <div className="bg-white rounded-lg shadow overflow-hidden"> 82 <table className="w-full"> 83 <thead className="bg-gray-100"> 84 84 <tr> 85 85 <th className="px-6 py-3 text-left text-sm font-semibold">Patient</th> … … 90 90 <th className="px-6 py-3 text-left text-sm font-semibold">Actions</th> 91 91 </tr> 92 </thead>93 <tbody>92 </thead> 93 <tbody> 94 94 {appointments.map(appointment => ( 95 <tr key={appointment.appointmentId} className="border-t hover:bg-gray-50">96 <td className="px-6 py-3">{appointment.patient?.firstName} {appointment.patient?.lastName}</td>97 <td className="px-6 py-3">Dr. {appointment.doctor?.firstName} {appointment.doctor?.lastName}</td>98 <td className="px-6 py-3">{appointment.appointmentDate}</td>99 <td className="px-6 py-3">{appointment.appointmentTime}</td>100 <td className="px-6 py-3">95 <tr key={appointment.appointmentId} className="border-t hover:bg-gray-50"> 96 <td className="px-6 py-3">{appointment.patient?.firstName} {appointment.patient?.lastName}</td> 97 <td className="px-6 py-3">Dr. {appointment.doctor?.firstName} {appointment.doctor?.lastName}</td> 98 <td className="px-6 py-3">{appointment.appointmentDate}</td> 99 <td className="px-6 py-3">{appointment.appointmentTime}</td> 100 <td className="px-6 py-3"> 101 101 <span className={`px-3 py-1 rounded text-sm font-semibold ${ 102 appointment.status === 'SCHEDULED' ? 'bg-purple-100 text-purple-800' :103 appointment.status === 'COMPLETED' ? 'bg-green-100 text-green-800' :104 'bg-red-100 text-red-800'102 appointment.status === 'SCHEDULED' ? 'bg-purple-100 text-purple-800' : 103 appointment.status === 'COMPLETED' ? 'bg-green-100 text-green-800' : 104 'bg-red-100 text-red-800' 105 105 }`}> 106 106 {appointment.status} 107 107 </span> 108 </td> 109 <td className="px-6 py-3"> 110 {appointment.status === 'SCHEDULED' && ( 111 <button 112 onClick={() => handleCancelAppointment(appointment.appointmentId)} 113 className="text-red-600 hover:underline px-3 py-2 text-sm font-medium" 114 > 115 Cancel 116 </button> 117 )} 118 </td> 119 </tr> 108 </td> 109 <td className="px-6 py-3"> 110 {appointment.status === 'SCHEDULED' && ( 111 (user.role === 'DOCTOR' && appointment.doctor?.doctorId !== user.doctorId) ? null : ( 112 <button 113 onClick={() => handleCancelAppointment(appointment.appointmentId)} 114 className="text-red-600 hover:underline px-3 py-2 text-sm font-medium" 115 > 116 Cancel 117 </button> 118 ) 119 )} 120 </td> 121 </tr> 120 122 ))} 121 </tbody> 122 </table> 123 </tbody> 124 </table> 125 </div> 123 126 </div> 124 </div>125 127 ); 126 128 }
Note:
See TracChangeset
for help on using the changeset viewer.
