import React from 'react'; import PropTypes from 'prop-types'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { gettext } from '../../utils/constants'; import { seafileAPI } from '../../utils/seafile-api.js'; import UserSelect from '../user-select'; import '../../css/transfer-group-dialog.css'; const propTypes = { groupID: PropTypes.string.isRequired, toggleTransferGroupDialog: PropTypes.func.isRequired, onGroupChanged: PropTypes.func.isRequired }; class TransferGroupDialog extends React.Component { constructor(props) { super(props); this.state = { selectedOption: null, errMessage: '', }; this.options = []; } handleSelectChange = (option) => { this.setState({ selectedOption: option, errMessage: '', }); this.options = []; } transferGroup = () => { const email = this.state.selectedOption && this.state.selectedOption.email; if (email) { seafileAPI.transferGroup(this.props.groupID, email).then((res) => { this.props.toggleTransferGroupDialog(); }).catch((error) => { if (error.response) { this.setState({ errMessage: error.response.data.error_msg }); } }); } } toggle = () => { this.props.toggleTransferGroupDialog(); } render() { return ( {gettext('Transfer Group')}

{gettext('Transfer group to')}

{this.state.errMessage}
); } } TransferGroupDialog.propTypes = propTypes; export default TransferGroupDialog;