|
@@ -1,4 +1,4 @@
|
|
|
-import { useState, useMemo } from 'react'
|
|
|
|
|
|
|
+import { useState, useMemo, useCallback } from 'react'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
import { Form, FormGroup, FormControl, Button } from 'react-bootstrap'
|
|
import { Form, FormGroup, FormControl, Button } from 'react-bootstrap'
|
|
|
import { useMultipleSelection } from 'downshift'
|
|
import { useMultipleSelection } from 'downshift'
|
|
@@ -9,6 +9,7 @@ import { useUserContacts } from '../hooks/use-user-contacts'
|
|
|
import useIsMounted from '../../../shared/hooks/use-is-mounted'
|
|
import useIsMounted from '../../../shared/hooks/use-is-mounted'
|
|
|
import { useProjectContext } from '../../../shared/context/project-context'
|
|
import { useProjectContext } from '../../../shared/context/project-context'
|
|
|
import { sendMB } from '../../../infrastructure/event-tracking'
|
|
import { sendMB } from '../../../infrastructure/event-tracking'
|
|
|
|
|
+import ClickableElementEnhancer from '@/shared/components/clickable-element-enhancer'
|
|
|
|
|
|
|
|
export default function AddCollaborators() {
|
|
export default function AddCollaborators() {
|
|
|
const [privileges, setPrivileges] = useState('readAndWrite')
|
|
const [privileges, setPrivileges] = useState('readAndWrite')
|
|
@@ -45,9 +46,7 @@ export default function AddCollaborators() {
|
|
|
|
|
|
|
|
const { reset, selectedItems } = multipleSelectionProps
|
|
const { reset, selectedItems } = multipleSelectionProps
|
|
|
|
|
|
|
|
- async function handleSubmit(event) {
|
|
|
|
|
- event.preventDefault()
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const handleSubmit = useCallback(async () => {
|
|
|
if (!selectedItems.length) {
|
|
if (!selectedItems.length) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -125,10 +124,22 @@ export default function AddCollaborators() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
setInFlight(false)
|
|
setInFlight(false)
|
|
|
- }
|
|
|
|
|
|
|
+ }, [
|
|
|
|
|
+ currentMemberEmails,
|
|
|
|
|
+ invites,
|
|
|
|
|
+ isMounted,
|
|
|
|
|
+ members,
|
|
|
|
|
+ privileges,
|
|
|
|
|
+ projectId,
|
|
|
|
|
+ reset,
|
|
|
|
|
+ selectedItems,
|
|
|
|
|
+ setError,
|
|
|
|
|
+ setInFlight,
|
|
|
|
|
+ updateProject,
|
|
|
|
|
+ ])
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <Form onSubmit={handleSubmit}>
|
|
|
|
|
|
|
+ <Form>
|
|
|
<FormGroup>
|
|
<FormGroup>
|
|
|
<SelectCollaborators
|
|
<SelectCollaborators
|
|
|
loading={!nonMemberContacts}
|
|
loading={!nonMemberContacts}
|
|
@@ -151,9 +162,13 @@ export default function AddCollaborators() {
|
|
|
<option value="readOnly">{t('read_only')}</option>
|
|
<option value="readOnly">{t('read_only')}</option>
|
|
|
</FormControl>
|
|
</FormControl>
|
|
|
<span> </span>
|
|
<span> </span>
|
|
|
- <Button type="submit" bsStyle="primary">
|
|
|
|
|
|
|
+ <ClickableElementEnhancer
|
|
|
|
|
+ as={Button}
|
|
|
|
|
+ onClick={handleSubmit}
|
|
|
|
|
+ bsStyle="primary"
|
|
|
|
|
+ >
|
|
|
{t('share')}
|
|
{t('share')}
|
|
|
- </Button>
|
|
|
|
|
|
|
+ </ClickableElementEnhancer>
|
|
|
</div>
|
|
</div>
|
|
|
</FormGroup>
|
|
</FormGroup>
|
|
|
</Form>
|
|
</Form>
|