Files
n8n-enterprise-unlocked/packages/editor-ui/src/composables/useUpgradeLink.ts
Iván Ovejero 57aab63c10 refactor: Integrate consistent-type-imports in FE packages (no-changelog) (#6060)
* 👕 Move `consistent-type-imports` to top level

* 👕 Apply lintfixes

* 👕 Apply more lintfixes

* 👕 More lintfixes

* 👕 More lintfixes
2023-04-24 12:18:24 +02:00

26 lines
816 B
TypeScript

import type { BaseTextKey } from '@/plugins/i18n';
import { useUIStore, useUsageStore } from '@/stores';
import { useI18n } from '@/composables';
import { computed } from 'vue';
export function useUpgradeLink(queryParams = { default: '', desktop: '' }) {
const uiStore = useUIStore();
const usageStore = useUsageStore();
const i18n = useI18n();
const upgradeLinkUrl = computed(() => {
const linkUrlTranslationKey = uiStore.contextBasedTranslationKeys.upgradeLinkUrl as BaseTextKey;
let url = i18n.baseText(linkUrlTranslationKey);
if (linkUrlTranslationKey.endsWith('.upgradeLinkUrl')) {
url = `${usageStore.viewPlansUrl}${queryParams.default}`;
} else if (linkUrlTranslationKey.endsWith('.desktop')) {
url = `${url}${queryParams.desktop}`;
}
return url;
});
return { upgradeLinkUrl };
}