Formating studyDate field

This commit is contained in:
maltempi 2019-02-15 23:36:33 -02:00
parent 04dc3724ff
commit 94ab9ff791
2 changed files with 27 additions and 19 deletions

View File

@ -1 +1 @@
export default '993b50e3bce2cc6f007212aea6d0ace66543226b';
export default '04dc3724ff959226b3178438e9bf6096fc923ef3';

View File

@ -4,6 +4,7 @@ import OHIF from 'ohif-core';
import { withRouter } from 'react-router-dom';
import { StudyList } from 'react-viewerbase';
import ConnectedHeader from '../connectedComponents/ConnectedHeader.js';
import moment from 'moment';
const subtractDaysFromDate = (date, days) => {
date.setDate(date.getDate() - days);
@ -75,25 +76,32 @@ class StudyListWithData extends Component {
}
const { field, order } = searchData.sortData;
const sortedStudies = studies.sort(function(a, b) {
if (order === 'desc') {
if (a[field] < b[field]) {
return -1;
const sortedStudies = studies
.sort(function(a, b) {
if (order === 'desc') {
if (a[field] < b[field]) {
return -1;
}
if (a[field] > b[field]) {
return 1;
}
return 0;
} else {
if (a[field] > b[field]) {
return -1;
}
if (a[field] < b[field]) {
return 1;
}
return 0;
}
if (a[field] > b[field]) {
return 1;
}
return 0;
} else {
if (a[field] > b[field]) {
return -1;
}
if (a[field] < b[field]) {
return 1;
}
return 0;
}
});
})
.map(study => {
study.studyDate = moment(study.studyDate, 'YYYYMMDD').format(
'MMM DD, YYYY'
);
return study;
});
this.setState({
studies: sortedStudies,