import { useState } from 'react' import { Modal, Button } from 'react-bootstrap' import { Trans } from 'react-i18next' import PropTypes from 'prop-types' import Icon from '../../../shared/components/icon' import { transferProjectOwnership } from '../utils/api' import AccessibleModal from '../../../shared/components/accessible-modal' import { reload } from '../../../shared/components/location' import { useProjectContext } from '../../../shared/context/project-context' export default function TransferOwnershipModal({ member, cancel }) { const [inflight, setInflight] = useState(false) const [error, setError] = useState(false) const { _id: projectId, name: projectName } = useProjectContext() function confirm() { setError(false) setInflight(true) transferProjectOwnership(projectId, member) .then(() => { reload() }) .catch(() => { setError(true) setInflight(false) }) } return (

, ]} shouldUnescape />

{inflight && } {error && ( )}
) } TransferOwnershipModal.propTypes = { member: PropTypes.object.isRequired, cancel: PropTypes.func.isRequired, }