scinote-web/app/javascript/packs/shared/modals_container/modals/LeaveTeamModal.jsx

91 lines
2.7 KiB
React
Raw Normal View History

2017-08-25 14:54:32 +08:00
import React, { Component } from "react";
2017-08-25 22:40:23 +08:00
import PropTypes, { bool, number, string, func } from "prop-types";
import { Modal, Button, Alert, Glyphicon } from "react-bootstrap";
import { FormattedMessage, FormattedHTMLMessage } from "react-intl";
2017-08-25 14:54:32 +08:00
import { connect } from "react-redux";
2017-08-28 15:36:21 +08:00
import axios from '../../../app/axios';
2017-08-25 14:54:32 +08:00
2017-08-25 22:40:23 +08:00
import { leaveTeamModalShow } from "../../actions/LeaveTeamActions";
2017-08-25 14:54:32 +08:00
class LeaveTeamModal extends Component {
2017-08-25 22:40:23 +08:00
constructor(props) {
super(props);
this.onCloseModal = this.onCloseModal.bind(this);
2017-08-28 15:36:21 +08:00
this.leaveTeam = this.leaveTeam.bind(this);
2017-08-25 22:40:23 +08:00
}
onCloseModal() {
this.props.leaveTeamModalShow(false);
}
2017-08-25 22:07:37 +08:00
2017-08-28 15:36:21 +08:00
leaveTeam() {
}
2017-08-25 14:54:32 +08:00
render() {
return (
2017-08-25 22:40:23 +08:00
<Modal show={this.props.showModal} onHide={this.onCloseModal}>
2017-08-25 14:54:32 +08:00
<Modal.Header closeButton>
<Modal.Title>
2017-08-25 22:07:37 +08:00
<FormattedMessage
id="settings_page.leave_team_modal.title"
values={{ teamName: this.props.teamName }}
/>
2017-08-25 14:54:32 +08:00
</Modal.Title>
</Modal.Header>
2017-08-25 22:40:23 +08:00
<Modal.Body>
<p>
<FormattedMessage id="settings_page.leave_team_modal.subtitle" />
</p>
<Alert bsStyle="danger">
2017-08-28 15:36:21 +08:00
<Glyphicon glyph="exclamation-sign" />&nbsp;
2017-08-25 22:40:23 +08:00
<FormattedMessage id="settings_page.leave_team_modal.warnings" />
<ul>
<li>
<FormattedMessage id="settings_page.leave_team_modal.warning_message_one" />
</li>
<li>
<FormattedHTMLMessage id="settings_page.leave_team_modal.warning_message_two" />
</li>
<li>
<FormattedMessage id="settings_page.leave_team_modal.warning_message_three" />
</li>
</ul>
</Alert>
</Modal.Body>
2017-08-25 14:54:32 +08:00
<Modal.Footer>
2017-08-25 22:40:23 +08:00
<Button onClick={this.onCloseModal}>
2017-08-25 14:54:32 +08:00
<FormattedMessage id="general.close" />
</Button>
2017-08-28 15:36:21 +08:00
<Button bsStyle="success" onClick={this.leaveTeam}>
<FormattedMessage id="settings_page.leave_team_modal.leave" />
</Button>
2017-08-25 14:54:32 +08:00
</Modal.Footer>
</Modal>
);
}
}
2017-08-25 22:07:37 +08:00
LeaveTeamModal.propTypes = {
showModal: bool.isRequired,
teamId: number.isRequired,
teamName: string.isRequired,
2017-08-25 22:40:23 +08:00
leaveTeamModalShow: func.isRequired,
2017-08-25 22:07:37 +08:00
teams: PropTypes.arrayOf(
PropTypes.shape({
id: number.isRequired,
name: string.isRequired,
current_team: bool.isRequired,
role: string.isRequired,
2017-08-25 22:40:23 +08:00
members: number.isRequired
2017-08-25 22:07:37 +08:00
}).isRequired
)
};
2017-08-25 14:54:32 +08:00
const mapStateToProps = ({ showLeaveTeamModal }) => ({
showModal: showLeaveTeamModal.show,
2017-08-25 22:07:37 +08:00
teamId: showLeaveTeamModal.id,
teamName: showLeaveTeamModal.teamName
2017-08-25 14:54:32 +08:00
});
2017-08-25 22:40:23 +08:00
export default connect(mapStateToProps, { leaveTeamModalShow })(LeaveTeamModal);