Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

feat(viewlabs): sort Labs by requestedOn field #2004

Merged
merged 13 commits into from
Apr 22, 2020
11 changes: 10 additions & 1 deletion src/labs/ViewLabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'
import { Button } from '@hospitalrun/components'
import { useHistory } from 'react-router'
import LabRepository from 'clients/db/LabRepository'
import SortRequest from 'clients/db/SortRequest'
import Lab from 'model/Lab'
import { useSelector } from 'react-redux'
import Permissions from 'model/Permissions'
Expand Down Expand Up @@ -38,7 +39,15 @@ const ViewLabs = () => {

useEffect(() => {
const fetch = async () => {
const fetchedLabs = await LabRepository.findAll()
const sortRequest: SortRequest = {
akshay-ap marked this conversation as resolved.
Show resolved Hide resolved
sorts: [
{
field: 'requestedOn',
direction: 'desc',
},
],
}
const fetchedLabs = await LabRepository.findAll(sortRequest)
setLabs(fetchedLabs)
}

Expand Down