From 8df3cc0b103c2df64c3785e3db63276f7d0cde41 Mon Sep 17 00:00:00 2001 From: Srujan Gurram Date: Sat, 26 Oct 2024 20:57:55 +0530 Subject: [PATCH] Update chat settings form input handling logic --- src/components/Settings/Sections/ChatSettings.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/Settings/Sections/ChatSettings.tsx b/src/components/Settings/Sections/ChatSettings.tsx index 63739125..1e272ab0 100644 --- a/src/components/Settings/Sections/ChatSettings.tsx +++ b/src/components/Settings/Sections/ChatSettings.tsx @@ -1,13 +1,12 @@ -import * as Switch from '@radix-ui/react-switch' import React, { useState } from 'react' import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai' -import { useSettings } from '../../../hooks/useSettings' +import { Mode } from '../../../config/settings' import { useChatModels } from '../../../hooks/useChatModels' +import { useSettings } from '../../../hooks/useSettings' import { capitalizeText } from '../../../lib/capitalizeText' import { validateApiKey } from '../../../lib/validApiKey' import FieldWrapper from '../Elements/FieldWrapper' import SectionHeading from '../Elements/SectionHeading' -import { Mode } from '../../../config/settings' const ChatSettings = () => { const [settings, setSettings] = useSettings() @@ -22,10 +21,8 @@ const ChatSettings = () => { event: React.FormEvent, ) => { event.preventDefault() - const target = event.target as HTMLFormElement - - const apiKeyValue = target.openAiApiKey.value - const baseurlValue = target.openAiBaseUrl.value + const apiKeyValue = OpenAiApiKeyInputRef.current?.value || '' + const baseurlValue = OpenAiBaseUrlInputRef.current?.value || '' if (OpenAiApiKeyInputRef.current) { const isOpenAiKeyValid: boolean = await validateApiKey(