flowrix 1.0.1-beta.14 → 1.0.1-beta.141

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.
Files changed (275) hide show
  1. package/dist/module.d.mts +1 -6
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +169 -30
  4. package/dist/runtime/composables/Blog/useBlogIndex.d.ts +2 -5
  5. package/dist/runtime/composables/Blog/useBlogSingle.js +2 -4
  6. package/dist/runtime/composables/Brand/brand.d.ts +1 -1
  7. package/dist/runtime/composables/Brand/brand.js +30 -2
  8. package/dist/runtime/composables/Cart/useCart.d.ts +40 -0
  9. package/dist/runtime/composables/Cart/useCart.js +10 -0
  10. package/dist/runtime/composables/Cart/useCartComponent.d.ts +1 -0
  11. package/dist/runtime/composables/Cart/useCartComponent.js +11 -0
  12. package/dist/runtime/composables/Cart/useCartDetail.d.ts +15 -5
  13. package/dist/runtime/composables/Cart/useCartDetail.js +3 -0
  14. package/dist/runtime/composables/Category/useCategoryIndex.d.ts +25 -32
  15. package/dist/runtime/composables/Category/useCategoryIndex.js +63 -44
  16. package/dist/runtime/composables/Checkout/PaymentMethods/useDirectDeposit.js +8 -0
  17. package/dist/runtime/composables/Checkout/PaymentMethods/useEway.js +16 -6
  18. package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.d.ts +40 -1
  19. package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.js +10 -2
  20. package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.d.ts +40 -1
  21. package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.js +10 -2
  22. package/dist/runtime/composables/Checkout/PaymentMethods/usePaymentMethods.js +3 -14
  23. package/dist/runtime/composables/Checkout/PaymentMethods/usePaypal.js +8 -0
  24. package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.d.ts +2 -2
  25. package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.js +8 -0
  26. package/dist/runtime/composables/Checkout/PaymentMethods/useZippay.js +8 -0
  27. package/dist/runtime/composables/Checkout/useCheckout.d.ts +85 -73
  28. package/dist/runtime/composables/Checkout/useCheckout.js +84 -53
  29. package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.d.ts +43 -0
  30. package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.js +84 -0
  31. package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.d.ts +55 -0
  32. package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.js +196 -0
  33. package/dist/runtime/composables/Checkout/useCreateAccount.d.ts +7 -7
  34. package/dist/runtime/composables/Checkout/useCreateAccount.js +3 -1
  35. package/dist/runtime/composables/Checkout/useDeliveryMethod.d.ts +2 -2
  36. package/dist/runtime/composables/Checkout/useDeliveryMethod.js +18 -11
  37. package/dist/runtime/composables/Customer/useBillingAddress.d.ts +112 -0
  38. package/dist/runtime/composables/Customer/useBillingAddress.js +93 -0
  39. package/dist/runtime/composables/Customer/useLogin.d.ts +9 -0
  40. package/dist/runtime/composables/Customer/useLogin.js +34 -0
  41. package/dist/runtime/composables/Customer/useOrders.d.ts +29 -0
  42. package/dist/runtime/composables/Customer/useOrders.js +56 -0
  43. package/dist/runtime/composables/Customer/usePasswordReset.d.ts +26 -0
  44. package/dist/runtime/composables/Customer/usePasswordReset.js +258 -0
  45. package/dist/runtime/composables/Customer/useProfile.d.ts +75 -0
  46. package/dist/runtime/composables/Customer/useProfile.js +106 -0
  47. package/dist/runtime/composables/Customer/useQuotations.d.ts +32 -0
  48. package/dist/runtime/composables/Customer/useQuotations.js +40 -0
  49. package/dist/runtime/composables/Customer/useRegister.d.ts +121 -13
  50. package/dist/runtime/composables/Customer/useRegister.js +310 -35
  51. package/dist/runtime/composables/Customer/useShippingAddress.d.ts +121 -0
  52. package/dist/runtime/composables/Customer/useShippingAddress.js +145 -0
  53. package/dist/runtime/composables/Customer/useUpdatePassword.d.ts +21 -0
  54. package/dist/runtime/composables/Customer/useUpdatePassword.js +130 -0
  55. package/dist/runtime/composables/Customer/useUserCards.d.ts +22 -0
  56. package/dist/runtime/composables/Customer/useUserCards.js +65 -0
  57. package/dist/runtime/composables/{useWishlists.d.ts → Customer/useWishlists.d.ts} +7 -20
  58. package/dist/runtime/composables/{useWishlists.js → Customer/useWishlists.js} +21 -30
  59. package/dist/runtime/composables/Extras/useCountry.d.ts +11 -6
  60. package/dist/runtime/composables/Extras/useCountry.js +5 -4
  61. package/dist/runtime/composables/Footer/useFooter.d.ts +4 -4
  62. package/dist/runtime/composables/Footer/useFooter.js +12 -8
  63. package/dist/runtime/composables/Header/useHeader.d.ts +6 -20
  64. package/dist/runtime/composables/Header/useHeader.js +3 -2
  65. package/dist/runtime/composables/Product/CustomProduct/useCustomeScript.js +4 -5
  66. package/dist/runtime/composables/Product/CustomProduct/useSteps.d.ts +1 -1
  67. package/dist/runtime/composables/Product/useProductComponent.js +110 -0
  68. package/dist/runtime/composables/Product/useProductSlug.d.ts +8 -1
  69. package/dist/runtime/composables/Product/useQuickView.d.ts +8 -0
  70. package/dist/runtime/composables/Product/useQuickView.js +27 -0
  71. package/dist/runtime/composables/Product/useService.d.ts +42 -15
  72. package/dist/runtime/composables/Product/useService.js +137 -48
  73. package/dist/runtime/composables/Samples/useSamples.d.ts +5 -6
  74. package/dist/runtime/composables/Samples/useSamples.js +19 -15
  75. package/dist/runtime/composables/SideBar/Filters/useFilters.d.ts +2 -2
  76. package/dist/runtime/composables/SideBar/Filters/useSorting.d.ts +2 -2
  77. package/dist/runtime/composables/index.d.ts +18 -12
  78. package/dist/runtime/composables/index.js +18 -12
  79. package/dist/runtime/composables/useAddresses.js +6 -6
  80. package/dist/runtime/composables/useApp.d.ts +1 -0
  81. package/dist/runtime/composables/useApp.js +88 -0
  82. package/dist/runtime/composables/useCards.js +2 -2
  83. package/dist/runtime/composables/useDataLayer.js +1 -1
  84. package/dist/runtime/composables/useDotDigital.d.ts +3 -0
  85. package/dist/runtime/composables/useDotDigital.js +122 -0
  86. package/dist/runtime/composables/useLocation.d.ts +61 -19
  87. package/dist/runtime/composables/useLocation.js +353 -25
  88. package/dist/runtime/composables/useMetaLayer.js +11 -11
  89. package/dist/runtime/composables/useQuotationCheckout.d.ts +78 -0
  90. package/dist/runtime/composables/useQuotationCheckout.js +137 -0
  91. package/dist/runtime/composables/useSubscriptions.d.ts +17 -10
  92. package/dist/runtime/composables/useSubscriptions.js +68 -33
  93. package/dist/runtime/composables/useTikTokDatalayer.js +7 -7
  94. package/dist/runtime/composables/useWebforms.d.ts +38 -9
  95. package/dist/runtime/composables/useWebforms.js +93 -60
  96. package/dist/runtime/middleware/flowrix.d.ts +5 -4
  97. package/dist/runtime/middleware/flowrix.js +40 -22
  98. package/dist/runtime/pages/404.d.vue.ts +3 -0
  99. package/dist/runtime/pages/404.vue +6 -0
  100. package/dist/runtime/pages/404.vue.d.ts +3 -0
  101. package/dist/runtime/pages/flowrix-default.d.vue.ts +3 -0
  102. package/dist/runtime/pages/flowrix-default.vue +42 -0
  103. package/dist/runtime/pages/flowrix-default.vue.d.ts +3 -0
  104. package/dist/runtime/plugin.d.ts +1 -1
  105. package/dist/runtime/plugins/router.d.ts +2 -0
  106. package/dist/runtime/plugins/router.js +11 -0
  107. package/dist/runtime/server/api/albums.d.ts +1 -0
  108. package/dist/runtime/server/api/albums.js +35 -7
  109. package/dist/runtime/server/api/auth/forgot.js +1 -2
  110. package/dist/runtime/server/api/auth/login.d.ts +7 -0
  111. package/dist/runtime/server/api/auth/login.js +4 -16
  112. package/dist/runtime/server/api/auth/logout.js +1 -2
  113. package/dist/runtime/server/api/auth/register.js +1 -2
  114. package/dist/runtime/server/api/auth/session.get.js +1 -3
  115. package/dist/runtime/server/api/auth/user/reset-password.js +1 -2
  116. package/dist/runtime/server/api/auth/user/session.js +1 -2
  117. package/dist/runtime/server/api/auth/user/verify-token.js +1 -2
  118. package/dist/runtime/server/api/banners.js +20 -15
  119. package/dist/runtime/server/api/brand/[...slug].js +55 -0
  120. package/dist/runtime/server/api/brand/index.d.ts +3 -0
  121. package/dist/runtime/server/api/brand/index.js +46 -0
  122. package/dist/runtime/server/api/cache/[...slug].delete.d.ts +4 -1
  123. package/dist/runtime/server/api/cache/[...slug].delete.js +4 -7
  124. package/dist/runtime/server/api/cache/clean.get.d.ts +5 -0
  125. package/dist/runtime/server/api/cache/clean.get.js +4 -7
  126. package/dist/runtime/server/api/cart/[slug]/add.d.ts +1 -1
  127. package/dist/runtime/server/api/cart/[slug]/add.js +11 -11
  128. package/dist/runtime/server/api/cart/[slug]/update.d.ts +1 -1
  129. package/dist/runtime/server/api/cart/[slug]/update.js +11 -11
  130. package/dist/runtime/server/api/{v2/[...slug].d.ts → cart/related.d.ts} +0 -1
  131. package/dist/runtime/server/api/cart/related.js +21 -0
  132. package/dist/runtime/server/api/cart/remove.d.ts +1 -1
  133. package/dist/runtime/server/api/cart/remove.js +10 -10
  134. package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +1 -1
  135. package/dist/runtime/server/api/cart/service/[slug]/add.js +12 -12
  136. package/dist/runtime/server/api/catalog/brands.d.ts +3 -0
  137. package/dist/runtime/server/api/catalog/brands.js +52 -0
  138. package/dist/runtime/server/api/catalog/categories.js +28 -19
  139. package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
  140. package/dist/runtime/server/api/catalog/categoriesall.js +52 -0
  141. package/dist/runtime/server/api/catalog/featured.js +28 -17
  142. package/dist/runtime/server/api/catalog/posts.d.ts +3 -0
  143. package/dist/runtime/server/api/catalog/posts.js +52 -0
  144. package/dist/runtime/server/api/catalog/samples.js +28 -19
  145. package/dist/runtime/server/api/catalog/search.js +28 -19
  146. package/dist/runtime/server/api/category/[...slug].js +31 -20
  147. package/dist/runtime/server/api/check-404.d.ts +4 -0
  148. package/dist/runtime/server/api/check-404.js +8 -0
  149. package/dist/runtime/server/api/checkout/applyCoupon.d.ts +1 -1
  150. package/dist/runtime/server/api/checkout/applyCoupon.js +13 -13
  151. package/dist/runtime/server/api/checkout/configs.d.ts +1 -1
  152. package/dist/runtime/server/api/checkout/configs.js +11 -11
  153. package/dist/runtime/server/api/checkout/countries.d.ts +1 -1
  154. package/dist/runtime/server/api/checkout/countries.js +5 -9
  155. package/dist/runtime/server/api/checkout/paymentmethod.d.ts +1 -1
  156. package/dist/runtime/server/api/checkout/paymentmethod.js +16 -11
  157. package/dist/runtime/server/api/{blog/blog.d.ts → checkout/quotation/[slug].d.ts} +0 -1
  158. package/dist/runtime/server/api/checkout/quotation/[slug].js +20 -0
  159. package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +2 -0
  160. package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +35 -0
  161. package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +2 -0
  162. package/dist/runtime/server/api/checkout/quotation/guest/customer.js +20 -0
  163. package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +2 -0
  164. package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +22 -0
  165. package/dist/runtime/server/api/checkvariables.d.ts +3 -0
  166. package/dist/runtime/server/api/checkvariables.js +37 -0
  167. package/dist/runtime/server/api/cmspost/[...slug].js +54 -0
  168. package/dist/runtime/server/api/cmspost/all.d.ts +3 -0
  169. package/dist/runtime/server/api/cmspost/all.js +52 -0
  170. package/dist/runtime/server/api/company/profile.d.ts +1 -1
  171. package/dist/runtime/server/api/company/profile.js +12 -7
  172. package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +1 -1
  173. package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +50 -15
  174. package/dist/runtime/server/api/contact-center/webforms/create.d.ts +1 -1
  175. package/dist/runtime/server/api/contact-center/webforms/create.js +13 -9
  176. package/dist/runtime/server/api/countries.d.ts +2 -0
  177. package/dist/runtime/server/api/countries.js +44 -0
  178. package/dist/runtime/server/api/customer/address/add.js +1 -2
  179. package/dist/runtime/server/api/customer/address/delete.js +2 -3
  180. package/dist/runtime/server/api/customer/address/setshipping.js +1 -2
  181. package/dist/runtime/server/api/customer/address/update.js +1 -2
  182. package/dist/runtime/server/api/customer/cards/delete.js +2 -3
  183. package/dist/runtime/server/api/customer/cards/get.js +2 -3
  184. package/dist/runtime/server/api/customer/change-password.js +2 -3
  185. package/dist/runtime/server/api/customer/checkout.js +1 -2
  186. package/dist/runtime/server/api/customer/orders.js +2 -3
  187. package/dist/runtime/server/api/customer/profile/update.js +1 -2
  188. package/dist/runtime/server/api/customer/quotations.js +2 -3
  189. package/dist/runtime/server/api/customer/search.js +1 -2
  190. package/dist/runtime/server/api/customer/tax-invoice.js +1 -2
  191. package/dist/runtime/server/api/customer/wishlist/add.js +1 -2
  192. package/dist/runtime/server/api/customer/wishlist/createWishList.js +1 -2
  193. package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +1 -2
  194. package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +1 -2
  195. package/dist/runtime/server/api/customer/wishlist/get.js +2 -3
  196. package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +1 -2
  197. package/dist/runtime/server/api/customer/wishlist/updateWishList.js +2 -3
  198. package/dist/runtime/server/api/featured.d.ts +3 -0
  199. package/dist/runtime/server/api/featured.js +52 -0
  200. package/dist/runtime/server/api/generate/robots.get.d.ts +2 -0
  201. package/dist/runtime/server/api/generate/robots.get.js +20 -0
  202. package/dist/runtime/server/api/generate/sitemap.get.d.ts +2 -0
  203. package/dist/runtime/server/api/generate/sitemap.get.js +32 -0
  204. package/dist/runtime/server/api/location.d.ts +1 -1
  205. package/dist/runtime/server/api/location.js +24 -12
  206. package/dist/runtime/server/api/nav/[id]/links.d.ts +1 -0
  207. package/dist/runtime/server/api/nav/[id]/links.js +46 -10
  208. package/dist/runtime/server/api/page/[...slug].js +54 -0
  209. package/dist/runtime/server/api/product/[...slug].js +28 -13
  210. package/dist/runtime/server/api/quickview/[slug].d.ts +2 -0
  211. package/dist/runtime/server/api/quickview/[slug].js +21 -0
  212. package/dist/runtime/server/api/reviews.d.ts +2 -0
  213. package/dist/runtime/server/api/reviews.js +23 -0
  214. package/dist/runtime/server/api/samples.d.ts +3 -0
  215. package/dist/runtime/server/api/samples.js +53 -0
  216. package/dist/runtime/server/api/search.d.ts +3 -0
  217. package/dist/runtime/server/api/search.js +53 -0
  218. package/dist/runtime/server/api/service/[slug].js +22 -16
  219. package/dist/runtime/server/api/service/availability.d.ts +1 -1
  220. package/dist/runtime/server/api/service/availability.js +14 -12
  221. package/dist/runtime/server/api/service/getall.d.ts +3 -0
  222. package/dist/runtime/server/api/service/getall.js +57 -0
  223. package/dist/runtime/server/api/shop.d.ts +3 -0
  224. package/dist/runtime/server/api/shop.js +53 -0
  225. package/dist/runtime/server/api/subscribe.d.ts +1 -1
  226. package/dist/runtime/server/api/subscribe.js +23 -14
  227. package/dist/runtime/server/api/v2/[...slug].get.d.ts +2 -0
  228. package/dist/runtime/server/api/v2/[...slug].get.js +32 -0
  229. package/dist/runtime/server/api/webform.d.ts +3 -0
  230. package/dist/runtime/server/api/webform.js +54 -0
  231. package/dist/runtime/server/tsconfig.json +3 -3
  232. package/dist/runtime/stores/Cart.d.ts +12 -0
  233. package/dist/runtime/stores/Cart.js +62 -17
  234. package/dist/runtime/stores/Checkout.d.ts +9 -15
  235. package/dist/runtime/stores/Checkout.js +38 -45
  236. package/dist/runtime/stores/IpLocation.d.ts +95 -4
  237. package/dist/runtime/stores/IpLocation.js +93 -15
  238. package/dist/runtime/stores/Search.d.ts +1 -1
  239. package/dist/runtime/stores/Services.d.ts +5 -0
  240. package/dist/runtime/stores/Services.js +59 -8
  241. package/dist/runtime/stores/auth.d.ts +8 -11
  242. package/dist/runtime/stores/auth.js +385 -8
  243. package/dist/runtime/stores/countries.d.ts +1 -3
  244. package/dist/runtime/stores/countries.js +4 -8
  245. package/dist/runtime/stores/product/README.md +6 -6
  246. package/dist/runtime/stores/product/slug.d.ts +1 -17
  247. package/dist/runtime/stores/webforms.d.ts +24 -9
  248. package/dist/runtime/stores/webforms.js +105 -5
  249. package/dist/runtime/stores/wishlists.d.ts +125 -8
  250. package/dist/runtime/stores/wishlists.js +212 -20
  251. package/dist/runtime/utils/api.js +7 -13
  252. package/dist/runtime/utils/htmlCache.d.ts +2 -2
  253. package/dist/runtime/utils/htmlCache.js +23 -13
  254. package/dist/types.d.mts +6 -2
  255. package/package.json +16 -5
  256. package/dist/runtime/composables/Checkout/useBillingAddress.d.ts +0 -19
  257. package/dist/runtime/composables/Checkout/useBillingAddress.js +0 -82
  258. package/dist/runtime/composables/Checkout/useShippingAddress.d.ts +0 -9
  259. package/dist/runtime/composables/Checkout/useShippingAddress.js +0 -121
  260. package/dist/runtime/composables/useAuth.d.ts +0 -45
  261. package/dist/runtime/composables/useAuth.js +0 -180
  262. package/dist/runtime/composables/useCountries.d.ts +0 -12
  263. package/dist/runtime/composables/useCountries.js +0 -50
  264. package/dist/runtime/composables/useOrders.d.ts +0 -21
  265. package/dist/runtime/composables/useOrders.js +0 -82
  266. package/dist/runtime/composables/useQuotations.d.ts +0 -14
  267. package/dist/runtime/composables/useQuotations.js +0 -50
  268. package/dist/runtime/server/api/blog/[slug].js +0 -51
  269. package/dist/runtime/server/api/blog/blog.js +0 -17
  270. package/dist/runtime/server/api/brand/[slug].js +0 -58
  271. package/dist/runtime/server/api/page/[slug].js +0 -51
  272. package/dist/runtime/server/api/v2/[...slug].js +0 -9
  273. /package/dist/runtime/server/api/brand/{[slug].d.ts → [...slug].d.ts} +0 -0
  274. /package/dist/runtime/server/api/{blog/[slug].d.ts → cmspost/[...slug].d.ts} +0 -0
  275. /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,376 @@ export const useAuthStore = defineStore("auth", {
7
15
  _hydrated: false
8
16
  }),
