flowrix 1.0.1-beta.103 → 1.0.1-beta.106
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 +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/composables/Cart/useCartComponent.js +5 -4
- package/dist/runtime/composables/Checkout/PaymentMethods/useDirectDeposit.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useEway.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/usePaypal.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useZippay.js +8 -0
- package/dist/runtime/composables/Customer/useRegister.d.ts +2 -3
- package/dist/runtime/composables/Customer/useRegister.js +23 -23
- package/dist/runtime/composables/Customer/useUpdatePassword.js +56 -20
- package/dist/runtime/composables/useWebforms.d.ts +38 -9
- package/dist/runtime/composables/useWebforms.js +93 -60
- package/dist/runtime/server/api/albums.js +6 -1
- package/dist/runtime/server/api/banners.js +6 -1
- package/dist/runtime/server/api/brand/[...slug].js +4 -1
- package/dist/runtime/server/api/cart/related.d.ts +1 -1
- package/dist/runtime/server/api/cart/related.js +1 -0
- package/dist/runtime/server/api/cart/remove.d.ts +1 -1
- package/dist/runtime/server/api/cart/remove.js +1 -0
- package/dist/runtime/server/api/catalog/brands.js +7 -1
- package/dist/runtime/server/api/catalog/categories.js +7 -1
- package/dist/runtime/server/api/catalog/categoriesall.js +7 -1
- package/dist/runtime/server/api/catalog/featured.js +7 -1
- package/dist/runtime/server/api/catalog/posts.js +7 -1
- package/dist/runtime/server/api/catalog/samples.js +7 -1
- package/dist/runtime/server/api/catalog/search.js +7 -1
- package/dist/runtime/server/api/category/[...slug].js +7 -1
- package/dist/runtime/server/api/cmspost/[...slug].js +6 -1
- package/dist/runtime/server/api/cmspost/all.js +7 -1
- package/dist/runtime/server/api/company/profile.js +6 -1
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +6 -1
- package/dist/runtime/server/api/contact-center/webforms/create.js +6 -2
- package/dist/runtime/server/api/countries.js +6 -1
- package/dist/runtime/server/api/featured.js +7 -1
- package/dist/runtime/server/api/location.js +6 -2
- package/dist/runtime/server/api/nav/[id]/links.js +6 -1
- package/dist/runtime/server/api/page/[...slug].js +6 -1
- package/dist/runtime/server/api/product/[...slug].js +8 -4
- package/dist/runtime/server/api/quickview/[slug].js +6 -2
- package/dist/runtime/server/api/reviews.js +6 -1
- package/dist/runtime/server/api/samples.js +7 -1
- package/dist/runtime/server/api/search.js +7 -1
- package/dist/runtime/server/api/service/[slug].js +6 -1
- package/dist/runtime/server/api/service/availability.js +6 -2
- package/dist/runtime/server/api/service/getall.js +6 -1
- package/dist/runtime/server/api/shop.js +7 -1
- package/dist/runtime/server/api/subscribe.js +6 -2
- package/dist/runtime/server/api/v2/[...slug].get.js +6 -1
- package/dist/runtime/server/api/webform.js +6 -1
- package/dist/runtime/stores/auth.js +16 -21
- package/dist/runtime/stores/webforms.d.ts +24 -9
- package/dist/runtime/stores/webforms.js +105 -5
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -8,15 +8,16 @@ const module$1 = defineNuxtModule({
|
|
|
8
8
|
defaults: {},
|
|
9
9
|
async setup(_options, nuxt) {
|
|
10
10
|
const env = process.env;
|
|
11
|
+
console.log("envenvenvenvenvenvenv", env);
|
|
11
12
|
const runtimeConfig = nuxt.options.runtimeConfig;
|
|
12
13
|
runtimeConfig.FLOWRIX_API_KEY = env.KEY || runtimeConfig.FLOWRIX_API_KEY || "";
|
|
14
|
+
runtimeConfig.FLOWRIX_API_SECRET = env.SECRET || runtimeConfig.FLOWRIX_API_SECRET || "";
|
|
13
15
|
runtimeConfig.FLOWRIX_API_ORIGIN = env.ORIGIN || runtimeConfig.FLOWRIX_API_ORIGIN || "";
|
|
14
16
|
runtimeConfig.FLOWRIX_API_BASE = env.BASE || runtimeConfig.FLOWRIX_API_BASE || "";
|
|
15
17
|
runtimeConfig.FLOWRIX_CACHE = env.CACHE || runtimeConfig.FLOWRIX_CACHE || "false";
|
|
16
18
|
runtimeConfig.FLOWRIX_CDN = env.CDN || runtimeConfig.FLOWRIX_CDN || "";
|
|
17
19
|
Object.assign(runtimeConfig.public, {
|
|
18
20
|
...runtimeConfig.public,
|
|
19
|
-
...process.env,
|
|
20
21
|
FLOWRIX_API_KEY: runtimeConfig.public.FLOWRIX_API_KEY || env.KEY || runtimeConfig.FLOWRIX_API_KEY || "",
|
|
21
22
|
FLOWRIX_API_ORIGIN: runtimeConfig.public.FLOWRIX_API_ORIGIN || env.ORIGIN || runtimeConfig.FLOWRIX_API_ORIGIN || "",
|
|
22
23
|
FLOWRIX_API_BASE: runtimeConfig.public.FLOWRIX_API_BASE || env.BASE || runtimeConfig.FLOWRIX_API_BASE || "",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { useCartStore } from "../../stores/Cart.js";
|
|
1
2
|
import { GTM_view_cart } from "../useDataLayer.js";
|
|
2
3
|
import { META_view_cart } from "../useMetaLayer.js";
|
|
3
4
|
import { TikTok_view_cart } from "../useTikTokDatalayer.js";
|
|
4
5
|
export const useCartComponent = async () => {
|
|
5
6
|
const cartStore = useCartStore();
|
|
6
|
-
const
|
|
7
|
-
GTM_view_cart(
|
|
8
|
-
META_view_cart(
|
|
9
|
-
TikTok_view_cart(
|
|
7
|
+
const cart = cartStore.cart;
|
|
8
|
+
GTM_view_cart(cart);
|
|
9
|
+
META_view_cart(cart);
|
|
10
|
+
TikTok_view_cart(cart);
|
|
10
11
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { useCheckoutStore } from "../../../stores/Checkout.js";
|
|
2
|
+
import { useCartStore } from "../../../stores/Cart.js";
|
|
3
|
+
import { GTM_add_payment_info } from "../../useDataLayer.js";
|
|
4
|
+
import { META_add_payment_info } from "../../useMetaLayer.js";
|
|
5
|
+
import { TikTok_add_payment_info } from "../../useTikTokDatalayer.js";
|
|
2
6
|
export default function() {
|
|
3
7
|
const checkoutStore = useCheckoutStore();
|
|
4
8
|
const getpaymentMethod = async (paymentMethod, inputData, totalPrice) => {
|
|
@@ -12,6 +16,10 @@ export default function() {
|
|
|
12
16
|
});
|
|
13
17
|
}
|
|
14
18
|
checkoutStore.saveToCheckoutSession(inputData);
|
|
19
|
+
const cartData = useCartStore().cart;
|
|
20
|
+
GTM_add_payment_info(cartData, "Direct Deposit");
|
|
21
|
+
META_add_payment_info(cartData, "Direct Deposit");
|
|
22
|
+
TikTok_add_payment_info(cartData, "Direct Deposit");
|
|
15
23
|
} catch (error) {
|
|
16
24
|
console.log("Error", error);
|
|
17
25
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { useCheckoutStore } from "../../../stores/Checkout.js";
|
|
2
|
+
import { useCartStore } from "../../../stores/Cart.js";
|
|
3
|
+
import { GTM_add_payment_info } from "../../useDataLayer.js";
|
|
4
|
+
import { META_add_payment_info } from "../../useMetaLayer.js";
|
|
5
|
+
import { TikTok_add_payment_info } from "../../useTikTokDatalayer.js";
|
|
2
6
|
export default function() {
|
|
3
7
|
const checkoutStore = useCheckoutStore();
|
|
4
8
|
const getpaymentMethod = async (paymentMethod, inputData, totalPrice) => {
|
|
@@ -13,6 +17,10 @@ export default function() {
|
|
|
13
17
|
inputData.ewayKey = checkoutStore.publishableKey.key;
|
|
14
18
|
}
|
|
15
19
|
checkoutStore.saveToCheckoutSession(inputData);
|
|
20
|
+
const cartData = useCartStore().cart;
|
|
21
|
+
GTM_add_payment_info(cartData, "Eway");
|
|
22
|
+
META_add_payment_info(cartData, "Eway");
|
|
23
|
+
TikTok_add_payment_info(cartData, "Eway");
|
|
16
24
|
} catch (error) {
|
|
17
25
|
console.log("Error", error);
|
|
18
26
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { useCheckoutStore } from "../../../stores/Checkout.js";
|
|
2
2
|
import { useAuthStore } from "../../../stores/auth.js";
|
|
3
|
+
import { useCartStore } from "../../../stores/Cart.js";
|
|
4
|
+
import { GTM_add_payment_info } from "../../useDataLayer.js";
|
|
5
|
+
import { META_add_payment_info } from "../../useMetaLayer.js";
|
|
6
|
+
import { TikTok_add_payment_info } from "../../useTikTokDatalayer.js";
|
|
3
7
|
export default function() {
|
|
4
8
|
const checkoutStore = useCheckoutStore();
|
|
5
9
|
const { user } = useAuthStore();
|
|
@@ -113,6 +117,10 @@ export default function() {
|
|
|
113
117
|
});
|
|
114
118
|
}
|
|
115
119
|
checkoutStore.saveToCheckoutSession(inputData);
|
|
120
|
+
const cartData = useCartStore().cart;
|
|
121
|
+
GTM_add_payment_info(cartData, "Flowrix Pay");
|
|
122
|
+
META_add_payment_info(cartData, "Flowrix Pay");
|
|
123
|
+
TikTok_add_payment_info(cartData, "Flowrix Pay");
|
|
116
124
|
} catch (error) {
|
|
117
125
|
console.log("Error", error);
|
|
118
126
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { useCheckoutStore } from "../../../stores/Checkout.js";
|
|
2
2
|
import { useAuthStore } from "../../../stores/auth.js";
|
|
3
|
+
import { useCartStore } from "../../../stores/Cart.js";
|
|
4
|
+
import { GTM_add_payment_info } from "../../useDataLayer.js";
|
|
5
|
+
import { META_add_payment_info } from "../../useMetaLayer.js";
|
|
6
|
+
import { TikTok_add_payment_info } from "../../useTikTokDatalayer.js";
|
|
3
7
|
export default function() {
|
|
4
8
|
const checkoutStore = useCheckoutStore();
|
|
5
9
|
const { user } = useAuthStore();
|
|
@@ -15,6 +19,10 @@ export default function() {
|
|
|
15
19
|
inputData.opayoKey = checkoutStore.publishableKey.key;
|
|
16
20
|
}
|
|
17
21
|
checkoutStore.saveToCheckoutSession(inputData);
|
|
22
|
+
const cartData = useCartStore().cart;
|
|
23
|
+
GTM_add_payment_info(cartData, "Opayo");
|
|
24
|
+
META_add_payment_info(cartData, "Opayo");
|
|
25
|
+
TikTok_add_payment_info(cartData, "Opayo");
|
|
18
26
|
} catch (error) {
|
|
19
27
|
console.log("Error", error);
|
|
20
28
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { useCheckoutStore } from "../../../stores/Checkout.js";
|
|
2
|
+
import { useCartStore } from "../../../stores/Cart.js";
|
|
3
|
+
import { GTM_add_payment_info } from "../../useDataLayer.js";
|
|
4
|
+
import { META_add_payment_info } from "../../useMetaLayer.js";
|
|
5
|
+
import { TikTok_add_payment_info } from "../../useTikTokDatalayer.js";
|
|
2
6
|
export default function() {
|
|
3
7
|
const checkoutStore = useCheckoutStore();
|
|
4
8
|
const getpaymentMethod = async (paymentMethod, inputData, totalPrice) => {
|
|
@@ -12,6 +16,10 @@ export default function() {
|
|
|
12
16
|
});
|
|
13
17
|
}
|
|
14
18
|
checkoutStore.saveToCheckoutSession(inputData);
|
|
19
|
+
const cartData = useCartStore().cart;
|
|
20
|
+
GTM_add_payment_info(cartData, "Paypal");
|
|
21
|
+
META_add_payment_info(cartData, "Paypal");
|
|
22
|
+
TikTok_add_payment_info(cartData, "Paypal");
|
|
15
23
|
} catch (error) {
|
|
16
24
|
console.log("Error", error);
|
|
17
25
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { loadStripe } from "@stripe/stripe-js";
|
|
2
2
|
import { useCheckoutStore } from "../../../stores/Checkout.js";
|
|
3
|
+
import { useCartStore } from "../../../stores/Cart.js";
|
|
4
|
+
import { GTM_add_payment_info } from "../../useDataLayer.js";
|
|
5
|
+
import { META_add_payment_info } from "../../useMetaLayer.js";
|
|
6
|
+
import { TikTok_add_payment_info } from "../../useTikTokDatalayer.js";
|
|
3
7
|
let stripe = null;
|
|
4
8
|
let elements = null;
|
|
5
9
|
export default function() {
|
|
@@ -26,6 +30,10 @@ export default function() {
|
|
|
26
30
|
cardElement.mount("#card-element");
|
|
27
31
|
}
|
|
28
32
|
checkoutStore.saveToCheckoutSession(inputData);
|
|
33
|
+
const cartData = useCartStore().cart;
|
|
34
|
+
GTM_add_payment_info(cartData, "Stripe");
|
|
35
|
+
META_add_payment_info(cartData, "Stripe");
|
|
36
|
+
TikTok_add_payment_info(cartData, "Stripe");
|
|
29
37
|
} catch (error) {
|
|
30
38
|
console.log("Error", error);
|
|
31
39
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { useCheckoutStore } from "../../../stores/Checkout.js";
|
|
2
|
+
import { useCartStore } from "../../../stores/Cart.js";
|
|
3
|
+
import { GTM_add_payment_info } from "../../useDataLayer.js";
|
|
4
|
+
import { META_add_payment_info } from "../../useMetaLayer.js";
|
|
5
|
+
import { TikTok_add_payment_info } from "../../useTikTokDatalayer.js";
|
|
2
6
|
export default function() {
|
|
3
7
|
const checkoutStore = useCheckoutStore();
|
|
4
8
|
const getpaymentMethod = async (paymentMethod, inputData, totalPrice) => {
|
|
@@ -12,6 +16,10 @@ export default function() {
|
|
|
12
16
|
});
|
|
13
17
|
}
|
|
14
18
|
checkoutStore.saveToCheckoutSession(inputData);
|
|
19
|
+
const cartData = useCartStore().cart;
|
|
20
|
+
GTM_add_payment_info(cartData, "Zippay");
|
|
21
|
+
META_add_payment_info(cartData, "Zippay");
|
|
22
|
+
TikTok_add_payment_info(cartData, "Zippay");
|
|
15
23
|
} catch (error) {
|
|
16
24
|
console.log("Error", error);
|
|
17
25
|
}
|
|
@@ -101,7 +101,6 @@ export default function (countries: any): {
|
|
|
101
101
|
shipping_mobile: string;
|
|
102
102
|
subscribe: boolean;
|
|
103
103
|
}>;
|
|
104
|
-
CustomerRegister: (registerFields: any) => Promise<void>;
|
|
105
104
|
regResponse: import("vue").Ref<null, null>;
|
|
106
105
|
isBusinessAccount: import("vue").Ref<boolean, boolean>;
|
|
107
106
|
companyName: import("vue").Ref<string, string>;
|
|
@@ -117,9 +116,9 @@ export default function (countries: any): {
|
|
|
117
116
|
toggleConfirmPassword: () => void;
|
|
118
117
|
handleSameAsCustomerDetails: () => void;
|
|
119
118
|
alertMessage: import("vue").Ref<string, string>;
|
|
120
|
-
alertType: import("vue").Ref<
|
|
119
|
+
alertType: import("vue").Ref<string, string>;
|
|
121
120
|
showAlert: import("vue").Ref<boolean, boolean>;
|
|
122
|
-
displayAlert: (message:
|
|
121
|
+
displayAlert: (message: any, type: any) => void;
|
|
123
122
|
dismissAlert: () => void;
|
|
124
123
|
handleSignup: () => Promise<void>;
|
|
125
124
|
initializeShippingData: () => void;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ref, watch } from "vue";
|
|
2
2
|
import { useRouter, useRoute } from "#vue-router";
|
|
3
3
|
import { useAuthStore } from "../../stores/auth.js";
|
|
4
|
-
import useLogin from "./useLogin.js";
|
|
5
4
|
export default function(countries) {
|
|
6
5
|
const router = useRouter();
|
|
7
6
|
const route = useRoute();
|
|
8
|
-
const
|
|
7
|
+
const authStore = useAuthStore();
|
|
9
8
|
const inputData = ref({
|
|
10
9
|
abn: "",
|
|
11
10
|
addresses: [],
|
|
@@ -41,9 +40,6 @@ export default function(countries) {
|
|
|
41
40
|
subscribe: false
|
|
42
41
|
});
|
|
43
42
|
const regResponse = ref(null);
|
|
44
|
-
const CustomerRegister = (async (registerFields) => {
|
|
45
|
-
regResponse.value = await useAuthStore().signUp(registerFields);
|
|
46
|
-
});
|
|
47
43
|
const isBusinessAccount = ref(false);
|
|
48
44
|
const companyName = ref("");
|
|
49
45
|
const abn = ref("");
|
|
@@ -148,10 +144,15 @@ export default function(countries) {
|
|
|
148
144
|
}
|
|
149
145
|
});
|
|
150
146
|
watch(() => inputData.value.address, (newAddress) => {
|
|
151
|
-
if (sameAsCustomerDetails.value && newAddress) {
|
|
147
|
+
if (sameAsCustomerDetails.value && newAddress && !isBusinessAccount.value) {
|
|
152
148
|
inputData.value.shipping_address = newAddress;
|
|
153
149
|
}
|
|
154
150
|
});
|
|
151
|
+
watch(() => address.value, (newBusinessAddress) => {
|
|
152
|
+
if (sameAsCustomerDetails.value && newBusinessAddress && isBusinessAccount.value) {
|
|
153
|
+
inputData.value.shipping_address = newBusinessAddress;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
155
156
|
watch(() => inputData.value.mobile, (newMobile) => {
|
|
156
157
|
if (sameAsCustomerDetails.value && newMobile) {
|
|
157
158
|
inputData.value.shipping_mobile = newMobile;
|
|
@@ -167,18 +168,14 @@ export default function(countries) {
|
|
|
167
168
|
inputData.value.shipping_state = newState;
|
|
168
169
|
}
|
|
169
170
|
});
|
|
170
|
-
watch(isBusinessAccount, (
|
|
171
|
+
watch(isBusinessAccount, () => {
|
|
171
172
|
if (sameAsCustomerDetails.value) {
|
|
172
173
|
handleSameAsCustomerDetails();
|
|
173
174
|
}
|
|
174
175
|
});
|
|
175
|
-
watch(logResponse, (newres) => {
|
|
176
|
-
if (newres?.status == "Success") {
|
|
177
|
-
router.push({ name: "dashboard-profile" });
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
176
|
const handleSignup = async () => {
|
|
181
177
|
isLoading.value = true;
|
|
178
|
+
dismissAlert();
|
|
182
179
|
inputData.value.billing_mobile = inputData.value.mobile;
|
|
183
180
|
inputData.value.billing_address = inputData.value.address;
|
|
184
181
|
inputData.value.billing_firstname = inputData.value.firstname;
|
|
@@ -210,14 +207,16 @@ export default function(countries) {
|
|
|
210
207
|
inputData.value.shipping_town = inputData.value.shipping_suburb;
|
|
211
208
|
}
|
|
212
209
|
}
|
|
213
|
-
await
|
|
210
|
+
regResponse.value = await authStore.signUp(inputData.value);
|
|
214
211
|
if (!regResponse.value || regResponse.value.status !== "Success") {
|
|
215
212
|
let errorMsg = "Registration failed. Please try again.";
|
|
216
213
|
if (regResponse.value?.message) {
|
|
217
214
|
if (typeof regResponse.value.message === "string") {
|
|
218
215
|
errorMsg = regResponse.value.message;
|
|
219
216
|
} else if (typeof regResponse.value.message === "object") {
|
|
220
|
-
const fieldErrors = Object.entries(regResponse.value.message).flatMap(
|
|
217
|
+
const fieldErrors = Object.entries(regResponse.value.message).flatMap(
|
|
218
|
+
([field, errors]) => (errors || []).map((err) => `${field.charAt(0).toUpperCase() + field.slice(1)}: ${err}`)
|
|
219
|
+
);
|
|
221
220
|
errorMsg = fieldErrors.length > 0 ? fieldErrors.join("\n") : errorMsg;
|
|
222
221
|
}
|
|
223
222
|
} else if (!regResponse.value) {
|
|
@@ -231,10 +230,13 @@ export default function(countries) {
|
|
|
231
230
|
email: inputData.value.email,
|
|
232
231
|
password: inputData.value.password
|
|
233
232
|
};
|
|
234
|
-
|
|
235
|
-
if (!
|
|
236
|
-
const errorMsg =
|
|
237
|
-
displayAlert(
|
|
233
|
+
const loginResult = await authStore.userLogin(loginCredentials);
|
|
234
|
+
if (!loginResult || loginResult.status !== "Success") {
|
|
235
|
+
const errorMsg = loginResult?.message ? typeof loginResult.message === "string" ? loginResult.message : "Auto-login failed." : "Auto-login failed. Please login manually.";
|
|
236
|
+
displayAlert(`Registration successful! However, ${errorMsg} Redirecting to login page...`, "danger");
|
|
237
|
+
setTimeout(() => {
|
|
238
|
+
router.push({ name: "customer-account-login" });
|
|
239
|
+
}, 3e3);
|
|
238
240
|
isLoading.value = false;
|
|
239
241
|
return;
|
|
240
242
|
}
|
|
@@ -242,11 +244,11 @@ export default function(countries) {
|
|
|
242
244
|
displayAlert(successMsg, "success");
|
|
243
245
|
resetForm();
|
|
244
246
|
setTimeout(() => {
|
|
245
|
-
router.push("
|
|
246
|
-
},
|
|
247
|
+
router.push({ name: "dashboard-profile" });
|
|
248
|
+
}, 1500);
|
|
247
249
|
} catch (error) {
|
|
248
250
|
console.error("Registration Error:", error);
|
|
249
|
-
const errorMsg = error
|
|
251
|
+
const errorMsg = error?.message || error?.data?.message || "An unexpected error occurred. Please try again.";
|
|
250
252
|
displayAlert(errorMsg, "danger");
|
|
251
253
|
} finally {
|
|
252
254
|
isLoading.value = false;
|
|
@@ -297,7 +299,6 @@ export default function(countries) {
|
|
|
297
299
|
router,
|
|
298
300
|
route,
|
|
299
301
|
inputData,
|
|
300
|
-
CustomerRegister,
|
|
301
302
|
regResponse,
|
|
302
303
|
isBusinessAccount,
|
|
303
304
|
companyName,
|
|
@@ -319,7 +320,6 @@ export default function(countries) {
|
|
|
319
320
|
dismissAlert,
|
|
320
321
|
handleSignup,
|
|
321
322
|
initializeShippingData,
|
|
322
|
-
// Make sure this is returned
|
|
323
323
|
resetForm
|
|
324
324
|
};
|
|
325
325
|
}
|
|
@@ -22,23 +22,57 @@ export function useUpdatePassword() {
|
|
|
22
22
|
};
|
|
23
23
|
clearMessages();
|
|
24
24
|
};
|
|
25
|
+
const formatApiError = (message) => {
|
|
26
|
+
if (typeof message === "string") {
|
|
27
|
+
return message;
|
|
28
|
+
}
|
|
29
|
+
if (typeof message === "object" && message !== null) {
|
|
30
|
+
const errors = [];
|
|
31
|
+
Object.entries(message).forEach(([field, fieldErrors]) => {
|
|
32
|
+
const fieldName = field.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
|
|
33
|
+
if (Array.isArray(fieldErrors)) {
|
|
34
|
+
fieldErrors.forEach((error) => {
|
|
35
|
+
errors.push(`${fieldName}: ${error}`);
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
errors.push(`${fieldName}: ${fieldErrors}`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return errors.join("\n");
|
|
42
|
+
}
|
|
43
|
+
return "An error occurred";
|
|
44
|
+
};
|
|
25
45
|
const validateForm = () => {
|
|
26
|
-
|
|
27
|
-
|
|
46
|
+
clearMessages();
|
|
47
|
+
if (!form.value.currentPassword?.trim()) {
|
|
48
|
+
errorMessage.value = "Current password is required!";
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (!form.value.newPassword?.trim()) {
|
|
52
|
+
errorMessage.value = "New password is required!";
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (!form.value.confirmPassword?.trim()) {
|
|
56
|
+
errorMessage.value = "Please confirm your new password!";
|
|
28
57
|
return false;
|
|
29
58
|
}
|
|
30
59
|
if (form.value.newPassword !== form.value.confirmPassword) {
|
|
31
60
|
errorMessage.value = "New password and confirm password do not match!";
|
|
32
61
|
return false;
|
|
33
62
|
}
|
|
34
|
-
if (form.value.newPassword.length <
|
|
35
|
-
errorMessage.value = "New password must be at least
|
|
63
|
+
if (form.value.newPassword.length < 6) {
|
|
64
|
+
errorMessage.value = "New password must be at least 6 characters long!";
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (form.value.currentPassword === form.value.newPassword) {
|
|
68
|
+
errorMessage.value = "New password must be different from current password!";
|
|
36
69
|
return false;
|
|
37
70
|
}
|
|
38
71
|
return true;
|
|
39
72
|
};
|
|
40
73
|
const updatePassword = async () => {
|
|
41
74
|
if (!validateForm()) {
|
|
75
|
+
console.log("Validation failed:", errorMessage.value);
|
|
42
76
|
return false;
|
|
43
77
|
}
|
|
44
78
|
loading.value = true;
|
|
@@ -50,34 +84,36 @@ export function useUpdatePassword() {
|
|
|
50
84
|
password_confirmation: form.value.confirmPassword.trim()
|
|
51
85
|
};
|
|
52
86
|
const response = await authStore.changePassword(requestBody);
|
|
53
|
-
if (response
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return
|
|
87
|
+
if (!response) {
|
|
88
|
+
console.log("No response received");
|
|
89
|
+
errorMessage.value = "No response received from server. Please try again.";
|
|
90
|
+
return false;
|
|
57
91
|
}
|
|
58
|
-
if (response) {
|
|
92
|
+
if (response.status === "Success") {
|
|
59
93
|
successMessage.value = response.message || "Password updated successfully!";
|
|
60
|
-
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
resetForm();
|
|
96
|
+
}, 7e3);
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
successMessage.value = "";
|
|
99
|
+
}, 2e3);
|
|
61
100
|
return true;
|
|
62
|
-
} else if (response
|
|
63
|
-
|
|
101
|
+
} else if (response.status === "Error") {
|
|
102
|
+
console.log("Error response:", response.message);
|
|
103
|
+
errorMessage.value = formatApiError(response.message);
|
|
64
104
|
return false;
|
|
65
105
|
} else {
|
|
106
|
+
console.log("Unexpected response format:", response);
|
|
66
107
|
errorMessage.value = "Unexpected response from server. Please try again.";
|
|
67
108
|
return false;
|
|
68
109
|
}
|
|
69
110
|
} catch (err) {
|
|
70
|
-
console.error("
|
|
71
|
-
|
|
72
|
-
errorMessage.value = err.data.message || "Failed to update password. Please try again.";
|
|
73
|
-
} else if (err.message) {
|
|
74
|
-
errorMessage.value = err.message;
|
|
75
|
-
} else {
|
|
76
|
-
errorMessage.value = "An unexpected error occurred while updating your password.";
|
|
77
|
-
}
|
|
111
|
+
console.error("Caught error:", err);
|
|
112
|
+
errorMessage.value = "An unexpected error occurred. Please try again.";
|
|
78
113
|
return false;
|
|
79
114
|
} finally {
|
|
80
115
|
loading.value = false;
|
|
116
|
+
console.log("Final state - Error:", errorMessage.value, "Success:", successMessage.value);
|
|
81
117
|
}
|
|
82
118
|
};
|
|
83
119
|
return {
|
|
@@ -1,16 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface ApiResponse<T> {
|
|
3
|
-
status: string;
|
|
4
|
-
message: string | Record<string, string[]> | null;
|
|
5
|
-
data: T | null;
|
|
6
|
-
}
|
|
1
|
+
import type { WebForm, WebFormSubmission, WebFormResponse } from '../stores/webforms.js';
|
|
7
2
|
export declare function useWebforms(): {
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
showSuccessModal: import("vue").Ref<boolean, boolean>;
|
|
4
|
+
currentFormData: import("vue").Ref<{
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
recaptcha: string;
|
|
7
|
+
} | null, WebFormSubmission | {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
recaptcha: string;
|
|
10
|
+
} | null>;
|
|
11
|
+
recaptchaToken: import("vue").Ref<string, string>;
|
|
12
|
+
formLoading: import("vue").Ref<boolean, boolean>;
|
|
10
13
|
webform: import("vue").ComputedRef<{
|
|
11
14
|
id: number;
|
|
15
|
+
title: string;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
fields: {
|
|
18
|
+
id: number;
|
|
19
|
+
name: string;
|
|
20
|
+
label: string;
|
|
21
|
+
type: string;
|
|
22
|
+
required: boolean;
|
|
23
|
+
options?: string[] | undefined;
|
|
24
|
+
validation?: string | undefined;
|
|
25
|
+
placeholder?: string | undefined;
|
|
26
|
+
}[];
|
|
27
|
+
success_message?: string | undefined;
|
|
28
|
+
} | null>;
|
|
29
|
+
webFormReturn: import("vue").ComputedRef<{
|
|
30
|
+
status: string;
|
|
31
|
+
message: string;
|
|
32
|
+
data: any | null;
|
|
12
33
|
} | null>;
|
|
13
|
-
webFormReturn: import("vue").ComputedRef<any>;
|
|
14
34
|
loading: import("vue").ComputedRef<boolean>;
|
|
15
35
|
error: import("vue").ComputedRef<string | null>;
|
|
36
|
+
clearMessages: () => void;
|
|
37
|
+
fetchWebform: (id: number) => Promise<WebForm | null>;
|
|
38
|
+
initFormSubmission: (formData: WebFormSubmission) => void;
|
|
39
|
+
submitInquiry: (formData: WebFormSubmission) => Promise<WebFormResponse>;
|
|
40
|
+
setRecaptchaToken: (token: string) => void;
|
|
41
|
+
closeSuccessModal: () => void;
|
|
42
|
+
resetForm: () => void;
|
|
43
|
+
autoClearMessages: () => void;
|
|
44
|
+
isFormValid: (formData: WebFormSubmission) => boolean;
|
|
16
45
|
};
|