import React, { useCallback } from 'react' import PropTypes from 'prop-types' import { useProjectContext, useShareProjectContext, } from './share-project-modal' import Icon from '../../../shared/components/icon' import { Button, Col, Row, OverlayTrigger, Tooltip } from 'react-bootstrap' import { Trans } from 'react-i18next' import MemberPrivileges from './member-privileges' import { resendInvite, revokeInvite } from '../utils/api' export default function Invite({ invite, isAdmin }) { return (
{invite.email}
.  {isAdmin && }
{isAdmin && ( )}
) } Invite.propTypes = { invite: PropTypes.object.isRequired, isAdmin: PropTypes.bool.isRequired, } function ResendInvite({ invite }) { const { monitorRequest } = useShareProjectContext() const project = useProjectContext() // const buttonRef = useRef(null) // const handleClick = useCallback( () => monitorRequest(() => resendInvite(project, invite)).finally(() => { // NOTE: disabled as react-bootstrap v0.33.1 isn't forwarding the ref to the `button` // if (buttonRef.current) { // buttonRef.current.blur() // } document.activeElement.blur() }), [invite, monitorRequest, project] ) return ( ) } ResendInvite.propTypes = { invite: PropTypes.object.isRequired, } function RevokeInvite({ invite }) { const { updateProject, monitorRequest } = useShareProjectContext() const project = useProjectContext() function handleClick(event) { event.preventDefault() monitorRequest(() => revokeInvite(project, invite)).then(() => { updateProject({ invites: project.invites.filter(existing => existing !== invite), }) }) } return ( } > ) } RevokeInvite.propTypes = { invite: PropTypes.object.isRequired, }