Skip to content

Commit

Permalink
fix a bug where surgery list is not properly selected when load in a …
Browse files Browse the repository at this point in the history
…state
  • Loading branch information
Haihan Lin authored and Haihan Lin committed Jun 11, 2020
1 parent c873727 commit ea54b9f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions frontend/src/Components/Utilities/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,24 @@ const SideBar: FC<Props> = ({ store }: Props) => {

//TODO this needs to check if the filterSelection is not empty

let tempMaxCaseCount = 0

let tempMaxCaseCount = 0;
let tempItemUnselected: any[] = [];
let tempItemSelected: any[] = [];
result.forEach((d: any) => {
tempMaxCaseCount = d.count > tempMaxCaseCount ? d.count : tempMaxCaseCount;
if (filterSelection.includes(d.value)) {
tempItemSelected.push(d)
} else {
tempItemUnselected.push(d)
}
})
result.sort((a: any, b: any) => b.count - a.count)
tempItemSelected.sort((a: any, b: any) => b.count - a.count)
tempItemUnselected.sort((a: any, b: any) => b.count - a.count)
setMaxCaseCount(tempMaxCaseCount)
stateUpdateWrapperUseJSON(procedureList, result, setProcedureList)
//setProcedureList(result);
setItemUnselected(result);
setItemUnselected(tempItemUnselected);
setItemSelected(tempItemSelected)
}

useEffect(() => {
Expand Down

0 comments on commit ea54b9f

Please sign in to comment.