mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat: Pagination component.
This commit is contained in:
31
client/src/containers/Router/withRouteActions.js
Normal file
31
client/src/containers/Router/withRouteActions.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
|
||||
const mapDispatchToProps = (dispatch, props) => {
|
||||
return {
|
||||
addQuery: (key, value) => {
|
||||
let pathname = props.location.pathname;
|
||||
let searchParams = new URLSearchParams(props.location.search);
|
||||
|
||||
searchParams.set(key, value);
|
||||
|
||||
props.history.push({
|
||||
pathname: pathname,
|
||||
search: searchParams.toString(),
|
||||
});
|
||||
},
|
||||
|
||||
removeQuery: (key) => {
|
||||
let pathname = props.location.pathname;
|
||||
let searchParams = new URLSearchParams(props.location.search);
|
||||
// returns the existing query string: '?type=fiction&author=fahid'
|
||||
searchParams.delete(key);
|
||||
props.history.push({
|
||||
pathname: pathname,
|
||||
search: searchParams.toString(),
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(null, mapDispatchToProps)
|
||||
Reference in New Issue
Block a user