From 4eec86794c92b946427b991d04c89df46417554a Mon Sep 17 00:00:00 2001 From: jableader Date: Sun, 2 Nov 2025 17:02:28 +1100 Subject: [PATCH] Fixed parsing --- src/api/sdk.ts | 4 ++-- src/components/recipes/EditRecipePage.vue | 12 ++++++------ src/components/recipes/RecipesPage.vue | 8 +++++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/api/sdk.ts b/src/api/sdk.ts index 96629fc..14d046c 100644 --- a/src/api/sdk.ts +++ b/src/api/sdk.ts @@ -200,8 +200,8 @@ export async function deleteRecipe(id: number | string): Promise { if (!response.ok) throw httpError(response, error) } -export async function parseRecipe(url: string): Promise { - const householdSlug = requireSlug() +export async function parseRecipe(url: string, householdSlugOverride?: string): Promise { + const householdSlug = requireSlug(householdSlugOverride) const { data, error, response } = await api.POST('/api/v1/households/{householdSlug}/recipes/parse-from-url', { params: { path: { householdSlug } }, body: { url }, diff --git a/src/components/recipes/EditRecipePage.vue b/src/components/recipes/EditRecipePage.vue index 972add8..fbda431 100644 --- a/src/components/recipes/EditRecipePage.vue +++ b/src/components/recipes/EditRecipePage.vue @@ -84,6 +84,7 @@ const props = defineProps({ const router = useRouter() const route = useRoute() +const slug = typeof route.params.householdSlug === 'string' ? route.params.householdSlug : '' const { show: showAlert } = useAlert() const link = ref(parseQueryString(route.query.url)) @@ -102,20 +103,19 @@ const image_styling = computed(() => { }) function parseLink() { - router.push({ path: '/recipes/add', query: { url: link.value } }) + router.push({ name: 'recipe-add', params: { householdSlug: slug }, query: { url: link.value } }) refreshRecipe() } async function refreshRecipe() { const id = props.id ? parseInt(props.id) : null if (id !== null && id >= 0) { - const slug = typeof route.params.householdSlug === 'string' ? route.params.householdSlug : '' - const r = await getRecipe(slug, id) + const r = await getRecipe(slug, id) recipe.value = r link.value = r.link ?? '' return } else if (link.value) { - const r = await parseRecipe(link.value) + const r = await parseRecipe(link.value, slug) recipe.value = r parse_failed.value = !r } else { @@ -139,7 +139,7 @@ async function saveRecipe() { const saved = recipe.value ? await saveRecipeApi(toRecipeCreate(recipe.value)) : null if (saved && saved.id >= 0) { showAlert({ heading: 'Recipe saved', message: 'Your recipe has been saved', type: 'success' }) - router.push(`/recipes/${saved.id}`) + router.push({ name: 'recipe-edit', params: { householdSlug: slug, id: saved.id } }) return } showAlert({ heading: 'Error saving recipe', message: 'There was an error saving your recipe', type: 'error' }) @@ -171,7 +171,7 @@ async function deleteRecipe() { if (confirm('Are you sure you want to delete this recipe?')) { if (!recipe.value) return await deleteRecipeApi(recipe.value.id) - router.push('/recipes') + router.push({ name: 'recipes', params: { householdSlug: slug } }) } } diff --git a/src/components/recipes/RecipesPage.vue b/src/components/recipes/RecipesPage.vue index b764940..0de8cc1 100644 --- a/src/components/recipes/RecipesPage.vue +++ b/src/components/recipes/RecipesPage.vue @@ -12,7 +12,7 @@