flowrix 1.0.1-beta.14 → 1.0.1-beta.140

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 (276) hide show
  1. package/dist/module.d.mts +1 -6
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +175 -29
  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/plugin.js +14 -1
  106. package/dist/runtime/plugins/router.d.ts +2 -0
  107. package/dist/runtime/plugins/router.js +11 -0
  108. package/dist/runtime/server/api/albums.d.ts +1 -0
  109. package/dist/runtime/server/api/albums.js +35 -7
  110. package/dist/runtime/server/api/auth/forgot.js +1 -2
  111. package/dist/runtime/server/api/auth/login.d.ts +7 -0
  112. package/dist/runtime/server/api/auth/login.js +4 -16
  113. package/dist/runtime/server/api/auth/logout.js +1 -2
  114. package/dist/runtime/server/api/auth/register.js +1 -2
  115. package/dist/runtime/server/api/auth/session.get.js +1 -3
  116. package/dist/runtime/server/api/auth/user/reset-password.js +1 -2
  117. package/dist/runtime/server/api/auth/user/session.js +1 -2
  118. package/dist/runtime/server/api/auth/user/verify-token.js +1 -2
  119. package/dist/runtime/server/api/banners.js +20 -15
  120. package/dist/runtime/server/api/brand/[...slug].js +55 -0
  121. package/dist/runtime/server/api/brand/index.d.ts +3 -0
  122. package/dist/runtime/server/api/brand/index.js +46 -0
  123. package/dist/runtime/server/api/cache/[...slug].delete.d.ts +4 -1
  124. package/dist/runtime/server/api/cache/[...slug].delete.js +4 -7
  125. package/dist/runtime/server/api/cache/clean.get.d.ts +5 -0
  126. package/dist/runtime/server/api/cache/clean.get.js +4 -7
  127. package/dist/runtime/server/api/cart/[slug]/add.d.ts +1 -1
  128. package/dist/runtime/server/api/cart/[slug]/add.js +11 -11
  129. package/dist/runtime/server/api/cart/[slug]/update.d.ts +1 -1
  130. package/dist/runtime/server/api/cart/[slug]/update.js +11 -11
  131. package/dist/runtime/server/api/{v2/[...slug].d.ts → cart/related.d.ts} +0 -1
  132. package/dist/runtime/server/api/cart/related.js +21 -0
  133. package/dist/runtime/server/api/cart/remove.d.ts +1 -1
  134. package/dist/runtime/server/api/cart/remove.js +10 -10
  135. package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +1 -1
  136. package/dist/runtime/server/api/cart/service/[slug]/add.js +12 -12
  137. package/dist/runtime/server/api/catalog/brands.d.ts +3 -0
  138. package/dist/runtime/server/api/catalog/brands.js +52 -0
  139. package/dist/runtime/server/api/catalog/categories.js +28 -19
  140. package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
  141. package/dist/runtime/server/api/catalog/categoriesall.js +52 -0
  142. package/dist/runtime/server/api/catalog/featured.js +28 -17
  143. package/dist/runtime/server/api/catalog/posts.d.ts +3 -0
  144. package/dist/runtime/server/api/catalog/posts.js +52 -0
  145. package/dist/runtime/server/api/catalog/samples.js +28 -19
  146. package/dist/runtime/server/api/catalog/search.js +28 -19
  147. package/dist/runtime/server/api/category/[...slug].js +31 -20
  148. package/dist/runtime/server/api/check-404.d.ts +4 -0
  149. package/dist/runtime/server/api/check-404.js +8 -0
  150. package/dist/runtime/server/api/checkout/applyCoupon.d.ts +1 -1
  151. package/dist/runtime/server/api/checkout/applyCoupon.js +13 -13
  152. package/dist/runtime/server/api/checkout/configs.d.ts +1 -1
  153. package/dist/runtime/server/api/checkout/configs.js +11 -11
  154. package/dist/runtime/server/api/checkout/countries.d.ts +1 -1
  155. package/dist/runtime/server/api/checkout/countries.js +5 -9
  156. package/dist/runtime/server/api/checkout/paymentmethod.d.ts +1 -1
  157. package/dist/runtime/server/api/checkout/paymentmethod.js +16 -11
  158. package/dist/runtime/server/api/{blog/blog.d.ts → checkout/quotation/[slug].d.ts} +0 -1
  159. package/dist/runtime/server/api/checkout/quotation/[slug].js +20 -0
  160. package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +2 -0
  161. package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +35 -0
  162. package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +2 -0
  163. package/dist/runtime/server/api/checkout/quotation/guest/customer.js +20 -0
  164. package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +2 -0
  165. package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +22 -0
  166. package/dist/runtime/server/api/checkvariables.d.ts +3 -0
  167. package/dist/runtime/server/api/checkvariables.js +37 -0
  168. package/dist/runtime/server/api/cmspost/[...slug].js +54 -0
  169. package/dist/runtime/server/api/cmspost/all.d.ts +3 -0
  170. package/dist/runtime/server/api/cmspost/all.js +52 -0
  171. package/dist/runtime/server/api/company/profile.d.ts +1 -1
  172. package/dist/runtime/server/api/company/profile.js +12 -7
  173. package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +1 -1
  174. package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +50 -15
  175. package/dist/runtime/server/api/contact-center/webforms/create.d.ts +1 -1
  176. package/dist/runtime/server/api/contact-center/webforms/create.js +13 -9
  177. package/dist/runtime/server/api/countries.d.ts +2 -0
  178. package/dist/runtime/server/api/countries.js +44 -0
  179. package/dist/runtime/server/api/customer/address/add.js +1 -2
  180. package/dist/runtime/server/api/customer/address/delete.js +2 -3
  181. package/dist/runtime/server/api/customer/address/setshipping.js +1 -2
  182. package/dist/runtime/server/api/customer/address/update.js +1 -2
  183. package/dist/runtime/server/api/customer/cards/delete.js +2 -3
  184. package/dist/runtime/server/api/customer/cards/get.js +2 -3
  185. package/dist/runtime/server/api/customer/change-password.js +2 -3
  186. package/dist/runtime/server/api/customer/checkout.js +1 -2
  187. package/dist/runtime/server/api/customer/orders.js +2 -3
  188. package/dist/runtime/server/api/customer/profile/update.js +1 -2
  189. package/dist/runtime/server/api/customer/quotations.js +2 -3
  190. package/dist/runtime/server/api/customer/search.js +1 -2
  191. package/dist/runtime/server/api/customer/tax-invoice.js +1 -2
  192. package/dist/runtime/server/api/customer/wishlist/add.js +1 -2
  193. package/dist/runtime/server/api/customer/wishlist/createWishList.js +1 -2
  194. package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +1 -2
  195. package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +1 -2
  196. package/dist/runtime/server/api/customer/wishlist/get.js +2 -3
  197. package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +1 -2
  198. package/dist/runtime/server/api/customer/wishlist/updateWishList.js +2 -3
  199. package/dist/runtime/server/api/featured.d.ts +3 -0
  200. package/dist/runtime/server/api/featured.js +52 -0
  201. package/dist/runtime/server/api/generate/robots.get.d.ts +2 -0
  202. package/dist/runtime/server/api/generate/robots.get.js +20 -0
  203. package/dist/runtime/server/api/generate/sitemap.get.d.ts +2 -0
  204. package/dist/runtime/server/api/generate/sitemap.get.js +32 -0
  205. package/dist/runtime/server/api/location.d.ts +1 -1
  206. package/dist/runtime/server/api/location.js +24 -12
  207. package/dist/runtime/server/api/nav/[id]/links.d.ts +1 -0
  208. package/dist/runtime/server/api/nav/[id]/links.js +46 -10
  209. package/dist/runtime/server/api/page/[...slug].js +54 -0
  210. package/dist/runtime/server/api/product/[...slug].js +28 -13
  211. package/dist/runtime/server/api/quickview/[slug].d.ts +2 -0
  212. package/dist/runtime/server/api/quickview/[slug].js +21 -0
  213. package/dist/runtime/server/api/reviews.d.ts +2 -0
  214. package/dist/runtime/server/api/reviews.js +23 -0
  215. package/dist/runtime/server/api/samples.d.ts +3 -0
  216. package/dist/runtime/server/api/samples.js +53 -0
  217. package/dist/runtime/server/api/search.d.ts +3 -0
  218. package/dist/runtime/server/api/search.js +53 -0
  219. package/dist/runtime/server/api/service/[slug].js +22 -16
  220. package/dist/runtime/server/api/service/availability.d.ts +1 -1
  221. package/dist/runtime/server/api/service/availability.js +14 -12
  222. package/dist/runtime/server/api/service/getall.d.ts +3 -0
  223. package/dist/runtime/server/api/service/getall.js +57 -0
  224. package/dist/runtime/server/api/shop.d.ts +3 -0
  225. package/dist/runtime/server/api/shop.js +53 -0
  226. package/dist/runtime/server/api/subscribe.d.ts +1 -1
  227. package/dist/runtime/server/api/subscribe.js +23 -14
  228. package/dist/runtime/server/api/v2/[...slug].get.d.ts +2 -0
  229. package/dist/runtime/server/api/v2/[...slug].get.js +32 -0
  230. package/dist/runtime/server/api/webform.d.ts +3 -0
  231. package/dist/runtime/server/api/webform.js +54 -0
  232. package/dist/runtime/server/tsconfig.json +3 -3
  233. package/dist/runtime/stores/Cart.d.ts +12 -0
  234. package/dist/runtime/stores/Cart.js +62 -17
  235. package/dist/runtime/stores/Checkout.d.ts +9 -15
  236. package/dist/runtime/stores/Checkout.js +38 -45
  237. package/dist/runtime/stores/IpLocation.d.ts +95 -4
  238. package/dist/runtime/stores/IpLocation.js +93 -15
  239. package/dist/runtime/stores/Search.d.ts +1 -1
  240. package/dist/runtime/stores/Services.d.ts +5 -0
  241. package/dist/runtime/stores/Services.js +59 -8
  242. package/dist/runtime/stores/auth.d.ts +8 -11
  243. package/dist/runtime/stores/auth.js +385 -8
  244. package/dist/runtime/stores/countries.d.ts +1 -3
  245. package/dist/runtime/stores/countries.js +4 -8
  246. package/dist/runtime/stores/product/README.md +6 -6
  247. package/dist/runtime/stores/product/slug.d.ts +1 -17
  248. package/dist/runtime/stores/webforms.d.ts +24 -9
  249. package/dist/runtime/stores/webforms.js +105 -5
  250. package/dist/runtime/stores/wishlists.d.ts +125 -8
  251. package/dist/runtime/stores/wishlists.js +212 -20
  252. package/dist/runtime/utils/api.js +7 -13
  253. package/dist/runtime/utils/htmlCache.d.ts +2 -2
  254. package/dist/runtime/utils/htmlCache.js +23 -13
  255. package/dist/types.d.mts +6 -2
  256. package/package.json +16 -5
  257. package/dist/runtime/composables/Checkout/useBillingAddress.d.ts +0 -19
  258. package/dist/runtime/composables/Checkout/useBillingAddress.js +0 -82
  259. package/dist/runtime/composables/Checkout/useShippingAddress.d.ts +0 -9
  260. package/dist/runtime/composables/Checkout/useShippingAddress.js +0 -121
  261. package/dist/runtime/composables/useAuth.d.ts +0 -45
  262. package/dist/runtime/composables/useAuth.js +0 -180
  263. package/dist/runtime/composables/useCountries.d.ts +0 -12
  264. package/dist/runtime/composables/useCountries.js +0 -50
  265. package/dist/runtime/composables/useOrders.d.ts +0 -21
  266. package/dist/runtime/composables/useOrders.js +0 -82
  267. package/dist/runtime/composables/useQuotations.d.ts +0 -14
  268. package/dist/runtime/composables/useQuotations.js +0 -50
  269. package/dist/runtime/server/api/blog/[slug].js +0 -51
  270. package/dist/runtime/server/api/blog/blog.js +0 -17
  271. package/dist/runtime/server/api/brand/[slug].js +0 -58
  272. package/dist/runtime/server/api/page/[slug].js +0 -51
  273. package/dist/runtime/server/api/v2/[...slug].js +0 -9
  274. /package/dist/runtime/server/api/brand/{[slug].d.ts → [...slug].d.ts} +0 -0
  275. /package/dist/runtime/server/api/{blog/[slug].d.ts → cmspost/[...slug].d.ts} +0 -0
  276. /package/dist/runtime/server/api/page/{[slug].d.ts → [...slug].d.ts} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { useCartStore } from "./Cart.js";
