Skip to content

Commit 4e31536

Browse files
committed
Custom date range now no-ops
1 parent dabc101 commit 4e31536

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

webapp/javascript/components/DateRangePicker.jsx

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import React, { useState } from "react";
2-
import { connect } from "react-redux";
2+
import { useDispatch, useSelector } from "react-redux";
33

44
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
55
import { faClock } from "@fortawesome/free-solid-svg-icons";
66

77
import OutsideClickHandler from "react-outside-click-handler";
88
import moment from "moment";
9-
import { bindActionCreators } from "redux";
10-
import { setDateRange, receiveJSON, setFrom, setUntil } from "../redux/actions";
9+
import { setDateRange } from "../redux/actions";
1110

1211
const defaultPresets = [
1312
[
@@ -42,8 +41,11 @@ const multiplierMapping = {
4241
y: "year",
4342
};
4443

45-
function DateRangePicker(props) {
46-
const { from, until, actions } = props;
44+
function DateRangePicker() {
45+
const dispatch = useDispatch();
46+
const from = useSelector((state) => state.from);
47+
const until = useSelector((state) => state.until);
48+
4749
const initialState = {
4850
// so the idea with this is that we don't want to send from and until back to the state
4951
// until the user clicks some button. This is why these are stored in state here.
@@ -63,7 +65,7 @@ function DateRangePicker(props) {
6365
};
6466

6567
const updateDateRange = () => {
66-
actions.setDateRange(state.from, state.until);
68+
dispatch(setDateRange(from, until));
6769
};
6870

6971
const humanReadableRange = () => {
@@ -90,7 +92,7 @@ function DateRangePicker(props) {
9092
};
9193

9294
const selectPreset = ({ from, until }) => {
93-
actions.setDateRange(from, until);
95+
dispatch(setDateRange(from, until));
9496
hideDropdown();
9597
};
9698

@@ -132,7 +134,7 @@ function DateRangePicker(props) {
132134
className="followed-by-btn"
133135
onChange={(e) => updateFrom(e.target.value)}
134136
onBlur={updateDateRange}
135-
value={state.from}
137+
value={from}
136138
/>
137139
<button className="drp-calendar-btn btn" onClick={updateDateRange}>
138140
<FontAwesomeIcon icon={faClock} />
@@ -144,7 +146,7 @@ function DateRangePicker(props) {
144146
className="followed-by-btn"
145147
onChange={(e) => updateUntil(e.target.value)}
146148
onBlur={updateDateRange}
147-
value={state.until}
149+
value={until}
148150
/>
149151
<button className="drp-calendar-btn btn" onClick={updateDateRange}>
150152
<FontAwesomeIcon icon={faClock} />
@@ -157,20 +159,4 @@ function DateRangePicker(props) {
157159
);
158160
}
159161

160-
const mapStateToProps = (state) => ({
161-
...state,
162-
});
163-
164-
const mapDispatchToProps = (dispatch) => ({
165-
actions: bindActionCreators(
166-
{
167-
setDateRange,
168-
receiveJSON,
169-
setFrom,
170-
setUntil,
171-
},
172-
dispatch
173-
),
174-
});
175-
176-
export default connect(mapStateToProps, mapDispatchToProps)(DateRangePicker);
162+
export default DateRangePicker;

0 commit comments

Comments
 (0)