This commit is contained in:
Mckay Wrigley
2023-03-27 09:38:56 -06:00
committed by GitHub
parent 2269403806
commit 34c79c0d66
51 changed files with 1744 additions and 295 deletions
+22
View File
@@ -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));
};