9
17
  actions: {
10
- setAuth({ user, token }) {
11
- this.user = user;
12
- this.token = token;
13
- this.isAuthenticated = true;
14
- if (process.client) {
15
- localStorage.setItem("auth_token", token);
16
- localStorage.setItem("auth_user", JSON.stringify(user));
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
+ console.error("Login error:", error);
50
+ return error.data || {
51
+ status: "Error",
52
+ message: "Login failed. Please try again."
53
+ };
54
+ }
55
+ },
56
+ async signUp(userFields) {
57
+ try {
58
+ this.user = null;
59
+ const apiUrl = "mystore/customer/create";
60
+ const config = useRuntimeConfig();
61
+ let rawCookies = "";
62
+ if (process.client) {
63
+ rawCookies = document.cookie || "";
64
+ }
65
+ const apiConfig = {
66
+ ...config,
67
+ cookies: rawCookies
68
+ };
69
+ const response = await flowrixApi.post(apiUrl, apiConfig, {
70
+ body: userFields
71
+ });
72
+ if (response.status == "Success") {
73
+ return response;
74
+ }
75
+ return response;
76
+ } catch (error) {
77
+ console.error("Signup error:", error);
78
+ return error.data || {
79
+ status: "Error",
80
+ message: "Registration failed. Please try again."
81
+ };
82
+ }
83
+ },
84
+ async fetchProfile() {
85
+ try {
86
+ const config = useRuntimeConfig();
87
+ let rawCookies = "";
88
+ if (process.client) {
89
+ rawCookies = document.cookie || "";
90
+ }
91
+ const apiConfig = {
92
+ ...config,
93
+ cookies: rawCookies
94
+ };
95
+ const apiUrl = "mystore/customer/profile";
96
+ const response = await flowrixApi.get(apiUrl, apiConfig);
97
+ if (response.status === "Success" && response.data) {
98
+ this.user = response.data;
99
+ return response.data;
100
+ }
101
+ return null;
102
+ } catch (error) {
103
+ console.error("Fetch profile failed:", error);
104
+ return null;
105
+ }
106
+ },
107
+ async updateProfile(userData) {
108
+ try {
109
+ const config = useRuntimeConfig();
110
+ let rawCookies = "";
111
+ if (process.client) {
112
+ rawCookies = document.cookie || "";
113
+ }
114
+ const apiConfig = {
115
+ ...config,
116
+ cookies: rawCookies
117
+ };
118
+ const apiUrl = "mystore/customer/profile/update";
119
+ const response = await flowrixApi.post(apiUrl, apiConfig, {
120
+ body: userData
121
+ });
122
+ if (response.status === "Success") {
123
+ await this.fetchProfile();
124
+ return { status: response.status, message: response.message || "Profile Updated Successfully" };
125
+ } else {
126
+ const errorMessage = response.message;
127
+ throw new Error(errorMessage);
128
+ }
129
+ } catch (error) {
130
+ return error.data;
131
+ }
132
+ },
133
+ async fetchUserCards() {
134
+ try {
135
+ const config = useRuntimeConfig();
136
+ let rawCookies = "";
137
+ if (process.client) {
138
+ rawCookies = document.cookie || "";
139
+ }
140
+ const apiConfig = {
141
+ ...config,
142
+ cookies: rawCookies
143
+ };
144
+ const apiUrl = "mystore/customer/cards";
145
+ const response = await flowrixApi.get(apiUrl, apiConfig);
146
+ if (response.status === "Success" && response.data) {
147
+ this.user = response.data;
148
+ return response.data;
149
+ }
150
+ return null;
151
+ } catch (error) {
152
+ console.error("Fetch user cards failed:", error);
153
+ return null;
154
+ }
155
+ },
156
+ async changePassword(userData) {
157
+ try {
158
+ const config = useRuntimeConfig();
159
+ let rawCookies = "";
160
+ if (process.client) {
161
+ rawCookies = document.cookie || "";
162
+ }
163
+ const apiConfig = {
164
+ ...config,
165
+ cookies: rawCookies
166
+ };
167
+ const apiUrl = "mystore/customer/change-password";
168
+ const response = await flowrixApi.post(apiUrl, apiConfig, {
169
+ body: userData
170
+ });
171
+ return response;
172
+ } catch (error) {
173
+ console.error("Change password error:", error);
174
+ return error.data || error;
175
+ }
176
+ },
177
+ async deleteCard(cardId) {
178
+ try {
179
+ const config = useRuntimeConfig();
180
+ let rawCookies = "";
181
+ if (process.client) {
182
+ rawCookies = document.cookie || "";
183
+ }
184
+ const apiConfig = {
185
+ ...config,
186
+ cookies: rawCookies
187
+ };
188
+ const apiUrl = `mystore/customer/cards/${cardId}`;
189
+ const response = await flowrixApi.delete(apiUrl, apiConfig);
190
+ if (response.status === "Success") {
191
+ return { status: response.status, message: response.message || "Card deleted Successfully" };
192
+ } else {
193
+ const errorMessage = response.message;
194
+ throw new Error(errorMessage);
195
+ }
196
+ } catch (error) {
197
+ return error.data;
198
+ }
199
+ },
200
+ async fetchOrders() {
201
+ try {
202
+ const config = useRuntimeConfig();
203
+ let rawCookies = "";
204
+ if (process.client) {
205
+ rawCookies = document.cookie || "";
206
+ }
207
+ const apiConfig = {
208
+ ...config,
209
+ cookies: rawCookies
210
+ };
211
+ const apiUrl = "mystore/customer/orders";
212
+ const response = await flowrixApi.get(apiUrl, apiConfig);
213
+ if (response.status === "Success" && response.data) {
214
+ return response.data;
215
+ }
216
+ return null;
217
+ } catch (error) {
218
+ console.error("Fetch Orders failed:", error);
219
+ return null;
220
+ }
221
+ },
222
+ async downloadInvoice(orderNo) {
223
+ try {
224
+ const config = useRuntimeConfig();
225
+ let rawCookies = "";
226
+ if (process.client) {
227
+ rawCookies = document.cookie || "";
228
+ }
229
+ const apiConfig = {
230
+ ...config,
231
+ cookies: rawCookies
232
+ };
233
+ const apiUrl = `mystore/customer/orders/${orderNo}/tax-invoice`;
234
+ const response = await flowrixApi.get(apiUrl, apiConfig);
235
+ const blob = new Blob([response], { type: "application/pdf" });
236
+ const url = window.URL.createObjectURL(blob);
237
+ const link = document.createElement("a");
238
+ link.href = url;
239
+ link.setAttribute("download", `tax-invoice-${orderNo}.pdf`);
240
+ document.body.appendChild(link);
241
+ link.click();
242
+ document.body.removeChild(link);
243
+ window.URL.revokeObjectURL(url);
244
+ return response;
245
+ } catch (err) {
246
+ console.error("Download invoice error:", err);
247
+ return err.data;
248
+ }
249
+ },
250
+ async fetchQuotations() {
251
+ try {
252
+ const config = useRuntimeConfig();
253
+ let rawCookies = "";
254
+ if (process.client) {
255
+ rawCookies = document.cookie || "";
256
+ }
257
+ const apiConfig = {
258
+ ...config,
259
+ cookies: rawCookies
260
+ };
261
+ const apiUrl = "mystore/customer/quotations";
262
+ const response = await flowrixApi.get(apiUrl, apiConfig);
263
+ if (response.status === "Success" && response.data) {
264
+ return response.data;
265
+ }
266
+ return null;
267
+ } catch (error) {
268
+ console.error("Fetch quotations failed:", error);
269
+ return null;
270
+ }
271
+ },
272
+ async setAddress(addressData, method = "add") {
273
+ try {
274
+ const config = useRuntimeConfig();
275
+ let rawCookies = "";
276
+ if (process.client) {
277
+ rawCookies = document.cookie || "";
278
+ }
279
+ const apiConfig = {
280
+ ...config,
281
+ cookies: rawCookies
282
+ };
283
+ let response = {};
284
+ if (method == "update") {
285
+ const apiUrl = `mystore/customer/address/${addressData.id}/update`;
286
+ response = await flowrixApi.patch(apiUrl, apiConfig, {
287
+ body: addressData
288
+ });
289
+ } else if (method == "delete") {
290
+ const apiUrl = `mystore/customer/address/${addressData.id}/delete`;
291
+ response = await flowrixApi.patch(apiUrl, apiConfig);
292
+ } else if (method == "setshipping") {
293
+ const apiUrl = `mystore/customer/address/${addressData.id}/setshipping`;
294
+ response = await flowrixApi.post(apiUrl, apiConfig);
295
+ } else {
296
+ const apiUrl = "mystore/customer/address/add";
297
+ response = await flowrixApi.post(apiUrl, apiConfig, {
298
+ body: addressData
299
+ });
300
+ }
301
+ if (response.status === "Success") {
302
+ await this.fetchProfile();
303
+ return response;
304
+ } else {
305
+ return response;
306
+ }
307
+ } catch (error) {
308
+ return error.data;
309
+ }
310
+ },
311
+ async verifyEmail(email) {
312
+ try {
313
+ const config = useRuntimeConfig();
314
+ let rawCookies = "";
315
+ if (process.client) {
316
+ rawCookies = document.cookie || "";
317
+ }
318
+ const apiConfig = {
319
+ ...config,
320
+ cookies: rawCookies
321
+ };
322
+ const response = await flowrixApi.post("verify-email", apiConfig, {
323
+ body: { email }
324
+ });
325
+ return response;
326
+ } catch (error) {
327
+ console.error("Verify email error:", error);
328
+ const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Email verification failed";
329
+ return {
330
+ status: "Error",
331
+ message,
332
+ data: null
333
+ };
334
+ }
335
+ },
336
+ async verifyToken(email, token) {
337
+ try {
338
+ const config = useRuntimeConfig();
339
+ let rawCookies = "";
340
+ if (process.client) {
341
+ rawCookies = document.cookie || "";
342
+ }
343
+ const apiConfig = {
344
+ ...config,
345
+ cookies: rawCookies
346
+ };
347
+ const response = await flowrixApi.post("verify-token", apiConfig, {
348
+ body: { email, token }
349
+ });
350
+ return response;
351
+ } catch (error) {
352
+ console.error("Verify token error:", error);
353
+ const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Token verification failed";
354
+ return {
355
+ status: "Error",
356
+ message,
357
+ data: null
358
+ };
359
+ }
360
+ },
361
+ async resetPassword(token, password, password_confirmation) {
362
+ try {
363
+ const config = useRuntimeConfig();
364
+ let rawCookies = "";
365
+ if (process.client) {
366
+ rawCookies = document.cookie || "";
367
+ }
368
+ const apiConfig = {
369
+ ...config,
370
+ cookies: rawCookies
371
+ };
372
+ const response = await flowrixApi.post("reset-password", apiConfig, {
373
+ body: {
374
+ token,
375
+ password,
376
+ password_confirmation
377
+ }
378
+ });
379
+ return response;
380
+ } catch (error) {
381
+ console.error("Reset password error:", error);
382
+ const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Password reset failed";
383
+ return {
384
+ status: "Error",
385
+ message,
386
+ data: null
387
+ };
17
388
  }
18
389
  },
19
390
  loadAuth() {
@@ -43,9 +414,10 @@ export const useAuthStore = defineStore("auth", {
43
414
  if (process.client) {
44
415
  localStorage.removeItem("auth_token");
45
416
  localStorage.removeItem("auth_user");
417
+ document.cookie = "authToken=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC; SameSite=None; Secure";
418
+ document.cookie = "customertype=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC; SameSite=None; Secure";
46
419
  }
47
420
  },
48
- // Mark as hydrated without loading
49
421
  setHydrated() {
50
422
  this._hydrated = true;
51
423
  }
@@ -55,5 +427,10 @@ export const useAuthStore = defineStore("auth", {
55
427
  getToken: (state) => state.token,
56
428
  isLoggedIn: (state) => state.isAuthenticated,
57
429
  isHydrated: (state) => state._hydrated
430
+ },
431
+ persist: {
432
+ enabled: true,
433
+ key: "user",
434
+ storage: typeof window !== "undefined" ? localStorage : void 0
58
435
  }
59
436
  });
@@ -4,7 +4,5 @@ export declare const useCountriesStore: import("pinia").StoreDefinition<"countri
4
4
  loading: boolean;
5
5
  error: string | null;
6
6
  }, {}, {
7
- setCountries(countries: Country[]): void;
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
- setCountries(countries) {
10
- this.countries = countries;
11
- },
12
- setLoading(loading) {
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
  });
@@ -89,22 +89,22 @@ await productStore.refreshProduct()
89
89
  const productStore = useProductSlugStore()
90
90
 
91
91
  // Check if product exists
92
- console.log(productStore.hasProduct)
92
+ // console.log(productStore.hasProduct)
93
93
 
94
94
  // Get product name safely
95
- console.log(productStore.productName)
95
+ // console.log(productStore.productName)
96
96
 
97
97
  // Check if product has discount
98
- console.log(productStore.hasDiscount)
98
+ // console.log(productStore.hasDiscount)
99
99
 
100
100
  // Check loading state
101
- console.log(productStore.isProductLoading)
101
+ // console.log(productStore.isProductLoading)
102
102
 
103
103
  // Get error message
104
- console.log(productStore.productError)
104
+ // console.log(productStore.productError)
105
105
 
106
106
  // Check if product is valid
107
- console.log(productStore.isValidProduct)
107
+ // console.log(productStore.isValidProduct)
108
108
  ```
109
109
 
110
110
  ## API Endpoint Format
@@ -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,18 +1,33 @@
1
- export interface WebForm {
1
+ export interface WebFormField {
2
2
  id: number;
3
+ name: string;
4
+ label: string;
5
+ type: string;
6
+ required: boolean;
7
+ options?: string[];
8
+ validation?: string;
9
+ placeholder?: string;
3
10
  }
4
- export interface WebFormData {
11
+ export interface WebForm {
5
12
  id: number;
13
+ title: string;
14
+ description?: string;
15
+ fields: WebFormField[];
16
+ success_message?: string;
17
+ }
18
+ export interface WebFormSubmission {
19
+ [key: string]: any;
6
20
  recaptcha: string;
7
21
  }
22
+ export interface WebFormResponse {
23
+ status: string;
24
+ message: string;
25
+ data: any | null;
26
+ }
8
27
  export declare const useWebformsStore: import("pinia").StoreDefinition<"webforms", {
9
28
  webform: WebForm | null;
10
- webFormReturn: any;
29
+ webFormReturn: WebFormResponse | null;
11
30
  loading: boolean;
12
31
  error: string | null;
13
- }, {}, {
14
- setWebform(webform: WebForm | null): void;
15
- setWebFormReturn(returnValue: any): void;
16
- setLoading(loading: boolean): void;
17
- setError(error: string | null): void;
18
- }>;
32
+ _hydrated: boolean;
33
+ }, {}, {}>;
@@ -1,23 +1,123 @@
1
1
  import { defineStore } from "pinia";
2
+ import { flowrixApi } from "../middleware/flowrix.js";
3
+ import { useRuntimeConfig } from "#imports";
4
+ function formatErrorMessage(message) {
5
+ if (typeof message === "string") {
6
+ return message;
7
+ }
8
+ if (Array.isArray(message)) {
9
+ return message.join(", ");
10
+ }
11
+ const errorMessages = [];
12
+ for (const [field, errors] of Object.entries(message)) {
13
+ if (Array.isArray(errors)) {
14
+ errorMessages.push(...errors);
15
+ } else {
16
+ errorMessages.push(String(errors));
17
+ }
18
+ }
19
+ return errorMessages.join(", ");
20
+ }
2
21
  export const useWebformsStore = defineStore("webforms", {
3
22
  state: () => ({
4
23
  webform: null,
5
24
  webFormReturn: null,
6
25
  loading: false,
7
- error: null
26
+ error: null,
27
+ _hydrated: false
8
28
  }),
9
29
  actions: {
30
+ async fetchWebform(id) {
31
+ try {
32
+ this.loading = true;
33
+ this.error = null;
34
+ const config = useRuntimeConfig();
35
+ let rawCookies = "";
36
+ if (process.client) {
37
+ rawCookies = document.cookie || "";
38
+ }
39
+ const apiConfig = {
40
+ ...config,
41
+ cookies: rawCookies
42
+ };
43
+ const apiUrl = `contact-center/webforms/${id}/details`;
44
+ const response = await flowrixApi.get(apiUrl, apiConfig);
45
+ if (response.status === "Success" && response.data) {
46
+ this.webform = response.data;
47
+ return response.data;
48
+ }
49
+ return null;
50
+ } catch (error) {
51
+ console.error("Fetch webform failed:", error);
52
+ this.error = error.data ? formatErrorMessage(error.data.message) : error.message || "Failed to fetch webform";
53
+ return null;
54
+ } finally {
55
+ this.loading = false;
56
+ }
57
+ },
58
+ async submitInquiry(formData) {
59
+ try {
60
+ this.loading = true;
61
+ this.error = null;
62
+ const config = useRuntimeConfig();
63
+ let rawCookies = "";
64
+ if (process.client) {
65
+ rawCookies = document.cookie || "";
66
+ }
67
+ const apiConfig = {
68
+ ...config,
69
+ cookies: rawCookies
70
+ };
71
+ const apiUrl = "contact-center/webforms/create";
72
+ const response = await flowrixApi.post(apiUrl, apiConfig, {
73
+ body: formData
74
+ });
75
+ if (response.status === "Success") {
76
+ this.webFormReturn = response;
77
+ return response;
78
+ } else {
79
+ const errorMessage = response.message || "Failed to submit inquiry";
80
+ throw new Error(errorMessage);
81
+ }
82
+ } catch (error) {
83
+ console.error("Submit inquiry error:", error);
84
+ const message = error.data ? formatErrorMessage(error.data.message) : error.message || "Submission failed";
85
+ this.error = message;
86
+ return {
87
+ status: "Error",
88
+ message,
89
+ data: null
90
+ };
91
+ } finally {
92
+ this.loading = false;
93
+ }
94
+ },
10
95
  setWebform(webform) {
11
96
  this.webform = webform;
12
97
  },
13
98
  setWebFormReturn(returnValue) {
14
99
  this.webFormReturn = returnValue;
15
100
  },
16
- setLoading(loading) {
17
- this.loading = loading;
101
+ clearError() {
102
+ this.error = null;
103
+ },
104
+ clearWebFormReturn() {
105
+ this.webFormReturn = null;
18
106
  },
19
- setError(error) {
20
- this.error = error;
107
+ setHydrated() {
108
+ this._hydrated = true;
21
109
  }
110
+ },
111
+ getters: {
112
+ getWebform: (state) => state.webform,
113
+ getWebFormReturn: (state) => state.webFormReturn,
114
+ getLoading: (state) => state.loading,
115
+ getError: (state) => state.error,
116
+ isHydrated: (state) => state._hydrated
117
+ },
118
+ persist: {
119
+ enabled: true,
120
+ key: "webforms",
121
+ storage: typeof window !== "undefined" ? localStorage : void 0
22
122
  }
23
123
  });