Skip to content

Commit

Permalink
#5428 App crashing in dispensing mode
Browse files Browse the repository at this point in the history
#5428 App crashing in dispensing mode
  • Loading branch information
sah-arjun committed Jan 17, 2024
1 parent 535348c commit 6a89099
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/reducers/DispensaryReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,31 @@ export const DispensaryReducer = (state = initialState(), action) => {
const { usingAdverseDrugReactions } = payload;
const { dataSet } = state;

// Default to patient
let sortBy = 'createdDate';
let isAscending = false;

const patientDataSet = usingAdverseDrugReactions
? 'patientWithAdverseDrugReactions'
: 'patient';

const prescriberDataSet = 'prescriber';
const newDataSet = dataSet === patientDataSet ? prescriberDataSet : patientDataSet;

const newColumns = getColumns(newDataSet);

if (newDataSet === 'prescriber') {
sortBy = 'firstName';
isAscending = true;
}

const newData = UIDatabase.objects(newDataSet === patientDataSet ? 'Patient' : 'Prescriber');

return {
...state,
dataSet: newDataSet,
columns: newColumns,
sortKey: 'createdDate',
isAscending: false,
sortKey: sortBy,
isAscending,
searchTerm: '',
data: newData,
};
Expand Down

0 comments on commit 6a89099

Please sign in to comment.