mirror of
https://github.com/langgenius/dify.git
synced 2026-04-23 00:18:22 +08:00
fix: can still invite when api is pending (#28161)
This commit is contained in:
parent
8e01eb4561
commit
168a1524b2
@ -17,8 +17,9 @@ import type { InvitationResult } from '@/models/common'
|
|||||||
import I18n from '@/context/i18n'
|
import I18n from '@/context/i18n'
|
||||||
import 'react-multi-email/dist/style.css'
|
import 'react-multi-email/dist/style.css'
|
||||||
import { noop } from 'lodash-es'
|
import { noop } from 'lodash-es'
|
||||||
|
|
||||||
import { useProviderContextSelector } from '@/context/provider-context'
|
import { useProviderContextSelector } from '@/context/provider-context'
|
||||||
|
import { useBoolean } from 'ahooks'
|
||||||
|
|
||||||
type IInviteModalProps = {
|
type IInviteModalProps = {
|
||||||
isEmailSetup: boolean
|
isEmailSetup: boolean
|
||||||
onCancel: () => void
|
onCancel: () => void
|
||||||
@ -49,9 +50,15 @@ const InviteModal = ({
|
|||||||
const { locale } = useContext(I18n)
|
const { locale } = useContext(I18n)
|
||||||
const [role, setRole] = useState<string>('normal')
|
const [role, setRole] = useState<string>('normal')
|
||||||
|
|
||||||
|
const [isSubmitting, {
|
||||||
|
setTrue: setIsSubmitting,
|
||||||
|
setFalse: setIsSubmitted,
|
||||||
|
}] = useBoolean(false)
|
||||||
|
|
||||||
const handleSend = useCallback(async () => {
|
const handleSend = useCallback(async () => {
|
||||||
if (isLimitExceeded)
|
if (isLimitExceeded || isSubmitting)
|
||||||
return
|
return
|
||||||
|
setIsSubmitting()
|
||||||
if (emails.map((email: string) => emailRegex.test(email)).every(Boolean)) {
|
if (emails.map((email: string) => emailRegex.test(email)).every(Boolean)) {
|
||||||
try {
|
try {
|
||||||
const { result, invitation_results } = await inviteMember({
|
const { result, invitation_results } = await inviteMember({
|
||||||
@ -70,7 +77,8 @@ const InviteModal = ({
|
|||||||
else {
|
else {
|
||||||
notify({ type: 'error', message: t('common.members.emailInvalid') })
|
notify({ type: 'error', message: t('common.members.emailInvalid') })
|
||||||
}
|
}
|
||||||
}, [isLimitExceeded, emails, role, locale, onCancel, onSend, notify, t])
|
setIsSubmitted()
|
||||||
|
}, [isLimitExceeded, emails, role, locale, onCancel, onSend, notify, t, isSubmitting])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn(s.wrap)}>
|
<div className={cn(s.wrap)}>
|
||||||
@ -133,7 +141,7 @@ const InviteModal = ({
|
|||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className='w-full'
|
className='w-full'
|
||||||
onClick={handleSend}
|
onClick={handleSend}
|
||||||
disabled={!emails.length || isLimitExceeded}
|
disabled={!emails.length || isLimitExceeded || isSubmitting}
|
||||||
variant='primary'
|
variant='primary'
|
||||||
>
|
>
|
||||||
{t('common.members.sendInvite')}
|
{t('common.members.sendInvite')}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user