flowrix 1.0.1-beta.9 → 1.0.1-beta.91
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.d.mts +1 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +103 -34
- package/dist/runtime/composables/Blog/useBlogIndex.d.ts +2 -5
- package/dist/runtime/composables/Brand/brand.js +2 -0
- package/dist/runtime/composables/Cart/useCart.d.ts +40 -0
- package/dist/runtime/composables/Cart/useCart.js +10 -0
- package/dist/runtime/composables/Cart/useCartDetail.d.ts +15 -5
- package/dist/runtime/composables/Cart/useCartDetail.js +3 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.d.ts +40 -1
- package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.js +2 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.d.ts +40 -1
- package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.js +2 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/usePaymentMethods.js +3 -14
- package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.d.ts +2 -2
- package/dist/runtime/composables/Checkout/useCheckout.d.ts +84 -73
- package/dist/runtime/composables/Checkout/useCheckout.js +81 -34
- package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.d.ts +43 -0
- package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.js +84 -0
- package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.d.ts +55 -0
- package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.js +196 -0
- package/dist/runtime/composables/Checkout/useCreateAccount.d.ts +7 -7
- package/dist/runtime/composables/Checkout/useCreateAccount.js +3 -1
- package/dist/runtime/composables/Checkout/useDeliveryMethod.d.ts +2 -2
- package/dist/runtime/composables/Checkout/useDeliveryMethod.js +8 -7
- package/dist/runtime/composables/Customer/useBillingAddress.d.ts +112 -0
- package/dist/runtime/composables/Customer/useBillingAddress.js +93 -0
- package/dist/runtime/composables/Customer/useLogin.d.ts +9 -0
- package/dist/runtime/composables/Customer/useLogin.js +34 -0
- package/dist/runtime/composables/Customer/useOrders.d.ts +29 -0
- package/dist/runtime/composables/Customer/useOrders.js +56 -0
- package/dist/runtime/composables/Customer/usePasswordReset.d.ts +26 -0
- package/dist/runtime/composables/Customer/usePasswordReset.js +258 -0
- package/dist/runtime/composables/Customer/useProfile.d.ts +75 -0
- package/dist/runtime/composables/Customer/useProfile.js +106 -0
- package/dist/runtime/composables/Customer/useQuotations.d.ts +32 -0
- package/dist/runtime/composables/Customer/useQuotations.js +40 -0
- package/dist/runtime/composables/Customer/useRegister.d.ts +120 -11
- package/dist/runtime/composables/Customer/useRegister.js +311 -34
- package/dist/runtime/composables/Customer/useShippingAddress.d.ts +121 -0
- package/dist/runtime/composables/Customer/useShippingAddress.js +145 -0
- package/dist/runtime/composables/Customer/useUpdatePassword.d.ts +21 -0
- package/dist/runtime/composables/Customer/useUpdatePassword.js +94 -0
- package/dist/runtime/composables/Customer/useUserCards.d.ts +22 -0
- package/dist/runtime/composables/Customer/useUserCards.js +65 -0
- package/dist/runtime/composables/{useWishlists.d.ts → Customer/useWishlists.d.ts} +6 -19
- package/dist/runtime/composables/{useWishlists.js → Customer/useWishlists.js} +21 -29
- package/dist/runtime/composables/Extras/useCountry.d.ts +11 -6
- package/dist/runtime/composables/Extras/useCountry.js +5 -4
- package/dist/runtime/composables/Header/useHeader.d.ts +6 -20
- package/dist/runtime/composables/Header/useHeader.js +3 -2
- package/dist/runtime/composables/Product/CustomProduct/useSteps.d.ts +1 -1
- package/dist/runtime/composables/Product/useProductComponent.js +2 -0
- package/dist/runtime/composables/Product/useProductSlug.d.ts +8 -1
- package/dist/runtime/composables/Product/useQuickView.d.ts +8 -0
- package/dist/runtime/composables/Product/useQuickView.js +27 -0
- package/dist/runtime/composables/Product/useService.d.ts +1 -1
- package/dist/runtime/composables/Product/useService.js +0 -3
- package/dist/runtime/composables/SideBar/Filters/useFilters.d.ts +2 -2
- package/dist/runtime/composables/SideBar/Filters/useSorting.d.ts +2 -2
- package/dist/runtime/composables/index.d.ts +16 -12
- package/dist/runtime/composables/index.js +16 -12
- package/dist/runtime/composables/useAddresses.js +6 -6
- package/dist/runtime/composables/useCards.js +2 -2
- package/dist/runtime/composables/useDataLayer.js +2 -1
- package/dist/runtime/composables/useLocation.d.ts +2 -12
- package/dist/runtime/composables/useQuotationCheckout.d.ts +78 -0
- package/dist/runtime/composables/useQuotationCheckout.js +138 -0
- package/dist/runtime/middleware/flowrix.d.ts +5 -4
- package/dist/runtime/middleware/flowrix.js +41 -21
- package/dist/runtime/pages/flowrix-default.d.vue.ts +3 -0
- package/dist/runtime/pages/flowrix-default.vue +34 -0
- package/dist/runtime/pages/flowrix-default.vue.d.ts +3 -0
- package/dist/runtime/plugin.d.ts +1 -1
- package/dist/runtime/server/api/albums.d.ts +1 -0
- package/dist/runtime/server/api/albums.js +38 -12
- package/dist/runtime/server/api/auth/forgot.js +1 -1
- package/dist/runtime/server/api/auth/login.js +5 -6
- package/dist/runtime/server/api/auth/logout.js +1 -1
- package/dist/runtime/server/api/auth/register.js +1 -1
- package/dist/runtime/server/api/auth/session.get.js +1 -1
- package/dist/runtime/server/api/auth/user/reset-password.js +1 -1
- package/dist/runtime/server/api/auth/user/session.js +1 -1
- package/dist/runtime/server/api/auth/user/verify-token.js +1 -1
- package/dist/runtime/server/api/banners.js +15 -12
- package/dist/runtime/server/api/brand/[...slug].js +55 -0
- package/dist/runtime/server/api/brand/index.d.ts +3 -0
- package/dist/runtime/server/api/brand/index.js +49 -0
- package/dist/runtime/server/api/cache/[...slug].delete.d.ts +2 -0
- package/dist/runtime/server/api/cache/[...slug].delete.js +40 -0
- package/dist/runtime/server/api/cache/clean.get.d.ts +5 -0
- package/dist/runtime/server/api/cache/clean.get.js +16 -0
- package/dist/runtime/server/api/cart/[slug]/add.d.ts +1 -1
- package/dist/runtime/server/api/cart/[slug]/add.js +11 -11
- package/dist/runtime/server/api/cart/[slug]/update.d.ts +1 -1
- package/dist/runtime/server/api/cart/[slug]/update.js +11 -11
- package/dist/runtime/server/api/{blog/blog.d.ts → cart/related.d.ts} +0 -1
- package/dist/runtime/server/api/cart/related.js +21 -0
- package/dist/runtime/server/api/cart/remove.js +1 -1
- package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +1 -1
- package/dist/runtime/server/api/cart/service/[slug]/add.js +12 -12
- package/dist/runtime/server/api/catalog/brands.d.ts +3 -0
- package/dist/runtime/server/api/catalog/brands.js +49 -0
- package/dist/runtime/server/api/catalog/categories.js +22 -16
- package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
- package/dist/runtime/server/api/catalog/categoriesall.js +49 -0
- package/dist/runtime/server/api/catalog/featured.js +22 -14
- package/dist/runtime/server/api/catalog/posts.d.ts +3 -0
- package/dist/runtime/server/api/catalog/posts.js +49 -0
- package/dist/runtime/server/api/catalog/samples.js +22 -16
- package/dist/runtime/server/api/catalog/search.js +21 -15
- package/dist/runtime/server/api/category/[...slug].js +22 -16
- package/dist/runtime/server/api/checkout/applyCoupon.d.ts +1 -1
- package/dist/runtime/server/api/checkout/applyCoupon.js +13 -13
- package/dist/runtime/server/api/checkout/configs.d.ts +1 -1
- package/dist/runtime/server/api/checkout/configs.js +11 -11
- package/dist/runtime/server/api/checkout/countries.d.ts +1 -1
- package/dist/runtime/server/api/checkout/countries.js +5 -9
- package/dist/runtime/server/api/checkout/paymentmethod.d.ts +1 -1
- package/dist/runtime/server/api/checkout/paymentmethod.js +16 -11
- package/dist/runtime/server/api/checkout/quotation/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/[slug].js +21 -0
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +37 -0
- package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/guest/customer.js +21 -0
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +23 -0
- package/dist/runtime/server/api/{blog/[slug].js → cmspost/[...slug].js} +19 -18
- package/dist/runtime/server/api/cmspost/all.d.ts +3 -0
- package/dist/runtime/server/api/cmspost/all.js +49 -0
- package/dist/runtime/server/api/company/profile.d.ts +1 -1
- package/dist/runtime/server/api/company/profile.js +9 -9
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +1 -1
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +48 -15
- package/dist/runtime/server/api/contact-center/webforms/create.d.ts +1 -1
- package/dist/runtime/server/api/contact-center/webforms/create.js +10 -10
- package/dist/runtime/server/api/countries.d.ts +2 -0
- package/dist/runtime/server/api/countries.js +42 -0
- package/dist/runtime/server/api/customer/address/add.js +1 -1
- package/dist/runtime/server/api/customer/address/delete.js +2 -2
- package/dist/runtime/server/api/customer/address/setshipping.js +1 -1
- package/dist/runtime/server/api/customer/address/update.js +1 -1
- package/dist/runtime/server/api/customer/cards/delete.js +2 -2
- package/dist/runtime/server/api/customer/cards/get.js +2 -2
- package/dist/runtime/server/api/customer/change-password.js +2 -2
- package/dist/runtime/server/api/customer/checkout.js +1 -1
- package/dist/runtime/server/api/customer/orders.js +2 -2
- package/dist/runtime/server/api/customer/profile/update.js +1 -1
- package/dist/runtime/server/api/customer/quotations.js +2 -2
- package/dist/runtime/server/api/customer/search.js +1 -1
- package/dist/runtime/server/api/customer/tax-invoice.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/add.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/createWishList.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/get.js +2 -2
- package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/updateWishList.js +2 -2
- package/dist/runtime/server/api/featured.d.ts +3 -0
- package/dist/runtime/server/api/featured.js +49 -0
- package/dist/runtime/server/api/generate/robots.get.d.ts +2 -0
- package/dist/runtime/server/api/generate/robots.get.js +20 -0
- package/dist/runtime/server/api/generate/sitemap.get.d.ts +2 -0
- package/dist/runtime/server/api/generate/sitemap.get.js +32 -0
- package/dist/runtime/server/api/location.d.ts +1 -1
- package/dist/runtime/server/api/location.js +20 -12
- package/dist/runtime/server/api/nav/[id]/links.d.ts +1 -0
- package/dist/runtime/server/api/nav/[id]/links.js +48 -14
- package/dist/runtime/server/api/page/{[slug].js → [...slug].js} +18 -17
- package/dist/runtime/server/api/product/[...slug].js +23 -9
- package/dist/runtime/server/api/{v2/[...slug].d.ts → quickview/[slug].d.ts} +0 -1
- package/dist/runtime/server/api/quickview/[slug].js +17 -0
- package/dist/runtime/server/api/reviews.d.ts +2 -0
- package/dist/runtime/server/api/reviews.js +18 -0
- package/dist/runtime/server/api/samples.d.ts +3 -0
- package/dist/runtime/server/api/samples.js +50 -0
- package/dist/runtime/server/api/search.d.ts +3 -0
- package/dist/runtime/server/api/search.js +50 -0
- package/dist/runtime/server/api/service/[slug].js +17 -13
- package/dist/runtime/server/api/service/availability.d.ts +1 -1
- package/dist/runtime/server/api/service/availability.js +11 -13
- package/dist/runtime/server/api/service/getall.d.ts +3 -0
- package/dist/runtime/server/api/service/getall.js +55 -0
- package/dist/runtime/server/api/shop.d.ts +3 -0
- package/dist/runtime/server/api/shop.js +50 -0
- package/dist/runtime/server/api/subscribe.d.ts +1 -1
- package/dist/runtime/server/api/subscribe.js +19 -14
- package/dist/runtime/server/api/v2/[...slug].get.d.ts +2 -0
- package/dist/runtime/server/api/v2/[...slug].get.js +16 -0
- package/dist/runtime/server/api/webform.d.ts +3 -0
- package/dist/runtime/server/api/webform.js +52 -0
- package/dist/runtime/server/tsconfig.json +3 -3
- package/dist/runtime/stores/Cart.d.ts +12 -0
- package/dist/runtime/stores/Cart.js +56 -19
- package/dist/runtime/stores/Checkout.d.ts +9 -15
- package/dist/runtime/stores/Checkout.js +19 -24
- package/dist/runtime/stores/Search.d.ts +1 -1
- package/dist/runtime/stores/Services.js +2 -2
- package/dist/runtime/stores/auth.d.ts +8 -11
- package/dist/runtime/stores/auth.js +390 -8
- package/dist/runtime/stores/countries.d.ts +1 -3
- package/dist/runtime/stores/countries.js +4 -8
- package/dist/runtime/stores/product/slug.d.ts +1 -17
- package/dist/runtime/stores/wishlists.d.ts +114 -6
- package/dist/runtime/stores/wishlists.js +209 -9
- package/dist/runtime/utils/api.js +9 -13
- package/dist/runtime/utils/htmlCache.d.ts +2 -2
- package/dist/runtime/utils/htmlCache.js +23 -13
- package/dist/types.d.mts +6 -2
- package/package.json +30 -20
- package/dist/runtime/composables/Checkout/useBillingAddress.d.ts +0 -19
- package/dist/runtime/composables/Checkout/useBillingAddress.js +0 -82
- package/dist/runtime/composables/Checkout/useShippingAddress.d.ts +0 -9
- package/dist/runtime/composables/Checkout/useShippingAddress.js +0 -121
- package/dist/runtime/composables/useAuth.d.ts +0 -45
- package/dist/runtime/composables/useAuth.js +0 -180
- package/dist/runtime/composables/useCountries.d.ts +0 -12
- package/dist/runtime/composables/useCountries.js +0 -50
- package/dist/runtime/composables/useOrders.d.ts +0 -21
- package/dist/runtime/composables/useOrders.js +0 -82
- package/dist/runtime/composables/useQuotations.d.ts +0 -14
- package/dist/runtime/composables/useQuotations.js +0 -50
- package/dist/runtime/plugins/fullReload.client.d.ts +0 -2
- package/dist/runtime/plugins/fullReload.client.js +0 -10
- package/dist/runtime/server/api/blog/blog.js +0 -17
- package/dist/runtime/server/api/brand/[slug].js +0 -58
- package/dist/runtime/server/api/v2/[...slug].js +0 -9
- /package/dist/runtime/server/api/brand/{[slug].d.ts → [...slug].d.ts} +0 -0
- /package/dist/runtime/server/api/{blog/[slug].d.ts → cmspost/[...slug].d.ts} +0 -0
- /package/dist/runtime/server/api/page/{[slug].d.ts → [...slug].d.ts} +0 -0
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { defineStore } from "pinia";
|
|
2
|
+
import { flowrixApi } from "../middleware/flowrix.js";
|
|
3
|
+
import { useRuntimeConfig } from "#imports";
|
|
4
|
+
function formatErrorMessage(message) {
|
|
5
|
+
if (Array.isArray(message)) {
|
|
6
|
+
return message.join(", ");
|
|
7
|
+
}
|
|
8
|
+
return message;
|
|
9
|
+
}
|
|
2
10
|
export const useAuthStore = defineStore("auth", {
|
|
3
11
|
state: () => ({
|
|
4
12
|
user: null,
|
|
@@ -7,13 +15,383 @@ export const useAuthStore = defineStore("auth", {
|
|
|
7
15
|
_hydrated: false
|
|
8
16
|
}),
|
|
9
17
|
actions: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
async userLogin(userFields) {
|
|
19
|
+
try {
|
|
20
|
+
this.user = null;
|
|
21
|
+
const apiUrl = "login";
|
|
22
|
+
const config = useRuntimeConfig();
|
|
23
|
+
let rawCookies = "";
|
|
24
|
+
if (process.client) {
|
|
25
|
+
rawCookies = document.cookie || "";
|
|
26
|
+
}
|
|
27
|
+
const apiConfig = {
|
|
28
|
+
...config,
|
|
29
|
+
cookies: rawCookies
|
|
30
|
+
};
|
|
31
|
+
const response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
32
|
+
body: userFields
|
|
33
|
+
});
|
|
34
|
+
if (response.status == "Success") {
|
|
35
|
+
if (process.client) {
|
|
36
|
+
const token = response?.data?.access_token;
|
|
37
|
+
const customertype = response?.data?.user?.customertype?.id || 1;
|
|
38
|
+
const expiryDate = /* @__PURE__ */ new Date();
|
|
39
|
+
expiryDate.setFullYear(expiryDate.getFullYear() + 100);
|
|
40
|
+
document.cookie = `authToken=${token}; path=/; expires=${expiryDate.toUTCString()}; SameSite=None; Secure`;
|
|
41
|
+
document.cookie = `customertype=${customertype}; path=/; expires=${expiryDate.toUTCString()}; SameSite=None; Secure`;
|
|
42
|
+
}
|
|
43
|
+
this.token = response.data.access_token;
|
|
44
|
+
this.user = response.data.user;
|
|
45
|
+
this.isAuthenticated = true;
|
|
46
|
+
}
|
|
47
|
+
return response;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return error.data;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
async signUp(userFields) {
|
|
53
|
+
try {
|
|
54
|
+
this.user = null;
|
|
55
|
+
const apiUrl = "mystore/customer/create";
|
|
56
|
+
const config = useRuntimeConfig();
|
|
57
|
+
let rawCookies = "";
|
|
58
|
+
if (process.client) {
|
|
59
|
+
rawCookies = document.cookie || "";
|
|
60
|
+
}
|
|
61
|
+
const apiConfig = {
|
|
62
|
+
...config,
|
|
63
|
+
cookies: rawCookies
|
|
64
|
+
};
|
|
65
|
+
const response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
66
|
+
body: userFields
|
|
67
|
+
});
|
|
68
|
+
if (response.status == "Success") {
|
|
69
|
+
const authTokenCookie = useCookie("authToken", {
|
|
70
|
+
sameSite: "none",
|
|
71
|
+
// cross-site requests
|
|
72
|
+
secure: true,
|
|
73
|
+
// must be https
|
|
74
|
+
path: "/",
|
|
75
|
+
expires: /* @__PURE__ */ new Date("2099-12-31")
|
|
76
|
+
});
|
|
77
|
+
authTokenCookie.value = response.data.access_token;
|
|
78
|
+
this.user = response.data.user;
|
|
79
|
+
}
|
|
80
|
+
return response;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return error.data;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
async fetchProfile() {
|
|
86
|
+
try {
|
|
87
|
+
const config = useRuntimeConfig();
|
|
88
|
+
let rawCookies = "";
|
|
89
|
+
if (process.client) {
|
|
90
|
+
rawCookies = document.cookie || "";
|
|
91
|
+
}
|
|
92
|
+
const apiConfig = {
|
|
93
|
+
...config,
|
|
94
|
+
cookies: rawCookies
|
|
95
|
+
};
|
|
96
|
+
const apiUrl = "mystore/customer/profile";
|
|
97
|
+
const response = await flowrixApi.get(apiUrl, apiConfig);
|
|
98
|
+
if (response.status === "Success" && response.data) {
|
|
99
|
+
this.user = response.data;
|
|
100
|
+
return response.data;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error("Fetch profile failed:", error);
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
async updateProfile(userData) {
|
|
109
|
+
try {
|
|
110
|
+
const config = useRuntimeConfig();
|
|
111
|
+
let rawCookies = "";
|
|
112
|
+
if (process.client) {
|
|
113
|
+
rawCookies = document.cookie || "";
|
|
114
|
+
}
|
|
115
|
+
const apiConfig = {
|
|
116
|
+
...config,
|
|
117
|
+
cookies: rawCookies
|
|
118
|
+
};
|
|
119
|
+
const apiUrl = "mystore/customer/profile/update";
|
|
120
|
+
const response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
121
|
+
body: userData
|
|
122
|
+
});
|
|
123
|
+
if (response.status === "Success") {
|
|
124
|
+
await this.fetchProfile();
|
|
125
|
+
return { status: response.status, message: response.message || "Profile Updated Successfully" };
|
|
126
|
+
} else {
|
|
127
|
+
const errorMessage = response.message;
|
|
128
|
+
throw new Error(errorMessage);
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
return error.data;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
async fetchUserCards() {
|
|
135
|
+
try {
|
|
136
|
+
const config = useRuntimeConfig();
|
|
137
|
+
let rawCookies = "";
|
|
138
|
+
if (process.client) {
|
|
139
|
+
rawCookies = document.cookie || "";
|
|
140
|
+
}
|
|
141
|
+
const apiConfig = {
|
|
142
|
+
...config,
|
|
143
|
+
cookies: rawCookies
|
|
144
|
+
};
|
|
145
|
+
const apiUrl = "mystore/customer/cards";
|
|
146
|
+
const response = await flowrixApi.get(apiUrl, apiConfig);
|
|
147
|
+
if (response.status === "Success" && response.data) {
|
|
148
|
+
this.user = response.data;
|
|
149
|
+
return response.data;
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error("Fetch user cards failed:", error);
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
async changePassword(userData) {
|
|
158
|
+
try {
|
|
159
|
+
const config = useRuntimeConfig();
|
|
160
|
+
let rawCookies = "";
|
|
161
|
+
if (process.client) {
|
|
162
|
+
rawCookies = document.cookie || "";
|
|
163
|
+
}
|
|
164
|
+
const apiConfig = {
|
|
165
|
+
...config,
|
|
166
|
+
cookies: rawCookies
|
|
167
|
+
};
|
|
168
|
+
const apiUrl = "mystore/customer/change-password";
|
|
169
|
+
const response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
170
|
+
body: userData
|
|
171
|
+
});
|
|
172
|
+
if (response.status === "Success") {
|
|
173
|
+
return { status: response.status, message: response.message || "Password Update Successfully" };
|
|
174
|
+
} else {
|
|
175
|
+
const errorMessage = response.message;
|
|
176
|
+
throw new Error(errorMessage);
|
|
177
|
+
}
|
|
178
|
+
} catch (error) {
|
|
179
|
+
return error.data;
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
async deleteCard(cardId) {
|
|
183
|
+
try {
|
|
184
|
+
const config = useRuntimeConfig();
|
|
185
|
+
let rawCookies = "";
|
|
186
|
+
if (process.client) {
|
|
187
|
+
rawCookies = document.cookie || "";
|
|
188
|
+
}
|
|
189
|
+
const apiConfig = {
|
|
190
|
+
...config,
|
|
191
|
+
cookies: rawCookies
|
|
192
|
+
};
|
|
193
|
+
const apiUrl = `mystore/customer/cards/${cardId}`;
|
|
194
|
+
const response = await flowrixApi.delete(apiUrl, apiConfig);
|
|
195
|
+
if (response.status === "Success") {
|
|
196
|
+
return { status: response.status, message: response.message || "Card deleted Successfully" };
|
|
197
|
+
} else {
|
|
198
|
+
const errorMessage = response.message;
|
|
199
|
+
throw new Error(errorMessage);
|
|
200
|
+
}
|
|
201
|
+
} catch (error) {
|
|
202
|
+
return error.data;
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
async fetchOrders() {
|
|
206
|
+
try {
|
|
207
|
+
const config = useRuntimeConfig();
|
|
208
|
+
let rawCookies = "";
|
|
209
|
+
if (process.client) {
|
|
210
|
+
rawCookies = document.cookie || "";
|
|
211
|
+
}
|
|
212
|
+
const apiConfig = {
|
|
213
|
+
...config,
|
|
214
|
+
cookies: rawCookies
|
|
215
|
+
};
|
|
216
|
+
const apiUrl = "mystore/customer/orders";
|
|
217
|
+
const response = await flowrixApi.get(apiUrl, apiConfig);
|
|
218
|
+
if (response.status === "Success" && response.data) {
|
|
219
|
+
return response.data;
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
} catch (error) {
|
|
223
|
+
console.error("Fetch Orders failed:", error);
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
async downloadInvoice(orderNo) {
|
|
228
|
+
try {
|
|
229
|
+
const config = useRuntimeConfig();
|
|
230
|
+
let rawCookies = "";
|
|
231
|
+
if (process.client) {
|
|
232
|
+
rawCookies = document.cookie || "";
|
|
233
|
+
}
|
|
234
|
+
const apiConfig = {
|
|
235
|
+
...config,
|
|
236
|
+
cookies: rawCookies
|
|
237
|
+
};
|
|
238
|
+
const apiUrl = `mystore/customer/orders/${orderNo}/tax-invoice`;
|
|
239
|
+
const response = await flowrixApi.get(apiUrl, apiConfig);
|
|
240
|
+
const blob = new Blob([response], { type: "application/pdf" });
|
|
241
|
+
const url = window.URL.createObjectURL(blob);
|
|
242
|
+
const link = document.createElement("a");
|
|
243
|
+
link.href = url;
|
|
244
|
+
link.setAttribute("download", `tax-invoice-${orderNo}.pdf`);
|
|
245
|
+
document.body.appendChild(link);
|
|
246
|
+
link.click();
|
|
247
|
+
document.body.removeChild(link);
|
|
248
|
+
window.URL.revokeObjectURL(url);
|
|
249
|
+
return response;
|
|
250
|
+
} catch (err) {
|
|
251
|
+
console.error("Download invoice error:", err);
|
|
252
|
+
return err.data;
|
|
253
|
+
} finally {
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
async fetchQuotations() {
|
|
257
|
+
try {
|
|
258
|
+
const config = useRuntimeConfig();
|
|
259
|
+
let rawCookies = "";
|
|
260
|
+
if (process.client) {
|
|
261
|
+
rawCookies = document.cookie || "";
|
|
262
|
+
}
|
|
263
|
+
const apiConfig = {
|
|
264
|
+
...config,
|
|
265
|
+
cookies: rawCookies
|
|
266
|
+
};
|
|
267
|
+
const apiUrl = "mystore/customer/quotations";
|
|
268
|
+
const response = await flowrixApi.get(apiUrl, apiConfig);
|
|
269
|
+
if (response.status === "Success" && response.data) {
|
|
270
|
+
return response.data;
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console.error("Fetch quotations failed:", error);
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
async setAddress(addressData, method = "add") {
|
|
279
|
+
try {
|
|
280
|
+
const config = useRuntimeConfig();
|
|
281
|
+
let rawCookies = "";
|
|
282
|
+
if (process.client) {
|
|
283
|
+
rawCookies = document.cookie || "";
|
|
284
|
+
}
|
|
285
|
+
const apiConfig = {
|
|
286
|
+
...config,
|
|
287
|
+
cookies: rawCookies
|
|
288
|
+
};
|
|
289
|
+
let response = {};
|
|
290
|
+
if (method == "update") {
|
|
291
|
+
const apiUrl = `mystore/customer/address/${addressData.id}/update`;
|
|
292
|
+
response = await flowrixApi.patch(apiUrl, apiConfig, {
|
|
293
|
+
body: addressData
|
|
294
|
+
});
|
|
295
|
+
} else if (method == "delete") {
|
|
296
|
+
const apiUrl = `mystore/customer/address/${addressData.id}/delete`;
|
|
297
|
+
response = await flowrixApi.patch(apiUrl, apiConfig);
|
|
298
|
+
} else if (method == "setshipping") {
|
|
299
|
+
const apiUrl = `mystore/customer/address/${addressData.id}/setshipping`;
|
|
300
|
+
response = await flowrixApi.post(apiUrl, apiConfig);
|
|
301
|
+
} else {
|
|
302
|
+
const apiUrl = "mystore/customer/address/add";
|
|
303
|
+
response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
304
|
+
body: addressData
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if (response.status === "Success") {
|
|
308
|
+
await this.fetchProfile();
|
|
309
|
+
return response;
|
|
310
|
+
} else {
|
|
311
|
+
return response;
|
|
312
|
+
}
|
|
313
|
+
} catch (error) {
|
|
314
|
+
return error.data;
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
// Password Reset APIs
|
|
318
|
+
async verifyEmail(email) {
|
|
319
|
+
try {
|
|
320
|
+
const config = useRuntimeConfig();
|
|
321
|
+
let rawCookies = "";
|
|
322
|
+
if (process.client) {
|
|
323
|
+
rawCookies = document.cookie || "";
|
|
324
|
+
}
|
|
325
|
+
const apiConfig = {
|
|
326
|
+
...config,
|
|
327
|
+
cookies: rawCookies
|
|
328
|
+
};
|
|
329
|
+
const response = await flowrixApi.post("verify-email", apiConfig, {
|
|
330
|
+
body: { email }
|
|
331
|
+
});
|
|
332
|
+
return response;
|
|
333
|
+
} catch (error) {
|
|
334
|
+
console.error("Verify email error:", error);
|
|
335
|
+
const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Email verification failed";
|
|
336
|
+
return {
|
|
337
|
+
status: "Error",
|
|
338
|
+
message,
|
|
339
|
+
data: null
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
async verifyToken(email, token) {
|
|
344
|
+
try {
|
|
345
|
+
const config = useRuntimeConfig();
|
|
346
|
+
let rawCookies = "";
|
|
347
|
+
if (process.client) {
|
|
348
|
+
rawCookies = document.cookie || "";
|
|
349
|
+
}
|
|
350
|
+
const apiConfig = {
|
|
351
|
+
...config,
|
|
352
|
+
cookies: rawCookies
|
|
353
|
+
};
|
|
354
|
+
const response = await flowrixApi.post("verify-token", apiConfig, {
|
|
355
|
+
body: { email, token }
|
|
356
|
+
});
|
|
357
|
+
return response;
|
|
358
|
+
} catch (error) {
|
|
359
|
+
console.error("Verify token error:", error);
|
|
360
|
+
const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Token verification failed";
|
|
361
|
+
return {
|
|
362
|
+
status: "Error",
|
|
363
|
+
message,
|
|
364
|
+
data: null
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
async resetPassword(token, password, password_confirmation) {
|
|
369
|
+
try {
|
|
370
|
+
const config = useRuntimeConfig();
|
|
371
|
+
let rawCookies = "";
|
|
372
|
+
if (process.client) {
|
|
373
|
+
rawCookies = document.cookie || "";
|
|
374
|
+
}
|
|
375
|
+
const apiConfig = {
|
|
376
|
+
...config,
|
|
377
|
+
cookies: rawCookies
|
|
378
|
+
};
|
|
379
|
+
const response = await flowrixApi.post("reset-password", apiConfig, {
|
|
380
|
+
body: {
|
|
381
|
+
token,
|
|
382
|
+
password,
|
|
383
|
+
password_confirmation
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
return response;
|
|
387
|
+
} catch (error) {
|
|
388
|
+
console.error("Reset password error:", error);
|
|
389
|
+
const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Password reset failed";
|
|
390
|
+
return {
|
|
391
|
+
status: "Error",
|
|
392
|
+
message,
|
|
393
|
+
data: null
|
|
394
|
+
};
|
|
17
395
|
}
|
|
18
396
|
},
|
|
19
397
|
loadAuth() {
|
|
@@ -45,7 +423,6 @@ export const useAuthStore = defineStore("auth", {
|
|
|
45
423
|
localStorage.removeItem("auth_user");
|
|
46
424
|
}
|
|
47
425
|
},
|
|
48
|
-
// Mark as hydrated without loading
|
|
49
426
|
setHydrated() {
|
|
50
427
|
this._hydrated = true;
|
|
51
428
|
}
|
|
@@ -55,5 +432,10 @@ export const useAuthStore = defineStore("auth", {
|
|
|
55
432
|
getToken: (state) => state.token,
|
|
56
433
|
isLoggedIn: (state) => state.isAuthenticated,
|
|
57
434
|
isHydrated: (state) => state._hydrated
|
|
435
|
+
},
|
|
436
|
+
persist: {
|
|
437
|
+
enabled: true,
|
|
438
|
+
key: "user",
|
|
439
|
+
storage: typeof window !== "undefined" ? localStorage : void 0
|
|
58
440
|
}
|
|
59
441
|
});
|
|
@@ -4,7 +4,5 @@ export declare const useCountriesStore: import("pinia").StoreDefinition<"countri
|
|
|
4
4
|
loading: boolean;
|
|
5
5
|
error: string | null;
|
|
6
6
|
}, {}, {
|
|
7
|
-
|
|
8
|
-
setLoading(loading: boolean): void;
|
|
9
|
-
setError(error: string | null): void;
|
|
7
|
+
getCountries(): Promise<any>;
|
|
10
8
|
}>;
|
|
@@ -6,14 +6,10 @@ export const useCountriesStore = defineStore("countries", {
|
|
|
6
6
|
error: null
|
|
7
7
|
}),
|
|
8
8
|
actions: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.loading = loading;
|
|
14
|
-
},
|
|
15
|
-
setError(error) {
|
|
16
|
-
this.error = error;
|
|
9
|
+
async getCountries() {
|
|
10
|
+
const response = await $fetch("/api/countries");
|
|
11
|
+
this.countries = response;
|
|
12
|
+
return response;
|
|
17
13
|
}
|
|
18
14
|
}
|
|
19
15
|
});
|
|
@@ -155,23 +155,7 @@ export declare const useProductSlugStore: import("pinia").StoreDefinition<"produ
|
|
|
155
155
|
lastFetchedSlug: string | null;
|
|
156
156
|
} & import("pinia").PiniaCustomStateProperties<ProductSlugState>) => string | null | undefined;
|
|
157
157
|
}, {
|
|
158
|
-
fetchProductBySlug(slug: string): Promise<
|
|
159
|
-
[x: string]: any;
|
|
160
|
-
id?: string | number | undefined;
|
|
161
|
-
slug?: string | undefined;
|
|
162
|
-
name?: string | undefined;
|
|
163
|
-
description?: string | undefined;
|
|
164
|
-
price?: string | undefined;
|
|
165
|
-
rrp?: string | undefined;
|
|
166
|
-
pricefloat?: number | undefined;
|
|
167
|
-
rpfloat?: number | undefined;
|
|
168
|
-
brandimage?: string | undefined;
|
|
169
|
-
variations?: string | undefined;
|
|
170
|
-
template?: string | undefined;
|
|
171
|
-
images?: string[] | undefined;
|
|
172
|
-
category?: string | undefined;
|
|
173
|
-
stock?: number | undefined;
|
|
174
|
-
} | null>;
|
|
158
|
+
fetchProductBySlug(slug: string): Promise<any>;
|
|
175
159
|
clearProduct(): void;
|
|
176
160
|
clearError(): void;
|
|
177
161
|
updateProduct(updates: Partial<Product>): void;
|
|
@@ -1,28 +1,136 @@
|
|
|
1
1
|
export interface Wishlist {
|
|
2
2
|
id: number;
|
|
3
|
-
|
|
3
|
+
title: string;
|
|
4
|
+
default: boolean;
|
|
5
|
+
created_at: string;
|
|
4
6
|
}
|
|
5
7
|
export interface WishlistProduct {
|
|
6
8
|
id: number;
|
|
7
|
-
|
|
9
|
+
slug: string;
|
|
10
|
+
name: string;
|
|
11
|
+
image: string;
|
|
12
|
+
price: string;
|
|
13
|
+
pricefloat: number;
|
|
14
|
+
rp: string;
|
|
15
|
+
rpfloat: number;
|
|
16
|
+
type: string;
|
|
17
|
+
brandimage: string;
|
|
8
18
|
}
|
|
9
19
|
export interface WishlistProducts {
|
|
10
20
|
[listId: number]: WishlistProduct[];
|
|
11
21
|
}
|
|
22
|
+
export interface CreateWishlistData {
|
|
23
|
+
title: string;
|
|
24
|
+
default: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface UpdateWishlistData {
|
|
27
|
+
title: string;
|
|
28
|
+
default: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface AddToWishlistData {
|
|
31
|
+
}
|
|
32
|
+
export interface ApiResponse<T> {
|
|
33
|
+
status: string;
|
|
34
|
+
message: string | Record<string, string[]> | null;
|
|
35
|
+
data: T | null;
|
|
36
|
+
}
|
|
12
37
|
export declare const useWishlistsStore: import("pinia").StoreDefinition<"wishlists", {
|
|
13
38
|
wishlists: Wishlist[];
|
|
14
39
|
wishlistProducts: WishlistProducts;
|
|
15
40
|
loading: boolean;
|
|
16
41
|
error: string | null;
|
|
17
|
-
}, {
|
|
42
|
+
}, {
|
|
43
|
+
getWishlists: (state: {
|
|
44
|
+
wishlists: {
|
|
45
|
+
id: number;
|
|
46
|
+
title: string;
|
|
47
|
+
default: boolean;
|
|
48
|
+
created_at: string;
|
|
49
|
+
}[];
|
|
50
|
+
wishlistProducts: WishlistProducts;
|
|
51
|
+
loading: boolean;
|
|
52
|
+
error: string | null;
|
|
53
|
+
} & import("pinia").PiniaCustomStateProperties<{
|
|
54
|
+
wishlists: Wishlist[];
|
|
55
|
+
wishlistProducts: WishlistProducts;
|
|
56
|
+
loading: boolean;
|
|
57
|
+
error: string | null;
|
|
58
|
+
}>) => {
|
|
59
|
+
id: number;
|
|
60
|
+
title: string;
|
|
61
|
+
default: boolean;
|
|
62
|
+
created_at: string;
|
|
63
|
+
}[];
|
|
64
|
+
getWishlistProducts: (state: {
|
|
65
|
+
wishlists: {
|
|
66
|
+
id: number;
|
|
67
|
+
title: string;
|
|
68
|
+
default: boolean;
|
|
69
|
+
created_at: string;
|
|
70
|
+
}[];
|
|
71
|
+
wishlistProducts: WishlistProducts;
|
|
72
|
+
loading: boolean;
|
|
73
|
+
error: string | null;
|
|
74
|
+
} & import("pinia").PiniaCustomStateProperties<{
|
|
75
|
+
wishlists: Wishlist[];
|
|
76
|
+
wishlistProducts: WishlistProducts;
|
|
77
|
+
loading: boolean;
|
|
78
|
+
error: string | null;
|
|
79
|
+
}>) => (listId: number) => WishlistProduct[];
|
|
80
|
+
isLoading: (state: {
|
|
81
|
+
wishlists: {
|
|
82
|
+
id: number;
|
|
83
|
+
title: string;
|
|
84
|
+
default: boolean;
|
|
85
|
+
created_at: string;
|
|
86
|
+
}[];
|
|
87
|
+
wishlistProducts: WishlistProducts;
|
|
88
|
+
loading: boolean;
|
|
89
|
+
error: string | null;
|
|
90
|
+
} & import("pinia").PiniaCustomStateProperties<{
|
|
91
|
+
wishlists: Wishlist[];
|
|
92
|
+
wishlistProducts: WishlistProducts;
|
|
93
|
+
loading: boolean;
|
|
94
|
+
error: string | null;
|
|
95
|
+
}>) => boolean;
|
|
96
|
+
getError: (state: {
|
|
97
|
+
wishlists: {
|
|
98
|
+
id: number;
|
|
99
|
+
title: string;
|
|
100
|
+
default: boolean;
|
|
101
|
+
created_at: string;
|
|
102
|
+
}[];
|
|
103
|
+
wishlistProducts: WishlistProducts;
|
|
104
|
+
loading: boolean;
|
|
105
|
+
error: string | null;
|
|
106
|
+
} & import("pinia").PiniaCustomStateProperties<{
|
|
107
|
+
wishlists: Wishlist[];
|
|
108
|
+
wishlistProducts: WishlistProducts;
|
|
109
|
+
loading: boolean;
|
|
110
|
+
error: string | null;
|
|
111
|
+
}>) => string | null;
|
|
112
|
+
}, {
|
|
113
|
+
setLoading(loading: boolean): void;
|
|
114
|
+
setError(error: string | null): void;
|
|
18
115
|
setWishlists(wishlists: Wishlist[]): void;
|
|
19
116
|
addWishlist(wishlist: Wishlist): void;
|
|
20
117
|
updateWishlist(updatedWishlist: Wishlist): void;
|
|
21
|
-
|
|
118
|
+
updateWishlist(id: number, data: UpdateWishlistData): Promise<ApiResponse<Wishlist>>;
|
|
119
|
+
removeWishlist(wishlistId: number): void;
|
|
22
120
|
setWishlistProducts(listId: number, products: WishlistProduct[]): void;
|
|
23
121
|
addWishlistProduct(listId: number, product: WishlistProduct): void;
|
|
24
122
|
removeWishlistProduct(listId: number, productSlug: string): void;
|
|
25
123
|
clearWishlistProducts(listId: number): void;
|
|
26
|
-
|
|
27
|
-
|
|
124
|
+
fetchWishlists(force?: boolean): Promise<ApiResponse<Wishlist[]>>;
|
|
125
|
+
fetchWishlistProducts(listId: number): Promise<ApiResponse<{
|
|
126
|
+
id: number;
|
|
127
|
+
title: string;
|
|
128
|
+
default: boolean;
|
|
129
|
+
created_at: string;
|
|
130
|
+
products: WishlistProduct[];
|
|
131
|
+
}>>;
|
|
132
|
+
createWishlist(data: CreateWishlistData): Promise<ApiResponse<Wishlist>>;
|
|
133
|
+
addToWishlist(listId: number, productSlug: string, data?: AddToWishlistData): Promise<ApiResponse<WishlistProduct>>;
|
|
134
|
+
removeFromWishlist(listId: number, productSlug: string): Promise<ApiResponse<void>>;
|
|
135
|
+
deleteWishlist(id: number): Promise<ApiResponse<void>>;
|
|
28
136
|
}>;
|