diff --git a/frontend/app/lang/messages/en-US.json b/frontend/app/lang/messages/en-US.json index 1201b9ebc..1a07fccde 100644 --- a/frontend/app/lang/messages/en-US.json +++ b/frontend/app/lang/messages/en-US.json @@ -410,7 +410,8 @@ "applies-on-days": "Applies on {0}s", "meal-plan-settings": "Meal Plan Settings", "add-all-to-list": "Add All to List", - "add-day-to-list": "Add Day to List" + "add-day-to-list": "Add Day to List", + "randomize-recipe": "Randomize Recipe" }, "migration": { "migration-data-removed": "Migration data removed", diff --git a/frontend/app/pages/household/mealplan/planner/edit.vue b/frontend/app/pages/household/mealplan/planner/edit.vue index b8fbe19b1..a1337e140 100644 --- a/frontend/app/pages/household/mealplan/planner/edit.vue +++ b/frontend/app/pages/household/mealplan/planner/edit.vue @@ -155,7 +155,18 @@ - + + {{ $globals.icons.diceMultiple }} + + {{ $globals.icons.delete }} @@ -391,6 +402,24 @@ async function randomMeal(date: Date, type: PlanEntryType) { } } +async function randomizeMeal(mealplan: UpdatePlanEntry) { + if (!mealplan.entryType) { + return; + } + + // Delete the current entry, then create a new random one with the same date and type + const { data: deleted } = await api.mealplans.deleteOne(mealplan.id); + if (deleted) { + await api.mealplans.setRandom({ + date: mealplan.date, + entryType: mealplan.entryType, + }); + + // Refresh either way: if setRandom failed we still need to reflect the deletion + props.actions.refreshAll(); + } +} + // ===================================================== // Search