-
Notifications
You must be signed in to change notification settings - Fork 51
/
index.js
32 lines (27 loc) · 980 Bytes
/
index.js
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
import { connect } from 'react-redux'
import GlossaryTermModal from './component'
import { map } from 'lodash'
import { showGlossaryDetails } from '../../actions/glossary-actions'
function mapStateToProps (state) {
const { context, glossary, headerData } = state
const { details, results, searchText } = glossary
const { byId, resultIndex, show } = details
const term = results.get(searchText)[resultIndex]
// undefined items are kept, that just indicates the detail has not been
// returned from the API yet.
const detailItems = term && term.sourceIdList
? map(term.sourceIdList, id => byId[id]) : []
return {
show,
sourceLocale: context.sourceLocale.localeId,
targetLocale: headerData.context.selectedLocale,
term,
details: detailItems
}
}
function mapDispatchToProps (dispatch) {
return {
close: () => dispatch(showGlossaryDetails(false))
}
}
export default connect(mapStateToProps, mapDispatchToProps)(GlossaryTermModal)