import React from 'react'; import { connect } from 'react-redux'; import { Button, Modal, Form, Icon, Checkbox, Input } from 'UI'; import styles from './funnelSaveModal.module.css'; import { edit, save, fetchList as fetchFunnelsList } from 'Duck/funnels'; @connect( (state) => ({ filter: state.getIn(['search', 'instance']), funnel: state.getIn(['funnels', 'instance']), loading: state.getIn(['funnels', 'saveRequest', 'loading']) || state.getIn(['funnels', 'updateRequest', 'loading']), }), { edit, save, fetchFunnelsList } ) export default class FunnelSaveModal extends React.PureComponent { state = { name: 'Untitled', isPublic: false }; static getDerivedStateFromProps(props) { if (!props.show) { return { name: props.funnel.name || 'Untitled', isPublic: props.funnel.isPublic, }; } return null; } onNameChange = ({ target: { value } }) => { this.props.edit({ name: value }); }; onChangeOption = (e, { checked, name }) => this.props.edit({ [name]: checked }); onSave = () => { const { funnel, filter } = this.props; if (funnel.name && funnel.name.trim() === '') return; this.props.save(funnel).then( function () { this.props.fetchFunnelsList(); this.props.closeHandler(); }.bind(this) ); }; render() { const { show, closeHandler, loading, funnel } = this.props; return (
{'Save Funnel'}
this.props.edit({ isPublic: !funnel.isPublic })} > Team Visible
); } }