fix: can still invite when api is pending (#28161)

This commit is contained in:
Joel 2025-11-13 15:28:32 +08:00 committed by GitHub
parent b75d533f9b
commit 667b1c37a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 4 deletions

View File

@ -17,8 +17,9 @@ import type { InvitationResult } from '@/models/common'
import I18n from '@/context/i18n'
import 'react-multi-email/dist/style.css'
import { noop } from 'lodash-es'
import { useProviderContextSelector } from '@/context/provider-context'
import { useBoolean } from 'ahooks'
type IInviteModalProps = {
isEmailSetup: boolean
onCancel: () => void
@ -49,9 +50,15 @@ const InviteModal = ({
const { locale } = useContext(I18n)
const [role, setRole] = useState<string>('normal')
const [isSubmitting, {
setTrue: setIsSubmitting,
setFalse: setIsSubmitted,
}] = useBoolean(false)
const handleSend = useCallback(async () => {
if (isLimitExceeded)
if (isLimitExceeded || isSubmitting)
return
setIsSubmitting()
if (emails.map((email: string) => emailRegex.test(email)).every(Boolean)) {
try {
const { result, invitation_results } = await inviteMember({
@ -70,7 +77,8 @@ const InviteModal = ({
else {
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 (
<div className={cn(s.wrap)}>
@ -133,7 +141,7 @@ const InviteModal = ({
tabIndex={0}
className='w-full'
onClick={handleSend}
disabled={!emails.length || isLimitExceeded}
disabled={!emails.length || isLimitExceeded || isSubmitting}
variant='primary'
>
{t('common.members.sendInvite')}