overleaf/services/web/frontend/js/features/share-project-modal/components/send-invites.js
Timothée Alby 6319455e91 Merge pull request #6236 from overleaf/ta-project-context-strict
Strict Project Context

GitOrigin-RevId: a0f7f2b3dcb29fbd0102dcb920cf5424a921d583
2022-01-11 09:05:03 +00:00

29 lines
872 B
JavaScript

import { useMemo } from 'react'
import { Row } from 'react-bootstrap'
import AddCollaborators from './add-collaborators'
import AddCollaboratorsUpgrade from './add-collaborators-upgrade'
import { useProjectContext } from '../../../shared/context/project-context'
export default function SendInvites() {
const { members, invites, features } = useProjectContext()
// whether the project has not reached the collaborator limit
const canAddCollaborators = useMemo(() => {
if (!features) {
return false
}
if (features.collaborators === -1) {
// infinite collaborators
return true
}
return members.length + invites.length < features.collaborators
}, [members, invites, features])
return (
<Row className="invite-controls">
{canAddCollaborators ? <AddCollaborators /> : <AddCollaboratorsUpgrade />}
</Row>
)
}