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