Changeset a64c772 for frontend/src/pages/billing/BillingList.js
- Timestamp:
- 05/25/26 13:43:53 (4 months ago)
- Branches:
- master
- Children:
- f18b11b
- Parents:
- 84249b1
- File:
-
- 1 edited
-
frontend/src/pages/billing/BillingList.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/pages/billing/BillingList.js
r84249b1 ra64c772 13 13 const user = JSON.parse(localStorage.getItem('user') || '{}'); 14 14 15 useEffect(() => {16 fetchBillings();17 }, [patientId]);18 19 15 const fetchBillings = async () => { 20 16 try { … … 24 20 response = await billingService.getBillingHistoryForPatient(patientId); 25 21 } else if (user.role === 'PATIENT') { 26 // Patients can only view their own billing history27 22 response = await billingService.getBillingHistoryForPatient(user.patientId); 28 23 } else { … … 38 33 }; 39 34 35 useEffect(() => { 36 fetchBillings(); 37 }, [patientId]); 38 39 // Prevent unauthorized access to billing 40 if (user.role === 'DOCTOR' || user.role === 'LAB_TECHNICIAN') { 41 return ( 42 <div style={{ padding: '20px', textAlign: 'center' }}> 43 <h1 className="text-2xl font-bold" style={{ color: '#7c3aed', marginBottom: '10px' }}>Access Denied</h1> 44 <p style={{ color: 'var(--color-neutral-600)' }}>You do not have permission to access billing records.</p> 45 </div> 46 ); 47 } 48 40 49 if (loading) return <Loading />; 41 50 42 51 return ( 43 <div>44 <h1 className="text-3xl font-bold mb-6" style={{ color: '#7c3aed' }}>{patientId ? 'Patient Billing History' : 'Billing Records'}</h1>52 <div> 53 <h1 className="text-3xl font-bold mb-6" style={{ color: '#7c3aed' }}>{patientId ? 'Patient Billing History' : 'Billing Records'}</h1> 45 54 46 {error && <ErrorAlert message={error} onClose={() => setError(null)} />}55 {error && <ErrorAlert message={error} onClose={() => setError(null)} />} 47 56 48 <div className="bg-white rounded-lg shadow overflow-hidden">49 <table className="w-full">50 <thead className="bg-gray-100">57 <div className="bg-white rounded-lg shadow overflow-hidden"> 58 <table className="w-full"> 59 <thead className="bg-gray-100"> 51 60 <tr> 52 61 <th className="px-6 py-3 text-left text-sm font-semibold">Patient</th> … … 56 65 <th className="px-6 py-3 text-left text-sm font-semibold">Actions</th> 57 66 </tr> 58 </thead>59 <tbody>67 </thead> 68 <tbody> 60 69 {billings.map(billing => ( 61 <tr key={billing.billId} className="border-t hover:bg-gray-50">62 <td className="px-6 py-3">{billing.patientName}</td>63 <td className="px-6 py-3">${billing.totalCost}</td>64 <td className="px-6 py-3">70 <tr key={billing.billId} className="border-t hover:bg-gray-50"> 71 <td className="px-6 py-3">{billing.patientName}</td> 72 <td className="px-6 py-3">${billing.totalCost}</td> 73 <td className="px-6 py-3"> 65 74 <span className={`px-3 py-1 rounded text-sm font-semibold ${ 66 billing.paymentStatus === 'PENDING' ? 'bg-yellow-100 text-yellow-800' :67 billing.paymentStatus === 'PAID' ? 'bg-green-100 text-green-800' :68 'bg-red-100 text-red-800'75 billing.paymentStatus === 'PENDING' ? 'bg-yellow-100 text-yellow-800' : 76 billing.paymentStatus === 'PAID' ? 'bg-green-100 text-green-800' : 77 'bg-red-100 text-red-800' 69 78 }`}> 70 79 {billing.paymentStatus} 71 80 </span> 72 </td>73 <td className="px-6 py-3">{billing.paymentDate || 'Not paid'}</td>74 <td className="px-6 py-3">75 <Link to={`/billing/${billing.billId}`} style={{ color: '#7c3aed', textDecoration: 'none', fontWeight: '400' }} onMouseEnter={(e) => e.currentTarget.style.textDecoration = 'underline'} onMouseLeave={(e) => e.currentTarget.style.textDecoration = 'none'}>76 View77 </Link>78 </td>79 </tr>81 </td> 82 <td className="px-6 py-3">{billing.paymentDate || 'Not paid'}</td> 83 <td className="px-6 py-3"> 84 <Link to={`/billing/${billing.billId}`} style={{ color: '#7c3aed', textDecoration: 'none', fontWeight: '400' }} onMouseEnter={(e) => e.currentTarget.style.textDecoration = 'underline'} onMouseLeave={(e) => e.currentTarget.style.textDecoration = 'none'}> 85 View 86 </Link> 87 </td> 88 </tr> 80 89 ))} 81 </tbody> 82 </table> 90 </tbody> 91 </table> 92 </div> 83 93 </div> 84 </div>85 94 ); 86 95 }
Note:
See TracChangeset
for help on using the changeset viewer.
