-
Notifications
You must be signed in to change notification settings - Fork 12
/
Results.jsx
51 lines (45 loc) · 1.81 KB
/
Results.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import { Pagination } from '@material-ui/lab'
import { map, startCase, includes, uniq, without } from 'lodash';
import RowComponent from './RowComponent';
const Results = props => {
const { resource, results } = props;
const [selectedList, setSelectedList] = React.useState([]);
const onSelectChange = (event, id) => {
const newSelectedList = event.target.checked ? uniq([...selectedList, id]) : without(selectedList, id);
setSelectedList(newSelectedList)
if (props.onSelectChange) props.onSelectChange(newSelectedList);
}
return (
<div className='col-sm-12 no-side-padding' style={{width: '100%'}}>
{
results.total ?
<div className='col-sm-12 no-side-padding' style={{width: '100%'}}>
{
includes(['concepts', 'mappings'], resource) ?
map(results.items, item => (
<RowComponent key={item.id} onSelect={onSelectChange} item={item} resource={resource} />
)) :
<div className="col-sm-12 no-side-padding" style={{textAlign: 'center', margin: '10px 0', width: '100%'}}>
{`This view is not implemented yet for ${startCase(props.resource)}`}
</div>
}
<div className='col-sm-12 no-side-padding pagination' style={{textAlign: 'center', marginTop: '10px', width: '100%'}}>
<Pagination
onChange={(event, page) => props.onPageChange(page)}
count={results.pages}
variant="outlined"
shape="rounded"
color="primary"
showFirstButton
showLastButton
page={results.pageNumber}
/>
</div>
</div> :
<div style={{padding: '2px'}}>We found 0 {startCase(resource)}.</div>
}
</div>
)
}
export default Results