PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.7.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.7.0
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 / composables / useOverviewData.ts
hostinger-reach / frontend / vue / composables Last commit date
index.ts 11 months ago useAmplitudeEvent.ts 3 months ago useHostingData.ts 3 months ago useModal.ts 11 months ago useOverviewData.ts 9 months ago useReachUrls.ts 1 month ago useScrollLock.ts 11 months ago useServerPagination.ts 10 months ago useToast.ts 11 months ago
useOverviewData.ts
95 lines
1 import { computed, ref } from 'vue';
2
3 import { reachRepo } from '@/data/repositories/reachRepo';
4 import type { OverviewData } from '@/types/models/reachDataModels';
5 import { translate } from '@/utils/translate';
6
7 export const useOverviewData = () => {
8 const isLoading = ref(true);
9 const error = ref<string | null>(null);
10 const status = ref<number | null>(null);
11 const overviewData = ref<OverviewData | null>(null);
12
13 const usageCards = computed(() => [
14 {
15 title: translate('hostinger_reach_overview_emails_title'),
16 layout: 'horizontal' as const,
17 metrics: [
18 {
19 label: translate('hostinger_reach_overview_emails_sent_label'),
20 value: overviewData.value?.totalEmailsSentThisMonth || 0
21 },
22 {
23 label: translate('hostinger_reach_overview_emails_remaining_label'),
24 value: overviewData.value?.remainingEmailsQuota || 0
25 }
26 ]
27 },
28 {
29 title: translate('hostinger_reach_overview_campaigns_title'),
30 layout: 'horizontal' as const,
31 metrics: [
32 {
33 label: translate('hostinger_reach_overview_campaigns_sent_label'),
34 value: overviewData.value?.totalCampaignsSentThisMonth || 0
35 },
36 {
37 label: translate('hostinger_reach_overview_campaigns_ctor_label'),
38 value: `${overviewData.value?.averageClickToOpenRate || 0}%`,
39 hasIcon: true,
40 tooltip: translate('hostinger_reach_ui_tooltip_ctor_info')
41 }
42 ]
43 },
44 {
45 title: translate('hostinger_reach_overview_subscribers_title'),
46 layout: 'vertical' as const,
47 metrics: [
48 {
49 label: translate('hostinger_reach_overview_subscribers_new_label'),
50 value: overviewData.value?.totalSubscribedThisMonth || 0
51 },
52 {
53 label: translate('hostinger_reach_overview_subscribers_unsubscribes_label'),
54 value: overviewData.value?.totalUnsubscribedThisMonth || 0
55 },
56 {
57 label: translate('hostinger_reach_overview_subscribers_total_label'),
58 value: overviewData.value?.totalSubscribed || 0
59 }
60 ]
61 }
62 ]);
63
64 const loadOverviewData = async () => {
65 isLoading.value = true;
66 error.value = null;
67 status.value = null;
68
69 const [data, err, responseStatus] = await reachRepo.getOverview();
70
71 status.value = responseStatus;
72
73 isLoading.value = false;
74
75 if (err) {
76 error.value = err.message || translate('hostinger_reach_error_message');
77
78 return;
79 }
80
81 if (data) {
82 overviewData.value = data;
83 }
84 };
85
86 return {
87 isLoading,
88 error,
89 status,
90 overviewData,
91 usageCards,
92 loadOverviewData
93 };
94 };
95