PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.5.9
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.5.9
1.7.2 1.7.1 1.7.0 1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / frontend / vue / views / WelcomeView.vue
hostinger-reach / frontend / vue / views Last commit date
OverviewView.vue 3 months ago WelcomeView.vue 2 months ago
WelcomeView.vue
119 lines
1 <script setup lang="ts">
2 import { computed, onMounted, ref } from 'vue';
3
4 import FAQ from '@/components/FAQ.vue';
5 import Hero from '@/components/Hero.vue';
6 import { useHostingData } from '@/composables/useHostingData';
7 import { useModal } from '@/composables/useModal';
8 import { useToast } from '@/composables/useToast';
9 import { connectFaqData } from '@/data/faq';
10 import { reachRepo } from '@/data/repositories/reachRepo';
11 import { useGeneralDataStore } from '@/stores';
12 import { ModalName } from '@/types/enums/modalEnum';
13 import { translate } from '@/utils/translate';
14
15 const TRUSTED_AUTH_DOMAINS = /^https:\/\/auth\.hostinger\.(dev|com)/;
16 const PREVIEW_DOMAINS = /hostingersite\.com/i;
17
18 const { showError } = useToast();
19
20 const generalDataStore = useGeneralDataStore();
21 const { domainDetails, loadDomainDetails, isLoading } = useHostingData();
22
23 const isConnectedToAnotherSite = ref(false);
24 const isButtonLoading = ref(false);
25 const { openModal } = useModal();
26 const domain = window.location.hostname;
27 const rawDomain = generalDataStore.rawDomain;
28
29 const isDomainActive = computed(
30 () =>
31 !generalDataStore.isHostingerUser ||
32 !domainDetails?.value?.status ||
33 domainDetails?.value?.status === 'active' ||
34 domainDetails?.value?.status === 'error'
35 );
36
37 const handleGetStarted = async () => {
38 isButtonLoading.value = true;
39
40 const [data, error] = await reachRepo.generateAuthUrl();
41
42 isButtonLoading.value = false;
43
44 if (error || !data) {
45 showError(error?.message || translate('hostinger_reach_error_message'));
46
47 return;
48 }
49
50 if (PREVIEW_DOMAINS.test(domain) || !isDomainActive.value) {
51 window.open(`https://hpanel.hostinger.com/websites/${encodeURIComponent(rawDomain)}`, '_blank');
52
53 return;
54 }
55
56 if (data.authUrl && TRUSTED_AUTH_DOMAINS.test(data.authUrl)) {
57 window.location.href = data.authUrl;
58 } else {
59 showError(translate('hostinger_reach_error_message'));
60 }
61 };
62
63 const openApiKeyModal = (apiKey: string = '') => {
64 openModal(ModalName.REACH_API_KEY_MODAL, { apiKey }, { hasCloseButton: true, isXL: true });
65 };
66
67 onMounted(() => {
68 if (generalDataStore.isHostingerUser) {
69 loadDomainDetails();
70 }
71
72 const params = new URLSearchParams(window.location.search);
73 const key = params.get('api_key');
74
75 if (key !== null) {
76 openApiKeyModal();
77 }
78 });
79 </script>
80
81 <template>
82 <div class="welcome-view">
83 <Hero
84 :is-connected-to-another-site="isConnectedToAnotherSite"
85 :is-button-loading="isButtonLoading || isLoading"
86 :domain="domain"
87 :is-temporary="PREVIEW_DOMAINS.test(domain)"
88 :is-not-active="!isDomainActive"
89 :on-get-started="handleGetStarted"
90 :on-manual-api-key-click="() => openApiKeyModal()"
91 />
92 <div class="faq-wrap">
93 <FAQ :faq-data="connectFaqData" />
94 </div>
95 </div>
96 </template>
97
98 <style scoped lang="scss">
99 .welcome-view {
100 min-height: 100vh;
101 padding: 0 16px;
102
103 @media (max-width: 480px) {
104 padding: 0 12px;
105 }
106 }
107
108 @media (max-width: 320px) {
109 .welcome-view {
110 padding: 0 8px;
111 }
112 }
113
114 .faq-wrap {
115 max-width: 780px;
116 margin: 24px auto;
117 }
118 </style>
119