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

Commit

Permalink
feat(viewlabs): sort Labs by requestedOn field
Browse files Browse the repository at this point in the history
feat #1966
  • Loading branch information
akshay-ap committed Apr 21, 2020
1 parent c703928 commit d22a174
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/labs/ViewLabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ const ViewLabs = () => {
</tr>
</thead>
<tbody>
{labs.map((lab) => (
<tr onClick={() => onTableRowClick(lab)} key={lab.id}>
<td>{lab.type}</td>
<td>{format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a')}</td>
<td>{lab.status}</td>
</tr>
))}
{labs
.sort((a, b) =>
a.requestedOn < b.requestedOn ? 1 : b.requestedOn < a.requestedOn ? -1 : 0,
)
.map((lab) => (
<tr onClick={() => onTableRowClick(lab)} key={lab.id}>
<td>{lab.type}</td>
<td>{format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a')}</td>
<td>{lab.status}</td>
</tr>
))}
</tbody>
</table>
</>
Expand Down

0 comments on commit d22a174

Please sign in to comment.