Skip to content

Commit

Permalink
Merge 713ce22 into f0fe3b6
Browse files Browse the repository at this point in the history
  • Loading branch information
mogoodrich committed Sep 30, 2019
2 parents f0fe3b6 + 713ce22 commit 6bc96c2
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
9 changes: 6 additions & 3 deletions app/js/middlewares/responseHandlerMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import toastr from 'toastr';
import { getIntl, selectors } from "@openmrs/react-components";
import {
GET_DATE_SUCCESS,
GET_DATE_FAILURE,
Expand All @@ -9,7 +10,7 @@ import {
DISCONTINUE_ACTIVE_DRUG_ORDER, DISCONTINUE_ORDER_SUCCEDED,
} from '../actions/actionTypes';

export default function responseHandlerMiddleware() {
export default function responseHandlerMiddleware({ getState }) {
return next => (action) => {
if (action.type === GET_DATE_SUCCESS) {
const { results } = action.payload.data;
Expand Down Expand Up @@ -60,10 +61,12 @@ export default function responseHandlerMiddleware() {
}

if (action.type === DISCONTINUE_ORDER_SUCCEDED) {
toastr.success('Order discontinued Succesfully');
const intl = getIntl(selectors.getSession(getState()).locale);
toastr.success(intl.formatMessage({ id: "app.orders.discontinue.success", defaultMessage: "Order discontinued successfully" }));
}
if (action.type === POST_DRUG_ORDER_SUCCESS && action.meta.activity === 'DISCONTINUE') {
toastr.success('Order discontinued Succesfully');
const intl = getIntl(selectors.getSession(getState()).locale);
toastr.success(intl.formatMessage({ id: "app.orders.discontinue.success", defaultMessage: "Order discontinued successfully" }));
next({ type: DISCONTINUE_ACTIVE_DRUG_ORDER, orderNumber: action.meta.orderNumber });
}

Expand Down
1 change: 1 addition & 0 deletions app/js/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"app.orders.discontinue":"DISCONTINUE",
"app.orders.discontinue.question":"Are you sure you want to discontinue this order ?",
"app.orders.discontinue.reason":"Reason for discontinuing",
"app.orders.discontinue.success": "Order discontinued successfully",
"app.orders.create.success":"Order Successfully Created",
"app.orders.is.active":"order is active",
"app.orders.number":"Order number"
Expand Down
8 changes: 5 additions & 3 deletions app/js/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
"app.orders.dosingInstructions": "Instructions de dosage",
"app.orders.dispense": "Dispenser",
"app.orders.orderBy": "Commander par",
"app.orders.activeDates":"Active Dates",
"app.orders.activeDates":"Dates Active",
"app.orders.testStatus.IN_PROGRESS":"Collecté",
"app.orders.testStatus.COMPLETED":"Rapporter",
"app.orders.testStatus.RECEIVED":"Reçu",
"app.orders.testStatus.EXCEPTION":"Pas effectué",
"app.orders.discontinue":"CESSER",
"app.orders.discontinue":"ABANDONNÉ",
"app.orders.discontinue.question":"Êtes-vous sûr de vouloir interrompre cette commande?",
"app.orders.discontinue.reason":"Raison de l'abandon",
"app.orders.discontinue.success": "Order discontinued successfully",
"app.orders.create.success":"Commande créée avec succès",
"app.orders.is.active":"l'ordre est actif"
"app.orders.is.active":"l'ordre est actif",
"app.orders.number":"Order number"
}
12 changes: 7 additions & 5 deletions app/js/translations/ht.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
"app.orders.testStatus.COMPLETED":"Reported",
"app.orders.testStatus.RECEIVED":"Received",
"app.orders.testStatus.EXCEPTION":"Not performed",
"app.orders.discontinue":"DISKONTINYE",
"app.orders.discontinue.question":"Èske ou sèten ou vle sispann lòd sa a?",
"app.orders.discontinue.reason":"Rezon pou sispann",
"app.orders.create.success":"Lòd siksè ki te kreye",
"app.orders.is.active":"lòd aktif"
"app.orders.discontinue":"DISCONTINUE",
"app.orders.discontinue.question":"Are you sure you want to discontinue this order ?",
"app.orders.discontinue.reason":"Reason for discontinuing",
"app.orders.discontinue.success": "Order discontinued successfully",
"app.orders.create.success":"Order Successfully Created",
"app.orders.is.active":"order is active",
"app.orders.number":"Order number"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/openmrs/openmrs-owa-orderentry"
},
"dependencies": {
"@openmrs/react-components": "^1.2.0",
"@openmrs/react-components": "^1.3.0",
"@openmrs/style-referenceapplication": "^0.1.0",
"ajv": "^6.4.0",
"axios": "^0.18.0",
Expand Down
25 changes: 18 additions & 7 deletions tests/middlewares/responseHandlerMiddleware.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import responseHandlerMiddleware from '../../app/js/middlewares/responseHandlerMiddleware.js';

describe('responseHandlerMiddleware', () => {
const nextHandler = responseHandlerMiddleware();

const mockState = {
getState: () => ({
openmrs: {
session: {
locale: 'en'
}
}
})
};

const nextHandler = responseHandlerMiddleware(mockState);
let nextArgs = [];
const fakeNext = (...args) => { nextArgs.push(args); };
const fakeStore = {};
Expand All @@ -21,7 +32,7 @@ describe('responseHandlerMiddleware', () => {
nextArgs = [];
nextHandler(fakeNext)(action);
expect(nextArgs[0]).toEqual([
{
{
type: 'GET_DATE_SUCCESS',
payload: action.payload,
dateFormat: 'DD-MMM-YYYY HH:mm'
Expand All @@ -40,7 +51,7 @@ describe('responseHandlerMiddleware', () => {
nextArgs = [];
nextHandler(fakeNext)(action);
expect(nextArgs[0]).toEqual([
{
{
type: 'GET_DATE_SUCCESS',
payload: action.payload,
dateFormat: 'DD-MMM-YYYY'
Expand All @@ -59,7 +70,7 @@ describe('responseHandlerMiddleware', () => {
nextArgs = [];
nextHandler(fakeNext)(action);
expect(nextArgs[0]).toEqual([
{
{
type: 'GET_DATE_FAILURE',
payload: Error('incomplete config'),
}
Expand All @@ -77,7 +88,7 @@ describe('responseHandlerMiddleware', () => {
nextArgs = [];
nextHandler(fakeNext)(action);
expect(nextArgs[0]).toEqual([
{
{
type: 'FETCH_ENCOUNTER_TYPE_FAILURE',
payload: Error('incomplete config'),
}
Expand All @@ -95,7 +106,7 @@ describe('responseHandlerMiddleware', () => {
nextArgs = [];
nextHandler(fakeNext)(action);
expect(nextArgs[0]).toEqual([
{
{
type: 'FETCH_ENCOUNTER_TYPE_SUCCESS',
data: { value : ['some encounter']},
payload: action.payload,
Expand Down Expand Up @@ -186,4 +197,4 @@ describe('responseHandlerMiddleware', () => {
}
])
})
});
});

0 comments on commit 6bc96c2

Please sign in to comment.