From 49f8e796f43e72c4901c42abff46dca9bb97fa08 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Sat, 2 Sep 2023 15:48:04 +0800 Subject: [PATCH] fix UI no data show default value --- packages/ui/src/views/chatflows/Configuration.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/views/chatflows/Configuration.js b/packages/ui/src/views/chatflows/Configuration.js index b49b87e7..4268fd08 100644 --- a/packages/ui/src/views/chatflows/Configuration.js +++ b/packages/ui/src/views/chatflows/Configuration.js @@ -36,13 +36,17 @@ const Configuration = () => { const obj = { rateLimit: {} } - - if (limitMax && limitDuration && limitMsg) + const rateLimitValuesBoolean = [!limitMax, !limitDuration, !limitMsg] + const rateLimitFilledValues = rateLimitValuesBoolean.filter((value) => value === false) + if (rateLimitFilledValues.length >= 1 && rateLimitFilledValues.length <= 2) { + throw new Error('Need to fill all rate limit input fields') + } else if (rateLimitFilledValues.length === 3) { obj.rateLimit = { limitMax, limitDuration, limitMsg } + } return obj } @@ -69,7 +73,9 @@ const Configuration = () => { } } catch (error) { console.error(error) - const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}` + const errorData = error.response + ? error.response.data || `${error.response.status}: ${error.response.statusText}` + : error.message enqueueSnackbar({ message: `Failed to save API Configuration: ${errorData}`, options: {