import React from 'react'; import PropTypes from 'prop-types'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import Select from 'react-select'; import makeAnimated from 'react-select/lib/animated'; import { seafileAPI } from '../../utils/seafile-api.js'; import { gettext, isPro } from '../../utils/constants'; import UserSelect from '../user-select'; const propTypes = { itemName: PropTypes.string.isRequired, toggleDialog: PropTypes.func.isRequired, submit: PropTypes.func.isRequired, }; class TransferDialog extends React.Component { constructor(props) { super(props); this.state = { selectedOption: null, errorMsg: [], transferToUser: true, }; this.options = []; } handleSelectChange = (option) => { this.setState({selectedOption: option}); } submit = () => { let user = this.state.selectedOption; this.props.submit(user); } componentDidMount() { seafileAPI.listDepartments().then((res) => { for (let i = 0 ; i < res.data.length; i++) { let obj = {}; obj.value = res.data[i].name; obj.email = res.data[i].email; obj.label = res.data[i].name; this.options.push(obj); } }); } onClick = () => { this.setState({ transferToUser: !this.state.transferToUser, }); } render() { const itemName = this.props.itemName; const innerSpan = '' + itemName +''; let msg = gettext('Transfer Library {library_name}'); let message = msg.replace('{library_name}', innerSpan); return (
{this.state.transferToUser ? :