refactor: Update handlePromptChange logic to handle undefined value
This commit is contained in:
parent
f389e45401
commit
f630addefc
@ -63,13 +63,18 @@ export default function OptionLayout({
|
|||||||
return prompts?.find((prompt) => prompt.id === id)
|
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)
|
const prompt = getPromptInfoById(value)
|
||||||
if (prompt?.is_system) {
|
if (prompt?.is_system) {
|
||||||
setSelectedSystemPrompt(prompt.id)
|
setSelectedSystemPrompt(prompt.id)
|
||||||
} else {
|
} else {
|
||||||
|
setSelectedSystemPrompt(undefined)
|
||||||
setSelectedQuickPrompt(prompt!.content)
|
setSelectedQuickPrompt(prompt!.content)
|
||||||
setSelectedSystemPrompt("")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user