2021-06-18 09:04:31 -07:00
|
|
|
import { connect } from 'react-redux';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2021-06-18 09:04:31 -07:00
|
|
|
import { addSchedule, removeSchedule } from '../../../actions/compose';
|
2022-01-10 14:17:52 -08:00
|
|
|
import ScheduleButton from '../components/schedule_button';
|
2021-06-18 09:04:31 -07:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
active: state.getIn(['compose', 'schedule']) ? true : false,
|
2022-05-03 14:00:07 -07:00
|
|
|
unavailable: !!state.getIn(['compose', 'id']),
|
2021-06-18 09:04:31 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
|
|
|
|
onClick() {
|
2021-06-27 22:06:04 -07:00
|
|
|
dispatch((dispatch, getState) => {
|
2021-06-18 09:04:31 -07:00
|
|
|
if (getState().getIn(['compose', 'schedule'])) {
|
|
|
|
dispatch(removeSchedule());
|
|
|
|
} else {
|
|
|
|
dispatch(addSchedule());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ScheduleButton);
|