equal
deleted
inserted
replaced
|
1 import React from 'react'; |
|
2 import PropTypes from 'prop-types'; |
|
3 import { connect } from 'react-redux'; |
|
4 |
|
5 import _ from 'lodash'; |
|
6 import AnnotationsCards from '../ui/AnnotationsCards'; |
|
7 |
|
8 const AnnotationsPage = ({ |
|
9 annotations, |
|
10 viaBaseUrl, |
|
11 metacategories, |
|
12 topics, |
|
13 }) => ( |
|
14 <AnnotationsCards |
|
15 annotations={annotations} |
|
16 viaBaseUrl={viaBaseUrl} |
|
17 metacategories={metacategories} |
|
18 categories={topics} |
|
19 /> |
|
20 ); |
|
21 |
|
22 AnnotationsPage.propTypes = { |
|
23 // title: PropTypes.string, |
|
24 annotations: PropTypes.array.isRequired, |
|
25 viaBaseUrl: PropTypes.string.isRequired, |
|
26 metacategories: PropTypes.arrayOf(PropTypes.object).isRequired, |
|
27 topics: PropTypes.arrayOf(PropTypes.string).isRequired, |
|
28 }; |
|
29 |
|
30 export default connect( |
|
31 (state, props) => { |
|
32 let annotations = state.annotations.items; |
|
33 let tag = (props.match.params || {}).tagName; |
|
34 if (tag) { |
|
35 tag = tag.toLowerCase(); |
|
36 annotations = _.filter( |
|
37 annotations, |
|
38 annot => _.find( |
|
39 annot.tags, |
|
40 t => t.toLowerCase() === tag, |
|
41 ), |
|
42 ); |
|
43 } |
|
44 return { |
|
45 annotations, |
|
46 }; |
|
47 }, |
|
48 )(AnnotationsPage); |