From bbdfda5c3df45ebe9ef58d0d01eaf1c68a5560e7 Mon Sep 17 00:00:00 2001 From: chloe Date: Thu, 19 Mar 2026 16:46:47 +0000 Subject: [PATCH] save functions updated --- Seasoned.Frontend/app/pages/chat.vue | 6 +++- Seasoned.Frontend/app/pages/uploader.vue | 40 ++++-------------------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/Seasoned.Frontend/app/pages/chat.vue b/Seasoned.Frontend/app/pages/chat.vue index 20942fc..945a277 100644 --- a/Seasoned.Frontend/app/pages/chat.vue +++ b/Seasoned.Frontend/app/pages/chat.vue @@ -102,12 +102,16 @@ const saveToCollection = async () => { saving.value = true try { - await $fetch(`${config.public.apiBase}api/recipe/save`, { + const response = await $fetch(`${config.public.apiBase}api/recipe/save`, { method: 'POST', credentials: 'include', body: recipe.value }) + if (response && response.id) { + recipe.value.id = response.id + } + hasSaved.value = true } catch (error) { console.error("Save failed:", error) diff --git a/Seasoned.Frontend/app/pages/uploader.vue b/Seasoned.Frontend/app/pages/uploader.vue index 6e8650b..68066fa 100644 --- a/Seasoned.Frontend/app/pages/uploader.vue +++ b/Seasoned.Frontend/app/pages/uploader.vue @@ -147,14 +147,6 @@ const saveToCollection = async () => { saving.value = false; localStorage.setItem('pending_recipe', JSON.stringify(recipe.value)) - snackbar.value = { - show: true, - message: 'Please sign in to preserve this recipe in your archives.', - color: '#efe5e3', - icon: 'mdi-account-key', - iconColor: '#8c4a32', - textColor: '#5d4037' - }; setTimeout(() => { router.push('/login') @@ -163,45 +155,25 @@ const saveToCollection = async () => { } try { - await $fetch(`${config.public.apiBase}api/recipe/save`, { + const response = await $fetch(`${config.public.apiBase}api/recipe/save`, { method: 'POST', credentials: 'include', body: recipe.value }); + if (response && response.id) { + recipe.value.id = response.id + } + hasSaved.value = true; - snackbar.value = { - show: true, - message: 'Recipe added to your collection.', - color: '#f4ede1', - icon: 'mdi-check-decagram', - iconColor: '#556b2f', - textColor: '#5d4037' - }; + } catch (error) { console.error("Save failed:", error); - snackbar.value = { - show: true, - message: 'Failure to save recipe.', - color: '#f8d7da', - icon: 'mdi-alert-rhombus', - iconColor: '#8c4a32', - textColor: '#5d4037' - }; } finally { saving.value = false; } } -const snackbar = ref({ - show: false, - message: '', - color: '#f4ede1', - icon: 'mdi-check-decagram', - iconColor: '#556b2f', - textColor: '#5d4037' -}) - const clearAll = () => { files.value = null recipe.value = null