send-invites.js 872 B

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