From 5d08ccf84b48e503b8a907c829c80b2ad72349f3 Mon Sep 17 00:00:00 2001 From: Anya Pawar Date: Tue, 28 Jul 2020 16:17:33 -0400 Subject: [PATCH 1/3] feat(viewlab.tsx): added success toast for updated/completed labs --- src/labs/ViewLab.tsx | 21 +++++++++++++++------ src/labs/requests/NewLabRequest.tsx | 16 +++++++++++----- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/labs/ViewLab.tsx b/src/labs/ViewLab.tsx index b8328de69d..0cc3bb6c91 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 { useTranslation } from 'react-i18next' @@ -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 08fe49b664..5036e94a89 100644 --- a/src/labs/requests/NewLabRequest.tsx +++ b/src/labs/requests/NewLabRequest.tsx @@ -1,4 +1,4 @@ -import { Typeahead, Label, Button, Alert } from '@hospitalrun/components' +import { Typeahead, Label, Button, Alert, Toast } from '@hospitalrun/components' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' @@ -40,6 +40,7 @@ const NewLabRequest = () => { setNewLabRequest((previousNewLabRequest) => ({ ...previousNewLabRequest, patient: patient.id, + fullName: patient.fullName, })) } @@ -60,12 +61,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 = () => { @@ -114,6 +119,7 @@ const NewLabRequest = () => { + From 6339e78285b01fdf7c8481aaf98b55471e5111b2 Mon Sep 17 00:00:00 2001 From: Anya Pawar Date: Mon, 10 Aug 2020 02:30:23 -0400 Subject: [PATCH 2/3] fix(added translation keys #2258): added missing translation keys PR #2258 --- src/__tests__/labs/ViewLab.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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') }) }) From f2a6386b68928c49ebdcb6650f9aad96569f16d0 Mon Sep 17 00:00:00 2001 From: Anya Pawar <35543770+anyapawar@users.noreply.github.com> Date: Mon, 10 Aug 2020 02:42:04 -0400 Subject: [PATCH 3/3] translation keys added --- src/__tests__/labs/ViewLab.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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') }) })