You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.9 KiB
77 lines
1.9 KiB
4 years ago
|
import PropTypes from 'prop-types';
|
||
|
import React, { Component } from 'react';
|
||
|
import { connect } from 'react-redux';
|
||
|
import { createSelector } from 'reselect';
|
||
|
import withScrollPosition from 'Components/withScrollPosition';
|
||
|
import { fetchReleases, setReleasesFilter, setReleasesSort, setReleasesTableOption } from 'Store/Actions/releaseActions';
|
||
|
import scrollPositions from 'Store/scrollPositions';
|
||
|
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
|
||
|
import createReleaseClientSideCollectionItemsSelector from 'Store/Selectors/createReleaseClientSideCollectionItemsSelector';
|
||
|
import SearchIndex from './SearchIndex';
|
||
|
|
||
|
function createMapStateToProps() {
|
||
|
return createSelector(
|
||
|
createReleaseClientSideCollectionItemsSelector('releases'),
|
||
|
createDimensionsSelector(),
|
||
|
(
|
||
|
movies,
|
||
|
dimensionsState
|
||
|
) => {
|
||
|
return {
|
||
|
...movies,
|
||
|
isSmallScreen: dimensionsState.isSmallScreen
|
||
|
};
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
function createMapDispatchToProps(dispatch, props) {
|
||
|
return {
|
||
|
onTableOptionChange(payload) {
|
||
|
dispatch(setReleasesTableOption(payload));
|
||
|
},
|
||
|
|
||
|
onSortSelect(sortKey) {
|
||
|
dispatch(setReleasesSort({ sortKey }));
|
||
|
},
|
||
|
|
||
|
onFilterSelect(selectedFilterKey) {
|
||
|
dispatch(setReleasesFilter({ selectedFilterKey }));
|
||
|
},
|
||
|
|
||
|
onSearchPress(payload) {
|
||
|
dispatch(fetchReleases(payload));
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
4 years ago
|
class SearchIndexConnector extends Component {
|
||
4 years ago
|
|
||
|
onScroll = ({ scrollTop }) => {
|
||
|
scrollPositions.movieIndex = scrollTop;
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// Render
|
||
|
|
||
|
render() {
|
||
|
return (
|
||
|
<SearchIndex
|
||
|
{...this.props}
|
||
|
onScroll={this.onScroll}
|
||
|
/>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
SearchIndexConnector.propTypes = {
|
||
4 years ago
|
isSmallScreen: PropTypes.bool.isRequired,
|
||
|
onSearchPress: PropTypes.func.isRequired,
|
||
|
items: PropTypes.arrayOf(PropTypes.object)
|
||
|
};
|
||
|
|
||
|
export default withScrollPosition(
|
||
4 years ago
|
connect(createMapStateToProps, createMapDispatchToProps)(SearchIndexConnector),
|
||
4 years ago
|
'releases'
|
||
|
);
|