flowrix 1.0.1-beta.113 → 1.0.1-beta.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useHead, useRequestEvent } from "#imports";
|
|
1
|
+
import { useHead, useRequestEvent, useRoute } from "#imports";
|
|
2
2
|
import { getRequestURL } from "h3";
|
|
3
3
|
import { useCompanyProfile } from "../stores/useCompanyProfile.js";
|
|
4
4
|
export const useApp = () => {
|
|
5
|
+
const route = useRoute();
|
|
5
6
|
const companyProfile = useCompanyProfile();
|
|
6
7
|
const gtmId = companyProfile.profile?.data?.integrations["google-tag-manager"]["script"] || "";
|
|
7
8
|
const tiktok = companyProfile.profile?.data?.integrations["tiktok"]["script"] || "";
|
|
@@ -22,6 +23,12 @@ export const useApp = () => {
|
|
|
22
23
|
websiteurl = window.location.origin;
|
|
23
24
|
}
|
|
24
25
|
useHead({
|
|
26
|
+
link: [
|
|
27
|
+
{
|
|
28
|
+
rel: "canonical",
|
|
29
|
+
href: `${websiteurl}${route.path}`
|
|
30
|
+
}
|
|
31
|
+
],
|
|
25
32
|
meta: [
|
|
26
33
|
{
|
|
27
34
|
name: "robots",
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
status:
|
|
3
|
-
message: string
|
|
4
|
-
data
|
|
1
|
+
export interface SubscribeResponse {
|
|
2
|
+
status: 'Success' | 'Error';
|
|
3
|
+
message: string;
|
|
4
|
+
data?: any;
|
|
5
5
|
}
|
|
6
6
|
export declare function useSubscriptions(): {
|
|
7
|
-
|
|
8
|
-
response: import("vue").
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
loading: import("vue").Ref<boolean, boolean>;
|
|
8
|
+
response: import("vue").Ref<{
|
|
9
|
+
status: "Success" | "Error";
|
|
10
|
+
message: string;
|
|
11
|
+
data?: any;
|
|
12
|
+
} | null, SubscribeResponse | {
|
|
13
|
+
status: "Success" | "Error";
|
|
14
|
+
message: string;
|
|
15
|
+
data?: any;
|
|
16
|
+
} | null>;
|
|
17
|
+
error: import("vue").Ref<string | null, string | null>;
|
|
18
|
+
subscribe: (email: string) => Promise<SubscribeResponse>;
|
|
19
|
+
clear: () => void;
|
|
13
20
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { flowrixApi } from "../middleware/flowrix.js";
|
|
3
|
+
import { useRuntimeConfig } from "#imports";
|
|
4
4
|
function formatErrorMessage(message) {
|
|
5
5
|
if (!message) return "An error occurred";
|
|
6
6
|
if (typeof message === "string") {
|
|
@@ -17,42 +17,77 @@ function formatErrorMessage(message) {
|
|
|
17
17
|
return errorMessages.join(", ");
|
|
18
18
|
}
|
|
19
19
|
export function useSubscriptions() {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const loading = ref(false);
|
|
21
|
+
const response = ref(null);
|
|
22
|
+
const error = ref(null);
|
|
23
|
+
const subscribe = async (email) => {
|
|
24
|
+
loading.value = true;
|
|
25
|
+
response.value = null;
|
|
26
|
+
error.value = null;
|
|
25
27
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const config = useRuntimeConfig();
|
|
29
|
+
let rawCookies = "";
|
|
30
|
+
if (process.client) {
|
|
31
|
+
rawCookies = document.cookie || "";
|
|
32
|
+
}
|
|
33
|
+
const apiConfig = {
|
|
34
|
+
...config,
|
|
35
|
+
cookies: rawCookies
|
|
36
|
+
};
|
|
37
|
+
const apiResponse = await flowrixApi.post("subscribe", apiConfig, {
|
|
38
|
+
body: { email }
|
|
39
|
+
});
|
|
40
|
+
if (apiResponse.status === "Success") {
|
|
41
|
+
const successResponse = {
|
|
42
|
+
status: "Success",
|
|
43
|
+
message: apiResponse.message || "Successfully subscribed!",
|
|
44
|
+
data: apiResponse.data
|
|
45
|
+
};
|
|
46
|
+
response.value = successResponse;
|
|
47
|
+
return successResponse;
|
|
30
48
|
} else {
|
|
31
|
-
const errorMessage = formatErrorMessage(
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
const errorMessage = formatErrorMessage(apiResponse.message);
|
|
50
|
+
const errorResponse = {
|
|
51
|
+
status: "Error",
|
|
52
|
+
message: errorMessage,
|
|
53
|
+
data: apiResponse.data
|
|
54
|
+
};
|
|
55
|
+
error.value = errorMessage;
|
|
56
|
+
response.value = errorResponse;
|
|
57
|
+
return errorResponse;
|
|
58
|
+
}
|
|
59
|
+
} catch (apiError) {
|
|
60
|
+
console.error("Subscribe error:", apiError);
|
|
61
|
+
let errorMessage = "Failed to subscribe";
|
|
62
|
+
if (apiError.data?.message) {
|
|
63
|
+
errorMessage = formatErrorMessage(apiError.data.message);
|
|
64
|
+
} else if (apiError.message) {
|
|
65
|
+
errorMessage = apiError.message;
|
|
34
66
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
67
|
+
const errorResponse = {
|
|
68
|
+
status: "Error",
|
|
69
|
+
message: errorMessage,
|
|
70
|
+
data: apiError.data || null
|
|
71
|
+
};
|
|
72
|
+
error.value = errorMessage;
|
|
73
|
+
response.value = errorResponse;
|
|
74
|
+
return errorResponse;
|
|
40
75
|
} finally {
|
|
41
|
-
|
|
76
|
+
loading.value = false;
|
|
42
77
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
78
|
+
};
|
|
79
|
+
const clear = () => {
|
|
80
|
+
loading.value = false;
|
|
81
|
+
response.value = null;
|
|
82
|
+
error.value = null;
|
|
83
|
+
};
|
|
50
84
|
return {
|
|
85
|
+
// State
|
|
86
|
+
loading,
|
|
87
|
+
response,
|
|
88
|
+
error,
|
|
89
|
+
// Methods
|
|
51
90
|
subscribe,
|
|
52
|
-
|
|
53
|
-
error: computed(() => store.error),
|
|
54
|
-
loading: computed(() => store.loading),
|
|
55
|
-
clearResponse,
|
|
56
|
-
clearError
|
|
91
|
+
clear
|
|
57
92
|
};
|
|
58
93
|
}
|