import { useState } from 'react' import { Modal, Button } from 'react-bootstrap' import { Trans, useTranslation } 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 { useProjectContext } from '../../../shared/context/project-context' import { useLocation } from '../../../shared/hooks/use-location' export default function TransferOwnershipModal({ member, cancel }) { const { t } = useTranslation() const [inflight, setInflight] = useState(false) const [error, setError] = useState(false) const location = useLocation() const { _id: projectId, name: projectName } = useProjectContext() function confirm() { setError(false) setInflight(true) transferProjectOwnership(projectId, member) .then(() => { location.reload() }) .catch(() => { setError(true) setInflight(false) }) } return ( {t('change_project_owner')}

, ]} // eslint-disable-next-line react/jsx-boolean-value shouldUnescape={true} tOptions={{ interpolation: { escapeValue: true } }} />

{t('project_ownership_transfer_confirmation_2')}

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