From a70eda6c4587b83876c4cb0a45142fd46ad04a3c Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 28 Nov 2024 13:09:43 +0800 Subject: [PATCH] add loading for auth modal --- .../tools/setting/build-in/config-credentials.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/app/components/tools/setting/build-in/config-credentials.tsx b/web/app/components/tools/setting/build-in/config-credentials.tsx index 167cef27f1..b82c243c75 100644 --- a/web/app/components/tools/setting/build-in/config-credentials.tsx +++ b/web/app/components/tools/setting/build-in/config-credentials.tsx @@ -34,6 +34,7 @@ const ConfigCredential: FC = ({ const [credentialSchema, setCredentialSchema] = useState(null) const { name: collectionName } = collection const [tempCredential, setTempCredential] = React.useState({}) + const [isLoading, setIsLoading] = React.useState(false) useEffect(() => { fetchBuiltInToolCredentialSchema(collectionName).then(async (res) => { const toolCredentialSchemas = toolCredentialToFormSchemas(res) @@ -45,14 +46,16 @@ const ConfigCredential: FC = ({ }) }, []) - const handleSave = () => { + const handleSave = async () => { for (const field of credentialSchema) { if (field.required && !tempCredential[field.name]) { Toast.notify({ type: 'error', message: t('common.errorMsg.fieldRequired', { field: field.label[language] || field.label.en_US }) }) return } } - onSaved(tempCredential) + setIsLoading(true) + await onSaved(tempCredential) + setIsLoading(false) } return ( @@ -102,7 +105,7 @@ const ConfigCredential: FC = ({ } < div className='flex space-x-2'> - +