diff --git a/refactor-strategy.md b/refactor-strategy.md index adec7fd..02456a3 100644 --- a/refactor-strategy.md +++ b/refactor-strategy.md @@ -27,11 +27,11 @@ Only outstanding, actionable steps are listed below. Completed work has been rem Acceptance: ESLint upgrade plan decided (or implemented), rules apply cleanly, lint passes. -## 2) Alerts as a composable (nice-to-have) -- Replace the simple event bus in `src/alert.js` with a `useAlert` composable (reactive queue API) and adapt `AlertToast.vue`. -- Provide show({ heading, message, type }) and auto-dismiss with clear-on-click. +## 2) Alerts as a composable +- DONE: Replaced the event bus with `useAlert` composable and updated `AlertToast.vue` and callers. +- Follow-up: consider queuing multiple alerts if needed (current behavior shows latest only). -Acceptance: AlertToast driven by composable; no global mutable arrays; behavior unchanged. +Acceptance: N/A (completed). Optional enhancement if queuing desired. ## 3) Incremental test coverage - Add unit tests for new utilities/composables when added (e.g., `useAlert`). @@ -44,10 +44,3 @@ Acceptance: New logic lands with tests; existing tests stay green. - Add Volar as a recommended extension in the project docs (README updated). Acceptance: Clear env setup; editor help consistent. - -## 5) Optional: Migrate from Vue CLI to Vite -- If desired, migrate build tooling to Vite for faster dev server and simpler config. -- Update scripts, configure vitest (already in place), and resolve aliasing. - -Acceptance: Dev/build parity maintained; cold/hot start noticeably faster. - diff --git a/src/components/AlertToast.vue b/src/components/AlertToast.vue index f1535a4..55cc821 100644 --- a/src/components/AlertToast.vue +++ b/src/components/AlertToast.vue @@ -48,8 +48,8 @@ diff --git a/src/components/meals/EditMealPage.vue b/src/components/meals/EditMealPage.vue index fdb64e9..0ccf9f3 100644 --- a/src/components/meals/EditMealPage.vue +++ b/src/components/meals/EditMealPage.vue @@ -97,7 +97,7 @@ import { useRoute, useRouter } from 'vue-router' import { getMeal, saveMeal } from '@/composables/useMeals' import { getRecipe } from '@/api/recipes' import { currentUser } from '@/api/auth' -import alert from '@/alert.js' +import { useAlert } from '@/composables/useAlert' import { ago } from '@/dateformats.js' @@ -116,6 +116,7 @@ function addPersonIfNotExists(list, person) { const route = useRoute() const router = useRouter() +const { show: showAlert } = useAlert() const showIngredients = reactive({}) const meal = reactive({ @@ -221,11 +222,11 @@ async function onSaveMeal() { if (saved?.id >= 0) { Object.assign(meal, saved) router.push(`/meals/${saved.id}`) - alert.show({ heading: 'Meal saved', message: 'Meal saved successfully', type: 'success' }) + showAlert({ heading: 'Meal saved', message: 'Meal saved successfully', type: 'success' }) return } - alert.show({ + showAlert({ heading: 'Error saving meal', message: 'An error occurred while saving the meal', type: 'error', diff --git a/src/components/recipes/EditRecipePage.vue b/src/components/recipes/EditRecipePage.vue index 68a5172..ac29183 100644 --- a/src/components/recipes/EditRecipePage.vue +++ b/src/components/recipes/EditRecipePage.vue @@ -66,7 +66,7 @@ input.recipe-name {