flowrix 1.0.1-beta.8 → 1.0.1-beta.81
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 +94 -29
- 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 +36 -28
- package/dist/runtime/composables/Checkout/{useBillingAddress.d.ts → useCheckoutBillingAddress.d.ts} +6 -6
- package/dist/runtime/composables/Checkout/{useBillingAddress.js → useCheckoutBillingAddress.js} +6 -1
- package/dist/runtime/composables/Checkout/{useShippingAddress.d.ts → useCheckoutShippingAddress.d.ts} +1 -1
- package/dist/runtime/composables/Checkout/{useShippingAddress.js → useCheckoutShippingAddress.js} +7 -2
- 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/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 +15 -12
- package/dist/runtime/composables/index.js +15 -12
- package/dist/runtime/composables/useAddresses.js +6 -6
- package/dist/runtime/composables/useCards.js +2 -2
- 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/plugin.d.ts +1 -1
- package/dist/runtime/server/api/albums.js +1 -1
- 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 +2 -2
- package/dist/runtime/server/api/brand/{[slug].js → [...slug].js} +17 -17
- package/dist/runtime/server/api/brand/index.d.ts +2 -0
- package/dist/runtime/server/api/brand/index.js +23 -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.js +1 -1
- package/dist/runtime/server/api/cart/[slug]/update.js +1 -1
- package/dist/runtime/server/api/cart/related.d.ts +2 -0
- 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.js +1 -1
- package/dist/runtime/server/api/catalog/categories.js +5 -4
- package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
- package/dist/runtime/server/api/catalog/categoriesall.js +44 -0
- package/dist/runtime/server/api/catalog/featured.js +5 -4
- package/dist/runtime/server/api/catalog/samples.js +5 -4
- package/dist/runtime/server/api/catalog/search.js +5 -4
- package/dist/runtime/server/api/category/[...slug].js +18 -14
- package/dist/runtime/server/api/checkout/applyCoupon.js +1 -1
- package/dist/runtime/server/api/checkout/configs.d.ts +1 -1
- package/dist/runtime/server/api/checkout/configs.js +10 -11
- package/dist/runtime/server/api/checkout/countries.js +1 -1
- package/dist/runtime/server/api/checkout/paymentmethod.js +7 -7
- 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} +7 -9
- package/dist/runtime/server/api/{blog/blog.js → cmspost/all.js} +2 -2
- 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.js +1 -1
- package/dist/runtime/server/api/contact-center/webforms/create.js +1 -1
- package/dist/runtime/server/api/countries.d.ts +2 -0
- package/dist/runtime/server/api/countries.js +35 -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 +2 -0
- package/dist/runtime/server/api/featured.js +16 -0
- package/dist/runtime/server/api/location.js +1 -1
- package/dist/runtime/server/api/nav/[id]/links.js +1 -1
- package/dist/runtime/server/api/page/{[slug].js → [...slug].js} +6 -8
- package/dist/runtime/server/api/product/[...slug].js +8 -5
- package/dist/runtime/server/api/quickview/[slug].d.ts +2 -0
- package/dist/runtime/server/api/quickview/[slug].js +16 -0
- package/dist/runtime/server/api/samples.d.ts +3 -0
- package/dist/runtime/server/api/samples.js +20 -0
- package/dist/runtime/server/api/search.d.ts +3 -0
- package/dist/runtime/server/api/search.js +15 -0
- package/dist/runtime/server/api/service/[slug].js +5 -4
- package/dist/runtime/server/api/service/availability.js +1 -1
- package/dist/runtime/server/api/service/getall.d.ts +3 -0
- package/dist/runtime/server/api/service/getall.js +52 -0
- package/dist/runtime/server/api/shop.d.ts +3 -0
- package/dist/runtime/server/api/shop.js +15 -0
- package/dist/runtime/server/api/subscribe.js +1 -1
- package/dist/runtime/server/api/v2/[...slug].js +3 -1
- package/dist/runtime/server/api/webform.d.ts +3 -0
- package/dist/runtime/server/api/webform.js +16 -0
- package/dist/runtime/stores/Cart.d.ts +12 -0
- package/dist/runtime/stores/Cart.js +50 -16
- package/dist/runtime/stores/Checkout.d.ts +9 -15
- package/dist/runtime/stores/Checkout.js +19 -5
- 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 +5 -0
- package/dist/runtime/utils/htmlCache.js +60 -0
- package/dist/types.d.mts +6 -2
- package/package.json +32 -20
- 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/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/{blog/blog.d.ts → cmspost/all.d.ts} +0 -0
- /package/dist/runtime/server/api/page/{[slug].d.ts → [...slug].d.ts} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { defineStore } from "pinia";
|
|
2
|
+
import { flowrixApi } from "../middleware/flowrix.js";
|
|
3
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
4
|
export const useWishlistsStore = defineStore("wishlists", {
|
|
3
5
|
state: () => ({
|
|
4
6
|
wishlists: [],
|
|
@@ -7,11 +9,17 @@ export const useWishlistsStore = defineStore("wishlists", {
|
|
|
7
9
|
error: null
|
|
8
10
|
}),
|
|
9
11
|
actions: {
|
|
12
|
+
setLoading(loading) {
|
|
13
|
+
this.loading = loading;
|
|
14
|
+
},
|
|
15
|
+
setError(error) {
|
|
16
|
+
this.error = error;
|
|
17
|
+
},
|
|
10
18
|
setWishlists(wishlists) {
|
|
11
19
|
this.wishlists = wishlists;
|
|
12
20
|
},
|
|
13
21
|
addWishlist(wishlist) {
|
|
14
|
-
this.wishlists.
|
|
22
|
+
this.wishlists.push(wishlist);
|
|
15
23
|
},
|
|
16
24
|
updateWishlist(updatedWishlist) {
|
|
17
25
|
const index = this.wishlists.findIndex((w) => w.id === updatedWishlist.id);
|
|
@@ -19,8 +27,8 @@ export const useWishlistsStore = defineStore("wishlists", {
|
|
|
19
27
|
this.wishlists[index] = updatedWishlist;
|
|
20
28
|
}
|
|
21
29
|
},
|
|
22
|
-
removeWishlist(
|
|
23
|
-
this.wishlists = this.wishlists.filter((w) => w.id !==
|
|
30
|
+
removeWishlist(wishlistId) {
|
|
31
|
+
this.wishlists = this.wishlists.filter((w) => w.id !== wishlistId);
|
|
24
32
|
},
|
|
25
33
|
setWishlistProducts(listId, products) {
|
|
26
34
|
this.wishlistProducts[listId] = products;
|
|
@@ -29,21 +37,213 @@ export const useWishlistsStore = defineStore("wishlists", {
|
|
|
29
37
|
if (!this.wishlistProducts[listId]) {
|
|
30
38
|
this.wishlistProducts[listId] = [];
|
|
31
39
|
}
|
|
32
|
-
this.wishlistProducts[listId].
|
|
40
|
+
this.wishlistProducts[listId].push(product);
|
|
33
41
|
},
|
|
34
42
|
removeWishlistProduct(listId, productSlug) {
|
|
35
43
|
if (this.wishlistProducts[listId]) {
|
|
36
|
-
this.wishlistProducts[listId] = this.wishlistProducts[listId].filter(
|
|
44
|
+
this.wishlistProducts[listId] = this.wishlistProducts[listId].filter(
|
|
45
|
+
(product) => product.slug !== productSlug
|
|
46
|
+
// Changed from productSlug to slug
|
|
47
|
+
);
|
|
37
48
|
}
|
|
38
49
|
},
|
|
39
50
|
clearWishlistProducts(listId) {
|
|
40
51
|
delete this.wishlistProducts[listId];
|
|
41
52
|
},
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
// Fetch all wishlists - Added force param for cache bypass
|
|
54
|
+
async fetchWishlists(force = false) {
|
|
55
|
+
if (!force && this.wishlists.length > 0) {
|
|
56
|
+
return {
|
|
57
|
+
status: "Success",
|
|
58
|
+
data: this.wishlists,
|
|
59
|
+
message: null
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const config = useRuntimeConfig();
|
|
64
|
+
let rawCookies = "";
|
|
65
|
+
if (process.client) {
|
|
66
|
+
rawCookies = document.cookie || "";
|
|
67
|
+
}
|
|
68
|
+
const apiConfig = {
|
|
69
|
+
...config,
|
|
70
|
+
cookies: rawCookies
|
|
71
|
+
};
|
|
72
|
+
const apiUrl = "mystore/customer/wishlist";
|
|
73
|
+
const response = await flowrixApi.get(apiUrl, apiConfig, {});
|
|
74
|
+
if (response.status === "Success") {
|
|
75
|
+
this.wishlists = response.data || [];
|
|
76
|
+
return response;
|
|
77
|
+
} else {
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
return error.data;
|
|
82
|
+
}
|
|
44
83
|
},
|
|
45
|
-
|
|
46
|
-
|
|
84
|
+
// Fetch products for a specific wishlist
|
|
85
|
+
async fetchWishlistProducts(listId) {
|
|
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/wishlist/${listId}/products`;
|
|
97
|
+
const response = await flowrixApi.get(apiUrl, apiConfig, {});
|
|
98
|
+
if (response.status === "Success" && response.data) {
|
|
99
|
+
const products = response.data.products || [];
|
|
100
|
+
this.setWishlistProducts(listId, products);
|
|
101
|
+
return response;
|
|
102
|
+
} else {
|
|
103
|
+
return response;
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return error.data;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
// Create a new wishlist
|
|
110
|
+
async createWishlist(data) {
|
|
111
|
+
try {
|
|
112
|
+
const config = useRuntimeConfig();
|
|
113
|
+
let rawCookies = "";
|
|
114
|
+
if (process.client) {
|
|
115
|
+
rawCookies = document.cookie || "";
|
|
116
|
+
}
|
|
117
|
+
const apiConfig = {
|
|
118
|
+
...config,
|
|
119
|
+
cookies: rawCookies
|
|
120
|
+
};
|
|
121
|
+
const apiUrl = "mystore/customer/wishlist/add";
|
|
122
|
+
const response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
123
|
+
body: data
|
|
124
|
+
});
|
|
125
|
+
if (response.status === "Success") {
|
|
126
|
+
await this.fetchWishlists(true);
|
|
127
|
+
return response;
|
|
128
|
+
} else {
|
|
129
|
+
return response;
|
|
130
|
+
}
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return error.data;
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
// Add product to wishlist
|
|
136
|
+
async addToWishlist(listId, productSlug, data = {}) {
|
|
137
|
+
try {
|
|
138
|
+
const config = useRuntimeConfig();
|
|
139
|
+
let rawCookies = "";
|
|
140
|
+
if (process.client) {
|
|
141
|
+
rawCookies = document.cookie || "";
|
|
142
|
+
}
|
|
143
|
+
const apiConfig = {
|
|
144
|
+
...config,
|
|
145
|
+
cookies: rawCookies
|
|
146
|
+
};
|
|
147
|
+
const apiUrl = `mystore/customer/wishlist/${listId}/${productSlug}/add`;
|
|
148
|
+
const response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
149
|
+
body: data
|
|
150
|
+
});
|
|
151
|
+
if (response.status === "Success" && response.data) {
|
|
152
|
+
this.addWishlistProduct(listId, response.data);
|
|
153
|
+
return response;
|
|
154
|
+
} else {
|
|
155
|
+
return response;
|
|
156
|
+
}
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return error.data;
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
// Remove product from wishlist
|
|
162
|
+
async removeFromWishlist(listId, productSlug) {
|
|
163
|
+
try {
|
|
164
|
+
const config = useRuntimeConfig();
|
|
165
|
+
let rawCookies = "";
|
|
166
|
+
if (process.client) {
|
|
167
|
+
rawCookies = document.cookie || "";
|
|
168
|
+
}
|
|
169
|
+
const apiConfig = {
|
|
170
|
+
...config,
|
|
171
|
+
cookies: rawCookies
|
|
172
|
+
};
|
|
173
|
+
const apiUrl = `mystore/customer/wishlist/${listId}/item/delete`;
|
|
174
|
+
const response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
175
|
+
body: { ids: { productSlug } }
|
|
176
|
+
// Assuming API expects this format
|
|
177
|
+
});
|
|
178
|
+
if (response.status === "Success") {
|
|
179
|
+
this.removeWishlistProduct(listId, productSlug);
|
|
180
|
+
await this.fetchWishlistProducts(listId);
|
|
181
|
+
return response;
|
|
182
|
+
} else {
|
|
183
|
+
return response;
|
|
184
|
+
}
|
|
185
|
+
} catch (error) {
|
|
186
|
+
return error.data;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
// Update wishlist
|
|
190
|
+
async updateWishlist(id, data) {
|
|
191
|
+
try {
|
|
192
|
+
const config = useRuntimeConfig();
|
|
193
|
+
let rawCookies = "";
|
|
194
|
+
if (process.client) {
|
|
195
|
+
rawCookies = document.cookie || "";
|
|
196
|
+
}
|
|
197
|
+
const apiConfig = {
|
|
198
|
+
...config,
|
|
199
|
+
cookies: rawCookies
|
|
200
|
+
};
|
|
201
|
+
const apiUrl = `mystore/customer/wishlist/${id}/update`;
|
|
202
|
+
const response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
203
|
+
body: data
|
|
204
|
+
});
|
|
205
|
+
if (response.status === "Success" && response.data) {
|
|
206
|
+
this.updateWishlist(response.data);
|
|
207
|
+
return response;
|
|
208
|
+
} else {
|
|
209
|
+
return response;
|
|
210
|
+
}
|
|
211
|
+
} catch (error) {
|
|
212
|
+
return error.data;
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
// Delete wishlist
|
|
216
|
+
async deleteWishlist(id) {
|
|
217
|
+
try {
|
|
218
|
+
const config = useRuntimeConfig();
|
|
219
|
+
let rawCookies = "";
|
|
220
|
+
if (process.client) {
|
|
221
|
+
rawCookies = document.cookie || "";
|
|
222
|
+
}
|
|
223
|
+
const apiConfig = {
|
|
224
|
+
...config,
|
|
225
|
+
cookies: rawCookies
|
|
226
|
+
};
|
|
227
|
+
const apiUrl = `mystore/customer/wishlist/${id}/delete`;
|
|
228
|
+
const response = await flowrixApi.post(apiUrl, apiConfig, {
|
|
229
|
+
body: {}
|
|
230
|
+
});
|
|
231
|
+
if (response.status === "Success") {
|
|
232
|
+
this.removeWishlist(id);
|
|
233
|
+
this.clearWishlistProducts(id);
|
|
234
|
+
return response;
|
|
235
|
+
} else {
|
|
236
|
+
return response;
|
|
237
|
+
}
|
|
238
|
+
} catch (error) {
|
|
239
|
+
return error.data;
|
|
240
|
+
}
|
|
47
241
|
}
|
|
242
|
+
},
|
|
243
|
+
getters: {
|
|
244
|
+
getWishlists: (state) => state.wishlists,
|
|
245
|
+
getWishlistProducts: (state) => (listId) => state.wishlistProducts[listId] || [],
|
|
246
|
+
isLoading: (state) => state.loading,
|
|
247
|
+
getError: (state) => state.error
|
|
48
248
|
}
|
|
49
249
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "nuxt/app";
|
|
2
|
+
import { useCookie } from "nuxt/app";
|
|
1
3
|
import { useAuthStore } from "../stores/auth.js";
|
|
2
4
|
function getLocationHeaders() {
|
|
3
5
|
const headers = {};
|
|
@@ -32,26 +34,20 @@ function getLocationHeaders() {
|
|
|
32
34
|
}
|
|
33
35
|
return headers;
|
|
34
36
|
}
|
|
35
|
-
function getEnv(key) {
|
|
36
|
-
if (typeof useRuntimeConfig === "function") {
|
|
37
|
-
const config = useRuntimeConfig();
|
|
38
|
-
return config.public?.[key] || config[key];
|
|
39
|
-
}
|
|
40
|
-
return process.env[key];
|
|
41
|
-
}
|
|
42
37
|
export function useApi() {
|
|
43
38
|
const authStore = useAuthStore();
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
39
|
+
const config = useRuntimeConfig();
|
|
40
|
+
const FLOWRIX_API_KEY = config.public.FLOWRIX_API_KEY;
|
|
41
|
+
const FLOWRIX_API_SECRET = config.public.FLOWRIX_API_SECRET;
|
|
42
|
+
const FLOWRIX_API_ORIGIN = config.public.FLOWRIX_API_ORIGIN;
|
|
43
|
+
const FLOWRIX_API_BASE = config.public.FLOWRIX_API_BASE;
|
|
48
44
|
const baseURL = FLOWRIX_API_BASE || "";
|
|
49
45
|
async function request(method, url, data = null, options = {}, extraHeaders = {}) {
|
|
50
46
|
const locationHeaders = getLocationHeaders();
|
|
51
47
|
const headers = {
|
|
52
48
|
"Content-Type": "application/json",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
49
|
+
"x-public-key": FLOWRIX_API_KEY,
|
|
50
|
+
"x-api-secret": FLOWRIX_API_SECRET,
|
|
55
51
|
// Add location headers from cookies
|
|
56
52
|
...locationHeaders,
|
|
57
53
|
// Add extra headers
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function readCache(url: URL, customerType: number): Promise<string | null>;
|
|
2
|
+
export declare function writeCache(url: URL, html: string, customerType: number): Promise<void>;
|
|
3
|
+
export declare function clearCache(): Promise<void>;
|
|
4
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | undefined>>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { promises as fs } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { getRequestURL, defineEventHandler, getCookie } from "h3";
|
|
4
|
+
const cacheDir = join("/tmp", ".cache", "html");
|
|
5
|
+
async function ensureDir() {
|
|
6
|
+
await fs.mkdir(cacheDir, { recursive: true });
|
|
7
|
+
}
|
|
8
|
+
function getCacheFilePath(url, customerType) {
|
|
9
|
+
const { pathname, searchParams } = url;
|
|
10
|
+
const queryObj = {};
|
|
11
|
+
for (const [key, value] of searchParams.entries()) {
|
|
12
|
+
queryObj[key] = value;
|
|
13
|
+
}
|
|
14
|
+
const queryString = Object.keys(queryObj).length ? `_${JSON.stringify(queryObj)}` : "";
|
|
15
|
+
const cacheKey = `${pathname}${queryString}`;
|
|
16
|
+
const safeName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_") || "index";
|
|
17
|
+
return join(cacheDir, `${safeName}-__-${customerType}.html`);
|
|
18
|
+
}
|
|
19
|
+
export async function readCache(url, customerType) {
|
|
20
|
+
try {
|
|
21
|
+
const filePath = getCacheFilePath(url, customerType);
|
|
22
|
+
const html = await fs.readFile(filePath, "utf8");
|
|
23
|
+
return html;
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export async function writeCache(url, html, customerType) {
|
|
29
|
+
await ensureDir();
|
|
30
|
+
const filePath = getCacheFilePath(url, customerType);
|
|
31
|
+
await fs.writeFile(filePath, html, "utf8");
|
|
32
|
+
}
|
|
33
|
+
export async function clearCache() {
|
|
34
|
+
try {
|
|
35
|
+
await fs.rm(cacheDir, { recursive: true, force: true });
|
|
36
|
+
await ensureDir();
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export default defineEventHandler(async (event) => {
|
|
41
|
+
const url = getRequestURL(event);
|
|
42
|
+
const customerType = getCookie(event, "customertype") || "";
|
|
43
|
+
if (event.method !== "GET" || !event.headers.get("accept")?.includes("text/html")) return;
|
|
44
|
+
const cached = await readCache(url, customerType);
|
|
45
|
+
if (cached) {
|
|
46
|
+
event.node.res.setHeader("x-cache", "HIT");
|
|
47
|
+
return cached;
|
|
48
|
+
}
|
|
49
|
+
const originalEnd = event.node.res.end;
|
|
50
|
+
let chunks = [];
|
|
51
|
+
event.node.res.end = function(chunk) {
|
|
52
|
+
if (chunk) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
53
|
+
const html = Buffer.concat(chunks).toString("utf-8");
|
|
54
|
+
if (event.node.res.statusCode === 200 && html.includes("<!DOCTYPE html>")) {
|
|
55
|
+
writeCache(url, html, customerType);
|
|
56
|
+
}
|
|
57
|
+
return originalEnd.apply(this, arguments);
|
|
58
|
+
};
|
|
59
|
+
return;
|
|
60
|
+
});
|
package/dist/types.d.mts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
2
4
|
|
|
3
|
-
export
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { default } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowrix",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1-beta.81",
|
|
4
|
+
"description": "Plug-and-play Nuxt eCommerce cart powered by FLOWRiX. Subscription required.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/types.d.mts",
|
|
10
10
|
"import": "./dist/module.mjs"
|
|
11
|
+
},
|
|
12
|
+
"./composables": {
|
|
13
|
+
"types": "./dist/runtime/composables/index.d.ts",
|
|
14
|
+
"import": "./dist/runtime/composables/index.js"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"main": "./dist/module.mjs",
|
|
@@ -15,12 +19,14 @@
|
|
|
15
19
|
"*": {
|
|
16
20
|
".": [
|
|
17
21
|
"./dist/types.d.mts"
|
|
22
|
+
],
|
|
23
|
+
"composables": [
|
|
24
|
+
"./dist/runtime/composables/index.d.ts"
|
|
18
25
|
]
|
|
19
26
|
}
|
|
20
27
|
},
|
|
21
28
|
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
"runtime/stores"
|
|
29
|
+
"dist"
|
|
24
30
|
],
|
|
25
31
|
"scripts": {
|
|
26
32
|
"prepack": "nuxt-module-build build",
|
|
@@ -34,24 +40,30 @@
|
|
|
34
40
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
35
41
|
},
|
|
36
42
|
"dependencies": {
|
|
37
|
-
"@nuxt/
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"pinia": "
|
|
41
|
-
"
|
|
43
|
+
"@nuxt/image": "^1.11.0",
|
|
44
|
+
"@nuxt/kit": "4.2.0",
|
|
45
|
+
"@nuxtjs/seo": "^3.2.2",
|
|
46
|
+
"@pinia/nuxt": "0.7.0",
|
|
47
|
+
"@stripe/stripe-js": "8.2.0",
|
|
48
|
+
"@vueuse/nuxt": "^14.0.0",
|
|
49
|
+
"nuxt-gtag": "^4.1.0",
|
|
50
|
+
"nuxt-swiper": "^2.0.1",
|
|
51
|
+
"nuxt-toast": "^1.4.0",
|
|
52
|
+
"pinia": "2.3.1",
|
|
53
|
+
"pinia-plugin-persistedstate": "^3.2.3"
|
|
42
54
|
},
|
|
43
55
|
"devDependencies": {
|
|
44
|
-
"@nuxt/devtools": "
|
|
45
|
-
"@nuxt/eslint-config": "
|
|
56
|
+
"@nuxt/devtools": "2.6.5",
|
|
57
|
+
"@nuxt/eslint-config": "1.9.0",
|
|
46
58
|
"@nuxt/module-builder": "^1.0.2",
|
|
47
|
-
"@nuxt/schema": "
|
|
48
|
-
"@nuxt/test-utils": "
|
|
49
|
-
"@types/node": "
|
|
50
|
-
"changelogen": "
|
|
51
|
-
"eslint": "
|
|
52
|
-
"nuxt": "
|
|
53
|
-
"typescript": "
|
|
54
|
-
"vitest": "
|
|
55
|
-
"vue-tsc": "
|
|
59
|
+
"@nuxt/schema": "4.2.0",
|
|
60
|
+
"@nuxt/test-utils": "3.19.2",
|
|
61
|
+
"@types/node": "24.9.1",
|
|
62
|
+
"changelogen": "0.6.2",
|
|
63
|
+
"eslint": "9.38.0",
|
|
64
|
+
"nuxt": "4.2.0",
|
|
65
|
+
"typescript": "5.9.3",
|
|
66
|
+
"vitest": "3.2.4",
|
|
67
|
+
"vue-tsc": "3.1.1"
|
|
56
68
|
}
|
|
57
69
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type User } from '../stores/auth.js';
|
|
2
|
-
export interface AuthCredentials {
|
|
3
|
-
email: string;
|
|
4
|
-
password: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ChangePasswordData {
|
|
7
|
-
current_password: string;
|
|
8
|
-
password: string;
|
|
9
|
-
password_confirmation: string;
|
|
10
|
-
}
|
|
11
|
-
export interface AuthResponse {
|
|
12
|
-
status: string;
|
|
13
|
-
message: string | Record<string, string[]> | null;
|
|
14
|
-
data: {
|
|
15
|
-
access_token: string;
|
|
16
|
-
token_type: string;
|
|
17
|
-
expires_in: number | null;
|
|
18
|
-
user: User;
|
|
19
|
-
} | null;
|
|
20
|
-
}
|
|
21
|
-
export declare function useAuth(): {
|
|
22
|
-
login: (credentials: AuthCredentials) => Promise<AuthResponse>;
|
|
23
|
-
register: (data: AuthCredentials & {
|
|
24
|
-
name?: string;
|
|
25
|
-
}) => Promise<AuthResponse>;
|
|
26
|
-
verifyEmail: (email: string) => Promise<AuthResponse>;
|
|
27
|
-
verifyToken: (email: string, token: string) => Promise<AuthResponse>;
|
|
28
|
-
resetPassword: (token: string, password: string, password_confirmation: string) => Promise<AuthResponse>;
|
|
29
|
-
logout: () => Promise<void>;
|
|
30
|
-
fetchProfile: () => Promise<User | null>;
|
|
31
|
-
updateProfile: (userData: any) => Promise<{
|
|
32
|
-
status: string;
|
|
33
|
-
message: string;
|
|
34
|
-
}>;
|
|
35
|
-
changePassword: (passwordData: ChangePasswordData) => Promise<{
|
|
36
|
-
status: string;
|
|
37
|
-
message: string;
|
|
38
|
-
}>;
|
|
39
|
-
initializeAuth: () => void;
|
|
40
|
-
formatErrorMessage: (message: string | Record<string, string[]> | null) => string;
|
|
41
|
-
user: import("vue").ComputedRef<User | null>;
|
|
42
|
-
token: import("vue").ComputedRef<string | null>;
|
|
43
|
-
isAuthenticated: import("vue").ComputedRef<boolean>;
|
|
44
|
-
isHydrated: import("vue").ComputedRef<boolean>;
|
|
45
|
-
};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
import { useAuthStore } from "../stores/auth.js";
|
|
3
|
-
import { useApi } from "../utils/api.js";
|
|
4
|
-
export function useAuth() {
|
|
5
|
-
const authStore = useAuthStore();
|
|
6
|
-
const { post, get } = useApi();
|
|
7
|
-
function formatErrorMessage(message) {
|
|
8
|
-
if (!message) return "";
|
|
9
|
-
if (typeof message === "string") {
|
|
10
|
-
return message;
|
|
11
|
-
}
|
|
12
|
-
const errorMessages = [];
|
|
13
|
-
for (const [, errors] of Object.entries(message)) {
|
|
14
|
-
if (Array.isArray(errors)) {
|
|
15
|
-
errorMessages.push(...errors);
|
|
16
|
-
} else {
|
|
17
|
-
errorMessages.push(String(errors));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return errorMessages.join(", ");
|
|
21
|
-
}
|
|
22
|
-
async function login(credentials) {
|
|
23
|
-
try {
|
|
24
|
-
const response = await post("/login", credentials);
|
|
25
|
-
if (response.status === "Success" && response.data?.access_token && response.data?.user) {
|
|
26
|
-
authStore.setAuth({
|
|
27
|
-
user: response.data.user,
|
|
28
|
-
token: response.data.access_token
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return response;
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error("Login error:", error);
|
|
34
|
-
const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Login failed";
|
|
35
|
-
return {
|
|
36
|
-
status: "Error",
|
|
37
|
-
message,
|
|
38
|
-
data: null
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async function register(data) {
|
|
43
|
-
try {
|
|
44
|
-
const response = await post("/customer/create", data);
|
|
45
|
-
return response;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.error("Registration error:", error);
|
|
48
|
-
const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Registration failed";
|
|
49
|
-
return {
|
|
50
|
-
status: "Error",
|
|
51
|
-
message,
|
|
52
|
-
data: null
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async function verifyEmail(email) {
|
|
57
|
-
try {
|
|
58
|
-
const response = await post("/verify-email", { email });
|
|
59
|
-
return response;
|
|
60
|
-
} catch (error) {
|
|
61
|
-
console.error("Verify email error:", error);
|
|
62
|
-
const message = error.data ? formatErrorMessage(error.data.message) : error.message || "email verification failed";
|
|
63
|
-
return {
|
|
64
|
-
status: "Error",
|
|
65
|
-
message,
|
|
66
|
-
data: null
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async function verifyToken(email, token) {
|
|
71
|
-
try {
|
|
72
|
-
const response = await post("/verify-token", { email, token });
|
|
73
|
-
return response;
|
|
74
|
-
} catch (error) {
|
|
75
|
-
console.error("Verify token error:", error);
|
|
76
|
-
const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Token verification failed";
|
|
77
|
-
return {
|
|
78
|
-
status: "Error",
|
|
79
|
-
message,
|
|
80
|
-
data: null
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
async function resetPassword(token, password, password_confirmation) {
|
|
85
|
-
try {
|
|
86
|
-
const response = await post("/reset-password", {
|
|
87
|
-
token,
|
|
88
|
-
password,
|
|
89
|
-
password_confirmation
|
|
90
|
-
});
|
|
91
|
-
return response;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error("Reset password error:", error);
|
|
94
|
-
const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Password reset failed";
|
|
95
|
-
return {
|
|
96
|
-
status: "Error",
|
|
97
|
-
message,
|
|
98
|
-
data: null
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
async function logout() {
|
|
103
|
-
try {
|
|
104
|
-
await post("/customer/logout", {});
|
|
105
|
-
} catch (error) {
|
|
106
|
-
console.error("Logout API failed:", error);
|
|
107
|
-
} finally {
|
|
108
|
-
authStore.logout();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
async function fetchProfile() {
|
|
112
|
-
try {
|
|
113
|
-
const response = await get("/customer/profile");
|
|
114
|
-
if (response.status === "Success" && response.data) {
|
|
115
|
-
authStore.user = response.data;
|
|
116
|
-
if (import.meta.client) {
|
|
117
|
-
localStorage.setItem("auth_user", JSON.stringify(response.data));
|
|
118
|
-
}
|
|
119
|
-
return response.data;
|
|
120
|
-
}
|
|
121
|
-
return null;
|
|
122
|
-
} catch (error) {
|
|
123
|
-
console.error("Fetch profile failed:", error);
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
async function updateProfile(userData) {
|
|
128
|
-
try {
|
|
129
|
-
const response = await post("/customer/profile/update", userData);
|
|
130
|
-
if (response.status === "Success") {
|
|
131
|
-
await fetchProfile();
|
|
132
|
-
return { status: response.status, message: response.message || "Profile Updated Successfully" };
|
|
133
|
-
} else {
|
|
134
|
-
const errorMessage = formatErrorMessage(response.message);
|
|
135
|
-
throw new Error(errorMessage);
|
|
136
|
-
}
|
|
137
|
-
} catch (error) {
|
|
138
|
-
console.error("Update profile error:", error);
|
|
139
|
-
const errorMessage = error.data ? formatErrorMessage(error.data.message) : error.message || "Failed to update profile";
|
|
140
|
-
throw new Error(errorMessage);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
async function changePassword(passwordData) {
|
|
144
|
-
try {
|
|
145
|
-
const response = await post("/customer/change-password", passwordData);
|
|
146
|
-
if (response.status === "Success") {
|
|
147
|
-
return { status: "Success", message: "Password updated successfully" };
|
|
148
|
-
} else {
|
|
149
|
-
const errorMessage = formatErrorMessage(response.message);
|
|
150
|
-
throw new Error(errorMessage);
|
|
151
|
-
}
|
|
152
|
-
} catch (error) {
|
|
153
|
-
console.error("Change password error:", error);
|
|
154
|
-
const errorMessage = error.data ? formatErrorMessage(error.data.message) : error.message || "Failed to change password";
|
|
155
|
-
throw new Error(errorMessage);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
const initializeAuth = () => {
|
|
159
|
-
if (import.meta.client && !authStore.isHydrated) {
|
|
160
|
-
authStore.loadAuth();
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
return {
|
|
164
|
-
login,
|
|
165
|
-
register,
|
|
166
|
-
verifyEmail,
|
|
167
|
-
verifyToken,
|
|
168
|
-
resetPassword,
|
|
169
|
-
logout,
|
|
170
|
-
fetchProfile,
|
|
171
|
-
updateProfile,
|
|
172
|
-
changePassword,
|
|
173
|
-
initializeAuth,
|
|
174
|
-
formatErrorMessage,
|
|
175
|
-
user: computed(() => authStore.getUser),
|
|
176
|
-
token: computed(() => authStore.getToken),
|
|
177
|
-
isAuthenticated: computed(() => authStore.isLoggedIn),
|
|
178
|
-
isHydrated: computed(() => authStore.isHydrated)
|
|
179
|
-
};
|
|
180
|
-
}
|