import { useState } from 'react' import { Trans, useTranslation } from 'react-i18next' 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 { Spinner } from 'react-bootstrap' import { ProjectMember } from '@/shared/context/types/project-metadata' export default function TransferOwnershipModal({ member, cancel, }: { member: ProjectMember cancel: () => void }) { const { t } = useTranslation() const [inflight, setInflight] = useState(false) const [error, setError] = useState(false) const location = useLocation() const { 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 && (
{t('cancel')} {t('change_owner')}
) }