overleaf/services/web/frontend/js/features/share-project-modal/components/send-invites.js
Miguel Serrano b7802674d5 Merge pull request #4245 from overleaf/msm-extract-project-context
React `project-context`

GitOrigin-RevId: 6a23437d6e6a328ff5854622ff903d348db1f8b8
2021-06-26 02:05:49 +00:00

32 lines
881 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 project = useProjectContext()
// whether the project has not reached the collaborator limit
const canAddCollaborators = useMemo(() => {
if (!project) {
return false
}
if (project.features.collaborators === -1) {
// infinite collaborators
return true
}
return (
project.members.length + project.invites.length <
project.features.collaborators
)
}, [project])
return (
<Row className="invite-controls">
{canAddCollaborators ? <AddCollaborators /> : <AddCollaboratorsUpgrade />}
</Row>
)
}