{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\User\\\\Downloads\\\\medora5\\\\frontend\\\\src\\\\pages\\\\patients\\\\PatientList.js\",\n _s = $RefreshSig$();\nimport React, { useState, useEffect } from 'react';\nimport { Link } from 'react-router-dom';\nimport { patientService } from '../../services/patientService';\nimport Loading from '../../components/Loading';\nimport ErrorAlert from '../../components/ErrorAlert';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nfunction PatientList() {\n _s();\n const user = JSON.parse(localStorage.getItem('user') || '{}');\n const isAdmin = user.role === 'ADMIN';\n const [patients, setPatients] = useState([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n const [searchTerm, setSearchTerm] = useState('');\n useEffect(() => {\n fetchPatients();\n }, []);\n const fetchPatients = async () => {\n try {\n setLoading(true);\n const response = await patientService.getAllPatients();\n setPatients(response.data);\n } catch (err) {\n setError('Failed to fetch patients');\n console.error(err);\n } finally {\n setLoading(false);\n }\n };\n const filteredPatients = patients.filter(patient => patient.firstName.toLowerCase().includes(searchTerm.toLowerCase()) || patient.lastName.toLowerCase().includes(searchTerm.toLowerCase()) || patient.embg.includes(searchTerm));\n if (loading) return /*#__PURE__*/_jsxDEV(Loading, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 38,\n columnNumber: 23\n }, this);\n return /*#__PURE__*/_jsxDEV(\"div\", {\n children: [/*#__PURE__*/_jsxDEV(\"div\", {\n className: \"flex justify-between items-center mb-6\",\n children: [/*#__PURE__*/_jsxDEV(\"h1\", {\n className: \"text-3xl font-bold\",\n style: {\n color: '#7c3aed'\n },\n children: \"Patients\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 43,\n columnNumber: 9\n }, this), isAdmin && /*#__PURE__*/_jsxDEV(Link, {\n to: \"/patients/new\",\n style: {\n display: 'inline-block',\n background: '#bfdbfe',\n color: '#1e1035',\n padding: '8px 16px',\n borderRadius: '6px',\n textDecoration: 'none',\n fontSize: '14px',\n fontWeight: '400'\n },\n onMouseEnter: e => e.currentTarget.style.background = '#93c5fd',\n onMouseLeave: e => e.currentTarget.style.background = '#bfdbfe',\n children: \"Add Patient\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 45,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 42,\n columnNumber: 7\n }, this), error && /*#__PURE__*/_jsxDEV(ErrorAlert, {\n message: error,\n onClose: () => setError(null)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 60,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"mb-6\",\n children: /*#__PURE__*/_jsxDEV(\"input\", {\n type: \"text\",\n placeholder: \"Search by name or EMBG...\",\n className: \"w-full px-4 py-2 border rounded-lg\",\n value: searchTerm,\n onChange: e => setSearchTerm(e.target.value)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 63,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 62,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"bg-white rounded-lg shadow overflow-hidden\",\n children: /*#__PURE__*/_jsxDEV(\"table\", {\n className: \"w-full\",\n children: [/*#__PURE__*/_jsxDEV(\"thead\", {\n className: \"bg-gray-100\",\n children: /*#__PURE__*/_jsxDEV(\"tr\", {\n children: [/*#__PURE__*/_jsxDEV(\"th\", {\n className: \"px-6 py-3 text-left text-sm font-semibold\",\n children: \"Name\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"th\", {\n className: \"px-6 py-3 text-left text-sm font-semibold\",\n children: \"EMBG\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"th\", {\n className: \"px-6 py-3 text-left text-sm font-semibold\",\n children: \"Email\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"th\", {\n className: \"px-6 py-3 text-left text-sm font-semibold\",\n children: \"Phone\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 79,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(\"th\", {\n className: \"px-6 py-3 text-left text-sm font-semibold\",\n children: \"Actions\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 80,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 74,\n columnNumber: 11\n }, this), /*#__PURE__*/_jsxDEV(\"tbody\", {\n children: filteredPatients.map(patient => /*#__PURE__*/_jsxDEV(\"tr\", {\n className: \"border-t hover:bg-gray-50\",\n children: [/*#__PURE__*/_jsxDEV(\"td\", {\n className: \"px-6 py-3\",\n children: [patient.firstName, \" \", patient.lastName]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"td\", {\n className: \"px-6 py-3\",\n children: patient.embg\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"td\", {\n className: \"px-6 py-3\",\n children: patient.emailAddress\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"td\", {\n className: \"px-6 py-3\",\n children: patient.phoneNumber\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 17\n }, this), /*#__PURE__*/_jsxDEV(\"td\", {\n className: \"px-6 py-3\",\n children: /*#__PURE__*/_jsxDEV(Link, {\n to: `/patients/${patient.patientId}`,\n className: \"text-purple-600 hover:underline\",\n children: \"View\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 19\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 17\n }, this)]\n }, patient.patientId, true, {\n fileName: _jsxFileName,\n lineNumber: 85,\n columnNumber: 15\n }, this))\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 83,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 73,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 72,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 41,\n columnNumber: 5\n }, this);\n}\n_s(PatientList, \"NfeSa1mJjIX1nkIu+dMYcNWP4kQ=\");\n_c = PatientList;\nexport default PatientList;\nvar _c;\n$RefreshReg$(_c, \"PatientList\");","map":{"version":3,"names":["React","useState","useEffect","Link","patientService","Loading","ErrorAlert","jsxDEV","_jsxDEV","PatientList","_s","user","JSON","parse","localStorage","getItem","isAdmin","role","patients","setPatients","loading","setLoading","error","setError","searchTerm","setSearchTerm","fetchPatients","response","getAllPatients","data","err","console","filteredPatients","filter","patient","firstName","toLowerCase","includes","lastName","embg","fileName","_jsxFileName","lineNumber","columnNumber","children","className","style","color","to","display","background","padding","borderRadius","textDecoration","fontSize","fontWeight","onMouseEnter","e","currentTarget","onMouseLeave","message","onClose","type","placeholder","value","onChange","target","map","emailAddress","phoneNumber","patientId","_c","$RefreshReg$"],"sources":["C:/Users/User/Downloads/medora5/frontend/src/pages/patients/PatientList.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { Link } from 'react-router-dom';\nimport { patientService } from '../../services/patientService';\nimport Loading from '../../components/Loading';\nimport ErrorAlert from '../../components/ErrorAlert';\n\nfunction PatientList() {\n const user = JSON.parse(localStorage.getItem('user') || '{}');\n const isAdmin = user.role === 'ADMIN';\n const [patients, setPatients] = useState([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n const [searchTerm, setSearchTerm] = useState('');\n\n useEffect(() => {\n fetchPatients();\n }, []);\n\n const fetchPatients = async () => {\n try {\n setLoading(true);\n const response = await patientService.getAllPatients();\n setPatients(response.data);\n } catch (err) {\n setError('Failed to fetch patients');\n console.error(err);\n } finally {\n setLoading(false);\n }\n };\n\n const filteredPatients = patients.filter(patient =>\n patient.firstName.toLowerCase().includes(searchTerm.toLowerCase()) ||\n patient.lastName.toLowerCase().includes(searchTerm.toLowerCase()) ||\n patient.embg.includes(searchTerm)\n );\n\n if (loading) return
| Name | \nEMBG | \nPhone | \nActions | \n|
|---|---|---|---|---|
| {patient.firstName} {patient.lastName} | \n{patient.embg} | \n{patient.emailAddress} | \n{patient.phoneNumber} | \n\n \n View\n \n | \n