send-invites.js 870 B

1234567891011121314151617181920212223242526272829303132
  1. import React, { useMemo } from 'react'
  2. import { Row } from 'react-bootstrap'
  3. import { useProjectContext } from './share-project-modal'
  4. import AddCollaborators from './add-collaborators'
  5. import AddCollaboratorsUpgrade from './add-collaborators-upgrade'
  6. export default function SendInvites() {
  7. const project = useProjectContext()
  8. // whether the project has not reached the collaborator limit
  9. const canAddCollaborators = useMemo(() => {
  10. if (!project) {
  11. return false
  12. }
  13. if (project.features.collaborators === -1) {
  14. // infinite collaborators
  15. return true
  16. }
  17. return (
  18. project.members.length + project.invites.length <
  19. project.features.collaborators
  20. )
  21. }, [project])
  22. return (
  23. <Row className="invite-controls">
  24. {canAddCollaborators ? <AddCollaborators /> : <AddCollaboratorsUpgrade />}
  25. </Row>
  26. )
  27. }