-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,466 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
import { Link } from 'react-router-dom'; | ||
|
||
import { Table, Menu, ActionIcon } from '@mantine/core'; | ||
import { | ||
IconDotsVertical, | ||
IconUser, | ||
IconQrcode, | ||
IconTrash, | ||
} from '@tabler/icons-react'; | ||
|
||
const patientTableRowProps = { | ||
headers: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
key: PropTypes.string.isRequired, | ||
text: PropTypes.node, | ||
}), | ||
), | ||
patient: PropTypes.shape({ | ||
id: PropTypes.string.isRequired, | ||
name: PropTypes.string.isRequired, | ||
createdBy: PropTypes.string.isRequired, | ||
createdAt: PropTypes.string.isRequired, | ||
updatedBy: PropTypes.string.isRequired, | ||
updatedAt: PropTypes.string.isRequired, | ||
}), | ||
|
||
onDelete: PropTypes.func.isRequired, | ||
showDeleteMenu: PropTypes.bool.isRequired, | ||
}; | ||
|
||
/** | ||
* Patient table row component | ||
* @param {PropTypes.InferProps<typeof patientTableRowProps>} props | ||
*/ | ||
export default function PatientTableRow({ | ||
headers, | ||
patient, | ||
onDelete, | ||
showDeleteMenu, | ||
}) { | ||
return ( | ||
<Table.Tr key={patient.id}> | ||
{headers.map((header) => ( | ||
<Table.Td key={patient[header.key] + header.key}> | ||
{patient[header.key]} | ||
</Table.Td> | ||
))} | ||
<Table.Td> | ||
<Menu shadow="md"> | ||
<Menu.Target> | ||
<ActionIcon variant="subtle" color="gray"> | ||
<IconDotsVertical size={18} /> | ||
</ActionIcon> | ||
</Menu.Target> | ||
<Menu.Dropdown> | ||
<Menu.Item | ||
leftSection={<IconUser size={18} />} | ||
component={Link} | ||
to={`/patients/${patient.id}`} | ||
> | ||
View/Edit | ||
</Menu.Item> | ||
<Menu.Item leftSection={<IconQrcode size={18} />}> | ||
Reprint QR Code | ||
</Menu.Item> | ||
{showDeleteMenu && ( | ||
<Menu.Item | ||
leftSection={<IconTrash size={18} />} | ||
color="red" | ||
onClick={() => | ||
onDelete({ | ||
id: patient.id, | ||
name: patient.name, | ||
}) | ||
} | ||
> | ||
Delete | ||
</Menu.Item> | ||
)} | ||
</Menu.Dropdown> | ||
</Menu> | ||
</Table.Td> | ||
</Table.Tr> | ||
); | ||
} | ||
|
||
PatientTableRow.propTypes = patientTableRowProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
Container, | ||
Group, | ||
TextInput, | ||
Divider, | ||
Pagination, | ||
LoadingOverlay, | ||
Text, | ||
} from '@mantine/core'; | ||
import { useDebouncedCallback } from '@mantine/hooks'; | ||
import { useState } from 'react'; | ||
|
||
import { IconSearch } from '@tabler/icons-react'; | ||
|
||
import classes from './Patients.module.css'; | ||
import PatientsTable from './PatientsTable'; | ||
import { usePatients } from './usePatients'; | ||
|
||
/** | ||
* Patients page component | ||
* | ||
*/ | ||
export default function Patients() { | ||
const [inputValue, setInputValue] = useState(''); | ||
const { patients, headers, isFetching, page, pages, setPage, setSearch } = | ||
usePatients(); | ||
|
||
const handleSearch = useDebouncedCallback((query) => { | ||
setSearch(query); | ||
}, 500); | ||
|
||
return ( | ||
<Container> | ||
<div className={classes.header}> | ||
<Text fw={600} size="xl" mr="md"> | ||
Patients | ||
</Text> | ||
<Group> | ||
<TextInput | ||
leftSectionPointerEvents="none" | ||
leftSection={<IconSearch stroke={2} />} | ||
placeholder="Search" | ||
onChange={(event) => { | ||
setInputValue(event.currentTarget.value); | ||
handleSearch(event.currentTarget.value); | ||
}} | ||
value={inputValue} | ||
/> | ||
</Group> | ||
</div> | ||
<Divider mb="xl" /> | ||
<Container className={classes.patientsContainer}> | ||
<LoadingOverlay | ||
visible={isFetching} | ||
zIndex={1000} | ||
overlayProps={{ radius: 'sm', blur: 2 }} | ||
/> | ||
<PatientsTable headers={headers} data={patients} /> | ||
<Pagination total={pages} value={page} onChange={setPage} /> | ||
</Container> | ||
</Container> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.tableWrapper { | ||
margin-bottom: var(--mantine-spacing-xs); | ||
} | ||
|
||
.table { | ||
border-radius: 7px; | ||
overflow: hidden; | ||
} | ||
|
||
.title { | ||
font-size: 1.2rem; | ||
font-weight: 600; | ||
color: var(--mantine-color-red-8); | ||
} | ||
|
||
.header { | ||
display: flex; | ||
justify-content: space-between; | ||
margin: 1rem 1rem; | ||
} | ||
|
||
.patientsContainer { | ||
position: relative; | ||
margin-bottom: var(--mantine-spacing-lg); | ||
} | ||
|
||
.button { | ||
margin-top: var(--mantine-spacing-lg); | ||
} |
Oops, something went wrong.