diff --git a/src/__tests__/labs/ViewLab.test.tsx b/src/__tests__/labs/ViewLab.test.tsx
index a8968a897c..9260d10ac7 100644
--- a/src/__tests__/labs/ViewLab.test.tsx
+++ b/src/__tests__/labs/ViewLab.test.tsx
@@ -329,7 +329,7 @@ describe('View Lab', () => {
expect(labRepositorySaveSpy).toHaveBeenCalledWith(
expect.objectContaining({ ...mockLab, result: expectedResult, notes: expectedNotes }),
)
- expect(history.location.pathname).toEqual('/labs')
+ expect(history.location.pathname).toEqual('/labs/12456')
})
})
@@ -365,7 +365,7 @@ describe('View Lab', () => {
completedOn: expectedDate.toISOString(),
}),
)
- expect(history.location.pathname).toEqual('/labs')
+ expect(history.location.pathname).toEqual('/labs/12456')
})
})
diff --git a/src/labs/ViewLab.tsx b/src/labs/ViewLab.tsx
index d07042bba3..36b5a5eac3 100644
--- a/src/labs/ViewLab.tsx
+++ b/src/labs/ViewLab.tsx
@@ -1,4 +1,4 @@
-import { Row, Column, Badge, Button, Alert } from '@hospitalrun/components'
+import { Row, Column, Badge, Button, Alert, Toast } from '@hospitalrun/components'
import format from 'date-fns/format'
import React, { useEffect, useState } from 'react'
import { useSelector, useDispatch } from 'react-redux'
@@ -64,17 +64,26 @@ const ViewLab = () => {
}
const onUpdate = async () => {
- const onSuccess = () => {
- history.push('/labs')
+ const onSuccess = (update: Lab) => {
+ history.push(`/labs/${update.id}`)
+ Toast(
+ 'success',
+ t('states.success'),
+ `${t('labs.successfullyUpdated')} ${update.type} ${patient?.fullName}`,
+ )
}
if (labToView) {
dispatch(updateLab(labToView, onSuccess))
}
}
-
const onComplete = async () => {
- const onSuccess = () => {
- history.push('/labs')
+ const onSuccess = (complete: Lab) => {
+ history.push(`/labs/${complete.id}`)
+ Toast(
+ 'success',
+ t('states.success'),
+ `${t('labs.successfullyCompleted')} ${complete.type} ${patient?.fullName} `,
+ )
}
if (labToView) {
diff --git a/src/labs/requests/NewLabRequest.tsx b/src/labs/requests/NewLabRequest.tsx
index 775911ed13..05aafca102 100644
--- a/src/labs/requests/NewLabRequest.tsx
+++ b/src/labs/requests/NewLabRequest.tsx
@@ -1,5 +1,6 @@
-import { Typeahead, Label, Button, Alert } from '@hospitalrun/components'
-import React, { useState, useEffect } from 'react'
+
+import { Typeahead, Label, Button, Alert, Toast } from '@hospitalrun/components'
+import React, { useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useHistory } from 'react-router-dom'
@@ -44,6 +45,7 @@ const NewLabRequest = () => {
setNewLabRequest((previousNewLabRequest) => ({
...previousNewLabRequest,
patient: patient.id,
+ fullName: patient.fullName,
}))
}
@@ -64,12 +66,16 @@ const NewLabRequest = () => {
}
const onSave = async () => {
- const newLab = newLabRequest as Lab
- const onSuccess = (createdLab: Lab) => {
- history.push(`/labs/${createdLab.id}`)
+ const onSuccessRequest = (newLab: Lab) => {
+ history.push(`/labs/${newLab.id}`)
+ Toast(
+ 'success',
+ t('states.success'),
+ `${t('lab.successfullyCreated')} ${newLab.type} ${newLab.patient}`,
+ )
}
- dispatch(requestLab(newLab, onSuccess))
+ dispatch(requestLab(newLabRequest as Lab, onSuccessRequest))
}
const onCancel = () => {
@@ -118,6 +124,7 @@ const NewLabRequest = () => {
+