2
2
  import { defineStore } from "pinia";
3
- import { useApi } from "../utils/api.js";
3
+ import { flowrixApi } from "../middleware/flowrix.js";
4
+ import { useRuntimeConfig } from "#imports";
4
5
  export const useCheckoutStore = defineStore("checkout", {
5
6
  state: () => ({
6
7
  publishableKey: {},
@@ -62,7 +63,6 @@ export const useCheckoutStore = defineStore("checkout", {
62
63
  },
63
64
  async getConfig() {
64
65
  try {
65
- const { post } = useApi();
66
66
  const formData = this.checkoutSession.fields || this.checkoutSession;
67
67
  if (formData.cart && Object.keys(formData.cart).length > 0) {
68
68
  const samples = Object.keys(formData.cart).filter(
@@ -78,10 +78,26 @@ export const useCheckoutStore = defineStore("checkout", {
78
78
  if (useCartStore().coupon?.length > 0) {
79
79
  formData.vouchercodes = useCartStore().coupon;
80
80
  }
81
- formData.cart = useCartStore().cart.items;
81
+ if (useCartStore().cart.items != void 0 && Object.keys(useCartStore().cart.items).length > 0) {
82
+ formData.cart = useCartStore().cart.items;
83
+ } else {
84
+ delete formData.cart;
85
+ }
82
86
  formData.abndToken = useCartStore().cart.abndToken;
83
87
  const apiUrl = `checkout/configs`;
84
- const response = await post(apiUrl, formData);
88
+ const config = useRuntimeConfig();
89
+ const rawCookies = document.cookie;
90
+ const apiConfig = {
91
+ ...config,
92
+ cookies: rawCookies
93
+ };
94
+ const response = await flowrixApi.post(
95
+ apiUrl,
96
+ apiConfig,
97
+ {
98
+ body: formData
99
+ }
100
+ );
85
101
  if (response?.data) {
86
102
  this.config = response.data;
87
103
  const shippingMethods = response.data.shippingmethods;
@@ -104,12 +120,14 @@ export const useCheckoutStore = defineStore("checkout", {
104
120
  deliverymethod: deliveryMethod.id
105
121
  };
106
122
  }
107
- const cart = {
123
+ let cart = {
108
124
  items: response.data.cart,
109
- totals: response.data.calculations
125
+ totals: response.data.calculations,
126
+ quote_items: response.data.quote_items || []
110
127
  };
111
128
  useCartStore().cart.items = cart.items;
112
129
  useCartStore().cart.totals = cart.totals;
130
+ useCartStore().cart.quote_items = cart.quote_items;
113
131
  this.config.totals = response.data.calculations;
114
132
  this.checkoutSession.calculations = response.data.calculations;
115
133
  }
@@ -120,11 +138,13 @@ export const useCheckoutStore = defineStore("checkout", {
120
138
  async submitCheckout() {
121
139
  try {
122
140
  this.loading = true;
123
- const { post } = useApi();
124
141
  const formData = this.checkoutSession.fields || {};
125
142
  const apiUrl = `customer/checkout`;
126
143
  formData.billing_address2 = formData.billing_address;
127
- const response = await post(apiUrl, formData);
144
+ delete formData.fields;
145
+ delete formData.calculations;
146
+ const config = useRuntimeConfig();
147
+ const response = await flowrixApi.post(apiUrl, config, { body: formData });
128
148
  if (response?.data?.order || response?.data?.order_no) {
129
149
  const orderData = response.data.order || response.data;
130
150
  const invoiceId = orderData.order_no;
@@ -148,28 +168,15 @@ export const useCheckoutStore = defineStore("checkout", {
148
168
  invoice: error?.data?.data?.order_no
149
169
  };
150
170
  this.loading = false;
151
- return error;
152
- }
153
- },
154
- async confirmPayment(checkoutId) {
155
- try {
156
- const apiUrl = `/api/checkout/success`;
157
- await $fetch(apiUrl, {
158
- method: "POST",
159
- body: { token: checkoutId }
160
- });
161
- } catch (error) {
162
- console.error("Error confirming payment:", error);
171
+ return error.data;
163
172
  }
164
173
  },
165
174
  async CheckUserAccount(email) {
166
175
  try {
167
176
  this.loading = true;
168
- const apiUrl = `/api/customer/search`;
169
- const response = await $fetch(apiUrl, {
170
- method: "POST",
171
- body: { email }
172
- });
177
+ const apiUrl = `customers/search`;
178
+ const config = useRuntimeConfig();
179
+ const response = await flowrixApi.post(apiUrl, config, { body: { email } });
173
180
  this.checkCustomer = response;
174
181
  this.loading = false;
175
182
  return response;
@@ -180,25 +187,6 @@ export const useCheckoutStore = defineStore("checkout", {
180
187
  }
181
188
  },
182
189
  async saveToCheckoutSession(fieldsData) {
183
- this.loading = true;
184
- fieldsData.firstname = fieldsData.billing_firstname ?? void 0;
185
- fieldsData.lastname = fieldsData.billing_lastname ?? void 0;
186
- fieldsData.mobile = fieldsData.billing_mobile ?? void 0;
187
- fieldsData.fullname = `${fieldsData.billing_firstname} ${fieldsData.billing_lastname}`;
188
- fieldsData.billing_fullname = `${fieldsData.billing_firstname} ${fieldsData.billing_lastname}`;
189
- fieldsData.shipping_fullname = `${fieldsData.billing_firstname} ${fieldsData.billing_lastname}`;
190
- if (fieldsData.shippingasbilling === true) {
191
- fieldsData.billing_address = fieldsData.shipping_address ?? void 0;
192
- fieldsData.billing_country = fieldsData.shipping_country ?? null;
193
- fieldsData.billing_state = fieldsData.shipping_state ?? void 0;
194
- fieldsData.billing_suburb = fieldsData.shipping_suburb ?? void 0;
195
- fieldsData.billing_firstname = fieldsData.shipping_firstname ?? void 0;
196
- fieldsData.billing_fullname = fieldsData.shipping_fullname ?? null;
197
- fieldsData.billing_lastname = fieldsData.shipping_lastname ?? void 0;
198
- fieldsData.billing_middlename = fieldsData.shipping_middlename ?? void 0;
199
- fieldsData.billing_mobile = fieldsData.shipping_mobile ?? void 0;
200
- fieldsData.billing_postcode = fieldsData.shipping_postcode ?? void 0;
201
- }
202
190
  this.checkoutSession.fields = {
203
191
  ...this.checkoutSession.fields,
204
192
  ...fieldsData
@@ -209,5 +197,10 @@ export const useCheckoutStore = defineStore("checkout", {
209
197
  }
210
198
  }
211
199
  },
212
- persist: true
200
+ persist: {
201
+ enabled: true,
202
+ // simple shape that works with most versions:
203
+ key: "checkoutSession",
204
+ storage: typeof window !== "undefined" ? localStorage : void 0
205
+ }
213
206
  });
@@ -1,4 +1,4 @@
1
- interface LocationData {
1
+ export interface LocationData {
2
2
  city?: string;
3
3
  country_name?: string;
4
4
  country_code?: string;
@@ -10,9 +10,100 @@ interface LocationData {
10
10
  region_id?: number;
11
11
  zip_code?: string;
12
12
  }
13
+ export interface LocationResponse {
14
+ status: string;
15
+ message?: string;
16
+ data: LocationData | null;
17
+ }
13
18
  export declare const useIpLocation: import("pinia").StoreDefinition<"IpLocation", {
14
19
  location: LocationData | null;
15
- }, {}, {
16
- getLocation(): Promise<void>;
20
+ loading: boolean;
21
+ error: string | null;
22
+ }, {
23
+ hasLocation: (state: {
24
+ location: {
25
+ city?: string | undefined;
26
+ country_name?: string | undefined;
27
+ country_code?: string | undefined;
28
+ country_id?: number | undefined;
29
+ ip?: string | undefined;
30
+ proxy?: boolean | undefined;
31
+ region?: string | undefined;
32
+ region_short?: string | undefined;
33
+ region_id?: number | undefined;
34
+ zip_code?: string | undefined;
35
+ } | null;
36
+ loading: boolean;
37
+ error: string | null;
38
+ } & import("pinia").PiniaCustomStateProperties<{
39
+ location: LocationData | null;
40
+ loading: boolean;
41
+ error: string | null;
42
+ }>) => boolean;
43
+ isLoading: (state: {
44
+ location: {
45
+ city?: string | undefined;
46
+ country_name?: string | undefined;
47
+ country_code?: string | undefined;
48
+ country_id?: number | undefined;
49
+ ip?: string | undefined;
50
+ proxy?: boolean | undefined;
51
+ region?: string | undefined;
52
+ region_short?: string | undefined;
53
+ region_id?: number | undefined;
54
+ zip_code?: string | undefined;
55
+ } | null;
56
+ loading: boolean;
57
+ error: string | null;
58
+ } & import("pinia").PiniaCustomStateProperties<{
59
+ location: LocationData | null;
60
+ loading: boolean;
61
+ error: string | null;
62
+ }>) => boolean;
63
+ locationString: (state: {
64
+ location: {
65
+ city?: string | undefined;
66
+ country_name?: string | undefined;
67
+ country_code?: string | undefined;
68
+ country_id?: number | undefined;
69
+ ip?: string | undefined;
70
+ proxy?: boolean | undefined;
71
+ region?: string | undefined;
72
+ region_short?: string | undefined;
73
+ region_id?: number | undefined;
74
+ zip_code?: string | undefined;
75
+ } | null;
76
+ loading: boolean;
77
+ error: string | null;
78
+ } & import("pinia").PiniaCustomStateProperties<{
79
+ location: LocationData | null;
80
+ loading: boolean;
81
+ error: string | null;
82
+ }>) => string;
83
+ fullAddress: (state: {
84
+ location: {
85
+ city?: string | undefined;
86
+ country_name?: string | undefined;
87
+ country_code?: string | undefined;
88
+ country_id?: number | undefined;
89
+ ip?: string | undefined;
90
+ proxy?: boolean | undefined;
91
+ region?: string | undefined;
92
+ region_short?: string | undefined;
93
+ region_id?: number | undefined;
94
+ zip_code?: string | undefined;
95
+ } | null;
96
+ loading: boolean;
97
+ error: string | null;
98
+ } & import("pinia").PiniaCustomStateProperties<{
99
+ location: LocationData | null;
100
+ loading: boolean;
101
+ error: string | null;
102
+ }>) => string;
103
+ }, {
104
+ getLocation(): Promise<LocationData | null>;
105
+ setLocation(locationData: LocationData): void;
106
+ updateLocation(partialData: Partial<LocationData>): void;
107
+ clearLocation(): void;
108
+ clearError(): void;
17
109
  }>;
18
- export {};
@@ -1,29 +1,107 @@
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 useIpLocation = defineStore("IpLocation", {
3
11
  state: () => ({
4
- location: null
12
+ location: null,
13
+ loading: false,
14
+ error: null
5
15
  }),
16
+ getters: {
17
+ hasLocation: (state) => state.location !== null,
18
+ isLoading: (state) => state.loading,
19
+ locationString: (state) => {
20
+ if (!state.location) return "";
21
+ const parts = [
22
+ state.location.city,
23
+ state.location.region_short || state.location.region,
24
+ state.location.zip_code
25
+ ].filter(Boolean);
26
+ return parts.join(", ");
27
+ },
28
+ fullAddress: (state) => {
29
+ if (!state.location) return "";
30
+ const parts = [
31
+ state.location.city,
32
+ state.location.region,
33
+ state.location.zip_code,
34
+ state.location.country_name
35
+ ].filter(Boolean);
36
+ return parts.join(", ");
37
+ }
38
+ },
6
39
  actions: {
7
40
  async getLocation() {
41
+ if (this.loading || this.location !== null) {
42
+ console.log("Location already loaded or loading:", this.location);
43
+ return this.location;
44
+ }
45
+ this.loading = true;
46
+ this.error = null;
8
47
  try {
9
- if (this.location == null) {
10
- const response = await $fetch(`/api/location`, {
11
- method: "POST",
12
- headers: {
13
- "Content-Type": "application/json"
14
- }
15
- });
16
- if (response.status == "Success" && response.data != null) {
17
- this.location = response.data;
18
- } else {
19
- this.location = null;
20
- }
48
+ const config = useRuntimeConfig();
49
+ let rawCookies = "";
50
+ if (process.client) {
51
+ rawCookies = document.cookie || "";
52
+ }
53
+ const apiConfig = {
54
+ ...config,
55
+ cookies: rawCookies
56
+ };
57
+ const apiUrl = "location";
58
+ const response = await flowrixApi.post(apiUrl, apiConfig);
59
+ if (response.status === "Success" && response.data !== null) {
60
+ this.location = response.data;
61
+ console.log("Location loaded:", this.location);
62
+ return response.data;
63
+ } else {
64
+ const errorMessage = response.message ? formatErrorMessage(response.message) : "Failed to fetch location";
65
+ this.error = errorMessage;
66
+ console.error("Failed to fetch location:", errorMessage);
67
+ this.location = null;
68
+ return null;
21
69
  }
22
70
  } catch (error) {
23
- console.error("Error fetching data:", error);
71
+ console.error("Error fetching location:", error);
72
+ this.error = error.message || "Unknown error occurred";
24
73
  this.location = null;
74
+ return null;
75
+ } finally {
76
+ this.loading = false;
77
+ }
78
+ },
79
+ setLocation(locationData) {
80
+ this.location = locationData;
81
+ this.error = null;
82
+ console.log("Location set manually:", this.location);
83
+ },
84
+ updateLocation(partialData) {
85
+ if (this.location) {
86
+ this.location = { ...this.location, ...partialData };
87
+ console.log("Location updated:", this.location);
88
+ } else {
89
+ console.warn("Cannot update location: no location data exists");
25
90
  }
91
+ },
92
+ clearLocation() {
93
+ this.location = null;
94
+ this.error = null;
95
+ this.loading = false;
96
+ console.log("Location cleared");
97
+ },
98
+ clearError() {
99
+ this.error = null;
26
100
  }
27
101
  },
28
- persist: true
102
+ persist: {
103
+ key: "IpLocation",
104
+ storage: typeof window !== "undefined" ? localStorage : void 0,
105
+ paths: ["location"]
106
+ }
29
107
  });
@@ -1,5 +1,5 @@
1
1
  export declare const useSearchStore: import("pinia").StoreDefinition<"SearchStore", {
2
2
  data: any[];
3
3
  }, {}, {
4
- fetchSearchData(query: string): Promise<any[]>;
4
+ fetchSearchData(query: string): Promise<any>;
5
5
  }>;
@@ -1,7 +1,12 @@
1
1
  export declare const useServiceStore: import("pinia").StoreDefinition<"ServiceStore", {
2
2
  services: never[];
3
+ currentService: any | null;
3
4
  availability: boolean;
5
+ loading: boolean;
6
+ error: string | null;
4
7
  }, {}, {
5
8
  getAllServices(): Promise<void>;
9
+ getServiceBySlug(slug: string, query?: {}): Promise<any>;
6
10
  checkAvailability(data: any): Promise<any>;
11
+ clearCurrentService(): void;
7
12
  }>;
@@ -1,16 +1,21 @@
1
1
  import { defineStore } from "pinia";
2
+ import { flowrixApi } from "../middleware/flowrix.js";
3
+ import { useRuntimeConfig } from "#imports";
2
4
  import { useCheckoutStore } from "./Checkout.js";
3
5
  export const useServiceStore = defineStore("ServiceStore", {
4
6
  state: () => ({
5
7
  services: [],
6
- availability: false
8
+ currentService: null,
9
+ availability: false,
10
+ loading: false,
11
+ error: null
7
12
  }),
8
13
  actions: {
9
14
  async getAllServices() {
10
15
  try {
11
- const apiUrl = `/api/services/getall`;
16
+ const apiUrl = `/api/service/getall`;
12
17
  const response = await $fetch(apiUrl, {
13
- method: "GET",
18
+ method: "POST",
14
19
  headers: {
15
20
  "Content-Type": "application/json"
16
21
  }
@@ -24,26 +29,72 @@ export const useServiceStore = defineStore("ServiceStore", {
24
29
  console.error("Error fetching data:", error);
25
30
  }
26
31
  },
27
- async checkAvailability(data) {
32
+ async getServiceBySlug(slug, query = {}) {
33
+ this.loading = true;
34
+ this.error = null;
28
35
  try {
29
- const apiUrl = `/api/services/availability`;
36
+ const apiUrl = `/api/service/${slug}`;
30
37
  const response = await $fetch(apiUrl, {
31
38
  method: "POST",
32
39
  headers: {
33
40
  "Content-Type": "application/json"
34
41
  },
42
+ query,
43
+ body: {}
44
+ });
45
+ if (response.status === "Success" && response.data) {
46
+ this.currentService = response.data;
47
+ return response.data;
48
+ } else if (response.success !== false && !response.status) {
49
+ this.currentService = response;
50
+ return response;
51
+ } else {
52
+ this.error = response.message || response.error || "Failed to fetch service";
53
+ return null;
54
+ }
55
+ } catch (error) {
56
+ console.error("Error fetching service by slug:", error);
57
+ this.error = error.message || "Failed to fetch service";
58
+ return null;
59
+ } finally {
60
+ this.loading = false;
61
+ }
62
+ },
63
+ async checkAvailability(data) {
64
+ this.loading = true;
65
+ this.error = null;
66
+ try {
67
+ const config = useRuntimeConfig();
68
+ let rawCookies = "";
69
+ if (process.client) {
70
+ rawCookies = document.cookie || "";
71
+ }
72
+ const apiConfig = {
73
+ ...config,
74
+ cookies: rawCookies
75
+ };
76
+ const apiUrl = "services/availability";
77
+ const response = await flowrixApi.post(apiUrl, apiConfig, {
35
78
  body: data
36
79
  });
37
- if (response.status == "Success") {
80
+ if (response.status === "Success") {
38
81
  this.availability = response.data.service;
39
82
  useCheckoutStore().saveToCheckoutSession(data);
40
83
  return response.data;
41
84
  } else {
42
- this.data = null;
85
+ this.error = response.message || "Failed to check availability";
86
+ return null;
43
87
  }
44
88
  } catch (error) {
45
- console.error("Error fetching data:", error);
89
+ console.error("Error checking availability:", error);
90
+ this.error = error.message || "Failed to check availability";
91
+ return null;
92
+ } finally {
93
+ this.loading = false;
46
94
  }
95
+ },
96
+ clearCurrentService() {
97
+ this.currentService = null;
47
98
  }
48
99
  }
49
100
  });
@@ -43,20 +43,17 @@ export interface User {
43
43
  export interface AuthState {
44
44
  user: User | null;
45
45
  token: string | null;
46
- isAuthenticated: boolean;
47
- _hydrated: boolean;
46
+ isAuthenticated: false;
47
+ _hydrated: false;
48
+ }
49
+ export interface AuthResponse {
50
+ status: string;
51
+ message: string;
52
+ data: any | null;
48
53
  }
49
54
  export declare const useAuthStore: import("pinia").StoreDefinition<"auth", AuthState, {
50
55
  getUser: (state: AuthState) => User | null;
51
56
  getToken: (state: AuthState) => string | null;
52
57
  isLoggedIn: (state: AuthState) => boolean;
53
58
  isHydrated: (state: AuthState) => boolean;
54
- }, {
55
- setAuth({ user, token }: {
56
- user: User;
57
- token: string;
58
- }): void;
59
- loadAuth(): void;
60
- logout(): void;
61
- setHydrated(): void;
62
- }>;
59
+ }, {}>;