diff --git a/Seasoned.Frontend/app/components/RecipeDisplay.vue b/Seasoned.Frontend/app/components/RecipeDisplay.vue index 9c49df5..196ad19 100644 --- a/Seasoned.Frontend/app/components/RecipeDisplay.vue +++ b/Seasoned.Frontend/app/components/RecipeDisplay.vue @@ -41,7 +41,7 @@ { } const shareRecipe = async () => { - const shareUrl = props.recipe.id - ? `${window.location.origin}/recipe/${props.recipe.id}` - : window.location.href; + if (!props.recipe?.id) { + alert("Please save this recipe to your collection first to generate a shareable link!"); + return; + } + + const shareUrl = `${window.location.origin}/recipe/${props.recipe.id}`; const shareData = { title: props.recipe.title, @@ -144,14 +147,13 @@ const shareRecipe = async () => { try { if (navigator.share) { - await navigator.share(shareData) - triggerShareSuccess() + await navigator.share(shareData); } else { - await navigator.clipboard.writeText(shareUrl) - triggerShareSuccess() + await navigator.clipboard.writeText(shareUrl); } + triggerShareSuccess(); } catch (err) { - console.error('Error sharing:', err) + if (err.name !== 'AbortError') console.error('Error sharing:', err); } } diff --git a/Seasoned.Frontend/app/pages/recipe/[id].vue b/Seasoned.Frontend/app/pages/recipe/[id].vue index a25aa37..501afb6 100644 --- a/Seasoned.Frontend/app/pages/recipe/[id].vue +++ b/Seasoned.Frontend/app/pages/recipe/[id].vue @@ -9,6 +9,9 @@