feat(recipe): Save and Save As for recipes

Custom recipes can be overwritten in place (TopBar SAVE now offers CANCEL /
SAVE AS / SAVE and prefills the current name); bundled recipes stay read-only
and only offer Save As. Adds updateCustomRecipe to storageUtils.
This commit is contained in:
2026-09-10 20:57:19 +07:00
parent 4bb2bda5c8
commit 91109cba54
3 changed files with 71 additions and 13 deletions
+7
View File
@@ -35,6 +35,13 @@ export async function saveCustomRecipe(recipe: Omit<Recipe, 'id' | 'isCustom'>):
return newRecipe;
}
// Overwrite an existing custom recipe in place (Save). No-op if the id is gone.
export async function updateCustomRecipe(id: string, recipe: Omit<Recipe, 'id' | 'isCustom'>): Promise<void> {
const custom = await getCustomRecipes();
const updated = custom.map((r) => (r.id === id ? { ...r, ...recipe, id, isCustom: true } : r));
await AsyncStorage.setItem(CUSTOM_RECIPES_KEY, JSON.stringify(updated));
}
export async function deleteCustomRecipe(id: string): Promise<void> {
const custom = await getCustomRecipes();
const updated = custom.filter(r => r.id !== id);