flowrix 1.0.1-beta.8 → 1.0.1-beta.80
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 +118 -11
- package/dist/runtime/composables/Customer/useRegister.js +236 -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} +5 -18
- package/dist/runtime/composables/{useWishlists.js → Customer/useWishlists.js} +19 -28
- 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 +105 -5
- package/dist/runtime/stores/wishlists.js +200 -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,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,6 +1,8 @@
|
|
|
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;
|
|
@@ -9,20 +11,118 @@ export interface WishlistProduct {
|
|
|
9
11
|
export interface WishlistProducts {
|
|
10
12
|
[listId: number]: WishlistProduct[];
|
|
11
13
|
}
|
|
14
|
+
export interface CreateWishlistData {
|
|
15
|
+
title: string;
|
|
16
|
+
default: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface UpdateWishlistData {
|
|
19
|
+
title: string;
|
|
20
|
+
default: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface AddToWishlistData {
|
|
23
|
+
}
|
|
24
|
+
export interface ApiResponse<T> {
|
|
25
|
+
status: string;
|
|
26
|
+
message: string | Record<string, string[]> | null;
|
|
27
|
+
data: T | null;
|
|
28
|
+
}
|
|
12
29
|
export declare const useWishlistsStore: import("pinia").StoreDefinition<"wishlists", {
|
|
13
30
|
wishlists: Wishlist[];
|
|
14
31
|
wishlistProducts: WishlistProducts;
|
|
15
32
|
loading: boolean;
|
|
16
33
|
error: string | null;
|
|
17
|
-
}, {
|
|
34
|
+
}, {
|
|
35
|
+
getWishlists: (state: {
|
|
36
|
+
wishlists: {
|
|
37
|
+
id: number;
|
|
38
|
+
title: string;
|
|
39
|
+
default: boolean;
|
|
40
|
+
created_at: string;
|
|
41
|
+
}[];
|
|
42
|
+
wishlistProducts: WishlistProducts;
|
|
43
|
+
loading: boolean;
|
|
44
|
+
error: string | null;
|
|
45
|
+
} & import("pinia").PiniaCustomStateProperties<{
|
|
46
|
+
wishlists: Wishlist[];
|
|
47
|
+
wishlistProducts: WishlistProducts;
|
|
48
|
+
loading: boolean;
|
|
49
|
+
error: string | null;
|
|
50
|
+
}>) => {
|
|
51
|
+
id: number;
|
|
52
|
+
title: string;
|
|
53
|
+
default: boolean;
|
|
54
|
+
created_at: string;
|
|
55
|
+
}[];
|
|
56
|
+
getWishlistProducts: (state: {
|
|
57
|
+
wishlists: {
|
|
58
|
+
id: number;
|
|
59
|
+
title: string;
|
|
60
|
+
default: boolean;
|
|
61
|
+
created_at: string;
|
|
62
|
+
}[];
|
|
63
|
+
wishlistProducts: WishlistProducts;
|
|
64
|
+
loading: boolean;
|
|
65
|
+
error: string | null;
|
|
66
|
+
} & import("pinia").PiniaCustomStateProperties<{
|
|
67
|
+
wishlists: Wishlist[];
|
|
68
|
+
wishlistProducts: WishlistProducts;
|
|
69
|
+
loading: boolean;
|
|
70
|
+
error: string | null;
|
|
71
|
+
}>) => (listId: number) => WishlistProduct[];
|
|
72
|
+
isLoading: (state: {
|
|
73
|
+
wishlists: {
|
|
74
|
+
id: number;
|
|
75
|
+
title: string;
|
|
76
|
+
default: boolean;
|
|
77
|
+
created_at: string;
|
|
78
|
+
}[];
|
|
79
|
+
wishlistProducts: WishlistProducts;
|
|
80
|
+
loading: boolean;
|
|
81
|
+
error: string | null;
|
|
82
|
+
} & import("pinia").PiniaCustomStateProperties<{
|
|
83
|
+
wishlists: Wishlist[];
|
|
84
|
+
wishlistProducts: WishlistProducts;
|
|
85
|
+
loading: boolean;
|
|
86
|
+
error: string | null;
|
|
87
|
+
}>) => boolean;
|
|
88
|
+
getError: (state: {
|
|
89
|
+
wishlists: {
|
|
90
|
+
id: number;
|
|
91
|
+
title: string;
|
|
92
|
+
default: boolean;
|
|
93
|
+
created_at: string;
|
|
94
|
+
}[];
|
|
95
|
+
wishlistProducts: WishlistProducts;
|
|
96
|
+
loading: boolean;
|
|
97
|
+
error: string | null;
|
|
98
|
+
} & import("pinia").PiniaCustomStateProperties<{
|
|
99
|
+
wishlists: Wishlist[];
|
|
100
|
+
wishlistProducts: WishlistProducts;
|
|
101
|
+
loading: boolean;
|
|
102
|
+
error: string | null;
|
|
103
|
+
}>) => string | null;
|
|
104
|
+
}, {
|
|
105
|
+
setLoading(loading: boolean): void;
|
|
106
|
+
setError(error: string | null): void;
|
|
18
107
|
setWishlists(wishlists: Wishlist[]): void;
|
|
19
108
|
addWishlist(wishlist: Wishlist): void;
|
|
20
109
|
updateWishlist(updatedWishlist: Wishlist): void;
|
|
21
|
-
|
|
110
|
+
updateWishlist(id: number, data: UpdateWishlistData): Promise<ApiResponse<Wishlist>>;
|
|
111
|
+
removeWishlist(wishlistId: number): void;
|
|
22
112
|
setWishlistProducts(listId: number, products: WishlistProduct[]): void;
|
|
23
113
|
addWishlistProduct(listId: number, product: WishlistProduct): void;
|
|
24
114
|
removeWishlistProduct(listId: number, productSlug: string): void;
|
|
25
115
|
clearWishlistProducts(listId: number): void;
|
|
26
|
-
|
|
27
|
-
|
|
116
|
+
fetchWishlists(): Promise<ApiResponse<Wishlist[]>>;
|
|
117
|
+
fetchWishlistProducts(listId: number): Promise<ApiResponse<{
|
|
118
|
+
id: number;
|
|
119
|
+
title: string;
|
|
120
|
+
default: boolean;
|
|
121
|
+
created_at: string;
|
|
122
|
+
products: WishlistProduct[];
|
|
123
|
+
}>>;
|
|
124
|
+
createWishlist(data: CreateWishlistData): Promise<ApiResponse<Wishlist>>;
|
|
125
|
+
addToWishlist(listId: number, productSlug: string, data?: AddToWishlistData): Promise<ApiResponse<WishlistProduct>>;
|
|
126
|
+
removeFromWishlist(listId: number, productSlug: string): Promise<ApiResponse<void>>;
|
|
127
|
+
deleteWishlist(id: number): Promise<ApiResponse<void>>;
|
|
28
128
|
}>;
|