refactor: Update handlePromptChange logic to handle undefined value

This commit is contained in:
n4ze3m 2024-05-08 10:22:50 +05:30
parent f389e45401
commit f630addefc

View File

@ -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("")
}
}