import { useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import PropTypes from 'prop-types' import Icon from '@/shared/components/icon' import { transferProjectOwnership } from '../../utils/api' import { useProjectContext } from '@/shared/context/project-context' import { useLocation } from '@/shared/hooks/use-location' import OLModal, { OLModalBody, OLModalFooter, OLModalHeader, OLModalTitle, } from '@/features/ui/components/ol/ol-modal' import OLNotification from '@/features/ui/components/ol/ol-notification' import OLButton from '@/features/ui/components/ol/ol-button' import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher' import { bsVersion } from '@/features/utils/bootstrap-5' import { Spinner } from 'react-bootstrap-5' 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')}

, ]} shouldUnescape tOptions={{ interpolation: { escapeValue: true } }} />

{t('project_ownership_transfer_confirmation_2')}

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