From dfb3f20c93736d659bbbcbdd5dd2edf06421c363 Mon Sep 17 00:00:00 2001 From: FernandoJVideira <03.pleaser-minster@icloud.com> Date: Fri, 1 Aug 2025 01:36:00 +0100 Subject: [PATCH] Fixed API link --- src/components/NameGenerator.vue | 15 +++++++----- src/components/NameGeneratorCard.vue | 34 ++++++++++++++++------------ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/components/NameGenerator.vue b/src/components/NameGenerator.vue index 7924064..d1368da 100644 --- a/src/components/NameGenerator.vue +++ b/src/components/NameGenerator.vue @@ -61,9 +61,9 @@
- @@ -92,9 +92,12 @@ function handleToast(event) { toastMessage.value = event.message; toastType.value = event.type; showToast.value = true; - setTimeout(() => { - showToast.value = false; - }, event.type === "error" ? 4000 : 2000); + setTimeout( + () => { + showToast.value = false; + }, + event.type === "error" ? 4000 : 2000 + ); } function addGenerator() { diff --git a/src/components/NameGeneratorCard.vue b/src/components/NameGeneratorCard.vue index ce9056f..5297692 100644 --- a/src/components/NameGeneratorCard.vue +++ b/src/components/NameGeneratorCard.vue @@ -142,7 +142,7 @@ const props = defineProps({ }, }); -const emit = defineEmits(['show-toast']); +const emit = defineEmits(["show-toast"]); const modern = ref(false); const isLoading = ref(false); @@ -221,7 +221,7 @@ async function generate() { try { if (modern.value) { // Use API for modern names - const url = `http://localhost:8080/v1/modern/${language.value}?gender=${gender.value}`; + const url = `https://namegen.fernandovideira.com/v1/modern/${language.value}?gender=${gender.value}`; const response = await fetch(url); if (!response.ok) { @@ -237,14 +237,16 @@ async function generate() { "Failed to fetch modern names:", data.message || "Unknown error" ); - emit('show-toast', { - message: `Error: ${data.message || "Failed to generate modern names"}`, - type: 'error' + emit("show-toast", { + message: `Error: ${ + data.message || "Failed to generate modern names" + }`, + type: "error", }); } } else { // Use API for fantasy names - const url = `http://localhost:8080/v1/fantasy/${race.value}-names?gender=${gender.value}`; + const url = `https://namegen.fernandovideira.com/v1/fantasy/${race.value}-names?gender=${gender.value}`; const response = await fetch(url); if (!response.ok) { @@ -260,17 +262,19 @@ async function generate() { "Failed to fetch fantasy names:", data.message || "Unknown error" ); - emit('show-toast', { - message: `Error: ${data.message || "Failed to generate fantasy names"}`, - type: 'error' + emit("show-toast", { + message: `Error: ${ + data.message || "Failed to generate fantasy names" + }`, + type: "error", }); } } } catch (error) { console.error("Error fetching names:", error); - emit('show-toast', { + emit("show-toast", { message: `Connection error: ${error.message}`, - type: 'error' + type: "error", }); } finally { isLoading.value = false; @@ -280,9 +284,9 @@ async function generate() { async function copyToClipboard(name) { try { await navigator.clipboard.writeText(name); - emit('show-toast', { + emit("show-toast", { message: `"${name}" copied to clipboard!`, - type: 'success' + type: "success", }); } catch (err) { console.error("Failed to copy to clipboard:", err); @@ -293,9 +297,9 @@ async function copyToClipboard(name) { textArea.select(); document.execCommand("copy"); document.body.removeChild(textArea); - emit('show-toast', { + emit("show-toast", { message: `"${name}" copied to clipboard!`, - type: 'success' + type: "success", }); } }