Skip to content

Commit 428333e

Browse files
committed
Sorts search results by last name, first name
1 parent d5de110 commit 428333e

File tree

1 file changed

+15
-5
lines changed
  • src/client/src/pages/DataView360/Search

1 file changed

+15
-5
lines changed

src/client/src/pages/DataView360/Search/Search.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
CircularProgress
1919
} from '@material-ui/core';
2020

21-
import _ from 'lodash';
21+
import _, { lowerCase } from 'lodash';
2222
import SearchBar from './components/SearchBar';
2323
import {formatPhoneNumber} from "../../../utils/utils";
2424
import Grid from "@material-ui/core/Grid";
@@ -104,14 +104,24 @@ class Search360 extends Component {
104104
})
105105
}
106106

107+
namesToLowerCase(participant) {
108+
let first_name = participant.first_name
109+
let last_name = participant.last_name
110+
111+
return {
112+
...participant,
113+
lower_first_name: lowerCase(first_name),
114+
lower_last_name: lowerCase(last_name)
115+
}
116+
}
117+
107118
renderParticipantsTable() {
108119
const {classes} = this.props;
109120
const tableRowColors = [classes.tableRowEven, classes.tableRowOdd]
110121

111-
let participantListGrouped = _.groupBy(this.state.participantList, "matching_id");
112-
participantListGrouped = _.reverse(_.sortBy(participantListGrouped, matching_group => {
113-
return _.size(matching_group);
114-
}));
122+
let participantListGrouped = _.map(this.state.participantList, this.namesToLowerCase)
123+
participantListGrouped = _.groupBy(participantListGrouped, "matching_id");
124+
participantListGrouped = _.orderBy(participantListGrouped, ['0.lower_last_name', '0.lower_first_name']);
115125

116126
return (
117127
<Grid container direction={"column"} justify={"center"}>

0 commit comments

Comments
 (0)