From 0f1dee42ecb3c11fbd723993844a6928aabf519d Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 Oct 2023 09:25:28 +0200 Subject: [PATCH] refs #6067 refactor: getUrl --- src/composables/getUrl.js | 9 +++------ src/pages/Login/VerifyEmail.vue | 3 ++- test/vitest/helper.js | 1 + 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/composables/getUrl.js b/src/composables/getUrl.js index e020d7f18..f2bd9ddb9 100644 --- a/src/composables/getUrl.js +++ b/src/composables/getUrl.js @@ -1,14 +1,11 @@ import axios from 'axios'; export async function getUrl(route, appName = 'salix') { - let url; const filter = { where: { and: [{ appName: appName }, { environment: process.env.NODE_ENV }] }, }; - await axios.get('Urls/findOne', { params: { filter } }).then((res) => { - url = res.data.url + route; - }); - - return url; + const { data } = await axios.get('Urls/findOne', { params: { filter } }); + const url = data.url; + return route ? url + route : url; } diff --git a/src/pages/Login/VerifyEmail.vue b/src/pages/Login/VerifyEmail.vue index b07b2a9c4..860b5bd89 100644 --- a/src/pages/Login/VerifyEmail.vue +++ b/src/pages/Login/VerifyEmail.vue @@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; import VnLogo from 'components/ui/VnLogo.vue'; +import { getUrl } from 'src/composables/getUrl'; const route = useRoute(); @@ -17,7 +18,7 @@ onMounted(async () => { color: 'bg-vnColor', icon: new URL(`../../assets/vn_icon.svg`, import.meta.url).href, text: 'goToShop', - url: params?.url, + url: await getUrl(null, 'hedera'), }); if (params?.isWorker && JSON.parse(params?.isWorker)) { diff --git a/test/vitest/helper.js b/test/vitest/helper.js index 8f4dc3221..7cc2bdfa5 100644 --- a/test/vitest/helper.js +++ b/test/vitest/helper.js @@ -63,6 +63,7 @@ class FormDataMock { } } global.FormData = FormDataMock; +global.URL = class URL {}; export function createWrapper(component, options) { const defaultOptions = {