mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
31 lines
819 B
JavaScript
31 lines
819 B
JavaScript
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)
|