From f630addefca8d0b375969d0b2f3e50294b6cb4a8 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Wed, 8 May 2024 10:22:50 +0530 Subject: [PATCH] refactor: Update handlePromptChange logic to handle undefined value --- src/components/Layouts/Layout.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Layouts/Layout.tsx b/src/components/Layouts/Layout.tsx index 296c641..03916be 100644 --- a/src/components/Layouts/Layout.tsx +++ b/src/components/Layouts/Layout.tsx @@ -63,13 +63,18 @@ export default function OptionLayout({ return prompts?.find((prompt) => prompt.id === id) } - const handlePromptChange = (value: string) => { + const handlePromptChange = (value?: string) => { + if (!value) { + setSelectedSystemPrompt(undefined) + setSelectedQuickPrompt(undefined) + return + } const prompt = getPromptInfoById(value) if (prompt?.is_system) { setSelectedSystemPrompt(prompt.id) } else { + setSelectedSystemPrompt(undefined) setSelectedQuickPrompt(prompt!.content) - setSelectedSystemPrompt("") } }