Prompts (#229)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { Prompt } from '@/types/prompt';
|
||||
|
||||
export const updatePrompt = (updatedPrompt: Prompt, allPrompts: Prompt[]) => {
|
||||
const updatedPrompts = allPrompts.map((c) => {
|
||||
if (c.id === updatedPrompt.id) {
|
||||
return updatedPrompt;
|
||||
}
|
||||
|
||||
return c;
|
||||
});
|
||||
|
||||
savePrompts(updatedPrompts);
|
||||
|
||||
return {
|
||||
single: updatedPrompt,
|
||||
all: updatedPrompts,
|
||||
};
|
||||
};
|
||||
|
||||
export const savePrompts = (prompts: Prompt[]) => {
|
||||
localStorage.setItem('prompts', JSON.stringify(prompts));
|
||||
};
|
||||
Reference in New Issue
Block a user