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,32 +1,360 @@
1
- import { computed, readonly } from "vue";
2
- import { useCookie } from "#imports";
3
- export const useLocation = () => {
4
- const locationCookie = useCookie("location", {
5
- default: () => ({ country: "US" }),
6
- // Default country
7
- maxAge: 60 * 60 * 24 * 365,
8
- // 1 year
9
- sameSite: "lax"
1
+ import { ref, computed, watch, nextTick } from "vue";
2
+ import { useIpLocation } from "../stores/IpLocation.js";
3
+ import { useCountriesStore } from "../stores/countries.js";
4
+ import { useCompanyProfile } from "../stores/useCompanyProfile.js";
5
+ import { useCheckoutStore } from "../stores/Checkout.js";
6
+ export function useLocation() {
7
+ const locationStore = useIpLocation();
8
+ const countriesStore = useCountriesStore();
9
+ const companyProfileStore = useCompanyProfile();
10
+ const checkoutStore = useCheckoutStore();
11
+ const states = ref([]);
12
+ const manualLocationHeading = ref(null);
13
+ const locationInputs = ref({
14
+ country: "Australia",
15
+ country_id: 14,
16
+ zip_code: 3370,
17
+ region: "",
18
+ region_id: null
10
19
  });
11
- const location = computed(() => locationCookie.value);
12
- const updateLocation = (newLocation) => {
13
- locationCookie.value = {
14
- ...locationCookie.value,
15
- ...newLocation
20
+ const location = computed(() => locationStore.location);
21
+ const countries = computed(() => {
22
+ const storeCountries = countriesStore.countries;
23
+ if (Array.isArray(storeCountries)) {
24
+ return storeCountries;
25
+ } else if (storeCountries?.data && Array.isArray(storeCountries.data)) {
26
+ return storeCountries.data;
27
+ }
28
+ return [];
29
+ });
30
+ const loading = computed(() => locationStore.loading);
31
+ const profile = computed(() => companyProfileStore.profile);
32
+ const companyCountryId = computed(() => profile.value?.country_id || 14);
33
+ const stateShortCodes = {
34
+ "New South Wales": "NSW",
35
+ "Victoria": "VIC",
36
+ "Queensland": "QLD",
37
+ "South Australia": "SA",
38
+ "Western Australia": "WA",
39
+ "Tasmania": "TAS",
40
+ "Northern Territory": "NT",
41
+ "Australian Capital Territory": "ACT"
42
+ };
43
+ const getStateShort = (stateName) => {
44
+ return stateShortCodes[stateName] || stateName;
45
+ };
46
+ const getStates = (countryId) => {
47
+ if (!countries.value || countries.value.length === 0) {
48
+ console.warn("No countries available");
49
+ return [];
50
+ }
51
+ const activeCountry = countries.value.find(
52
+ (country) => country.id == countryId || country.name == countryId
53
+ );
54
+ if (activeCountry && activeCountry.states) {
55
+ states.value = activeCountry.states;
56
+ return activeCountry.states;
57
+ } else {
58
+ states.value = [];
59
+ console.warn("No states found for country:", countryId);
60
+ return [];
61
+ }
62
+ };
63
+ const changeStates = (selectedCountry) => {
64
+ const country = countries.value?.find(
65
+ (c) => c.name === selectedCountry || c.id === selectedCountry
66
+ );
67
+ if (country) {
68
+ states.value = country.states || [];
69
+ locationInputs.value.country_id = country.id;
70
+ locationInputs.value.region = "";
71
+ locationInputs.value.region_id = null;
72
+ if (window.locationcountry === country.name && window.locationstate) {
73
+ locationInputs.value.region = window.locationstate;
74
+ const state = country.states?.find((s) => s.name === window.locationstate);
75
+ if (state) {
76
+ locationInputs.value.region_id = state.id;
77
+ }
78
+ }
79
+ } else {
80
+ console.warn("Country not found:", selectedCountry);
81
+ }
82
+ };
83
+ const updateLocationData = async (data = {}) => {
84
+ try {
85
+ const currentLocation = location.value;
86
+ const updateData = {
87
+ region: data.region || currentLocation?.region || "",
88
+ region_id: data.region_id || currentLocation?.region_id || null,
89
+ zip_code: data.zip_code || currentLocation?.zip_code || "",
90
+ country: data.country || currentLocation?.country_name || "Australia",
91
+ country_id: data.country_id || currentLocation?.country_id || companyCountryId.value
92
+ };
93
+ const country = countries.value?.find(
94
+ (c) => c.name === updateData.country || c.id === updateData.country_id
95
+ );
96
+ if (!country) {
97
+ console.error("Country not found:", updateData.country);
98
+ return;
99
+ }
100
+ const state = country.states?.find(
101
+ (s) => s.name === updateData.region || s.id === updateData.region_id
102
+ );
103
+ if (!state) {
104
+ console.error("State not found:", updateData.region);
105
+ return;
106
+ }
107
+ const newLocation = {
108
+ zip_code: updateData.zip_code,
109
+ region: state.name,
110
+ region_short: getStateShort(state.name),
111
+ region_id: state.id,
112
+ country_name: country.name,
113
+ country_id: country.id
114
+ };
115
+ locationStore.location = newLocation;
116
+ checkoutStore.saveToCheckoutSession(newLocation, "changelocation");
117
+ } catch (error) {
118
+ console.error("Error updating location:", error);
119
+ }
120
+ };
121
+ const changeLocation = async (data) => {
122
+ if (data && Object.keys(data).length > 0) {
123
+ await updateLocationData(data);
124
+ }
125
+ };
126
+ const checkLocationPermission = async () => {
127
+ try {
128
+ const permissionStatus = await navigator.permissions.query({
129
+ name: "geolocation"
130
+ });
131
+ return permissionStatus.state;
132
+ } catch (error) {
133
+ console.error("Permission check failed:", error);
134
+ return "error";
135
+ }
136
+ };
137
+ const requestBrowserLocation = async () => {
138
+ return new Promise((resolve) => {
139
+ if (!navigator.geolocation) {
140
+ console.log("Geolocation not supported");
141
+ resolve(false);
142
+ return;
143
+ }
144
+ navigator.geolocation.getCurrentPosition(
145
+ async (position) => {
146
+ try {
147
+ await processGeolocation(position);
148
+ resolve(true);
149
+ } catch (error) {
150
+ console.error("Error processing geolocation:", error);
151
+ resolve(false);
152
+ }
153
+ },
154
+ (error) => {
155
+ console.log("Geolocation denied or failed:", error.message);
156
+ resolve(false);
157
+ },
158
+ {
159
+ timeout: 1e4,
160
+ maximumAge: 0
161
+ }
162
+ );
163
+ });
164
+ };
165
+ const getBrowserLocation = async () => {
166
+ const success = await requestBrowserLocation();
167
+ if (!success) {
168
+ throw new Error("Browser location unavailable");
169
+ }
170
+ };
171
+ const processGeolocation = async (position) => {
172
+ const lat = position.coords.latitude;
173
+ const lng = position.coords.longitude;
174
+ const apiKey = window.GeocodingAPI;
175
+ if (!apiKey) {
176
+ throw new Error("Geocoding API key not found");
177
+ }
178
+ try {
179
+ const response = await fetch(
180
+ `https://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${lng}&key=${apiKey}`
181
+ );
182
+ const data = await response.json();
183
+ if (data.status !== "OK") {
184
+ throw new Error("Geocoding failed");
185
+ }
186
+ const locationData = extractLocationData(data.results);
187
+ const country = countries.value?.find((c) => c.name === locationData.country);
188
+ if (country) {
189
+ const state = country.states?.find((s) => s.name === locationData.state);
190
+ locationStore.location = {
191
+ city: locationData.city,
192
+ country_name: country.name,
193
+ country_code: locationData.country_code,
194
+ country_id: country.id,
195
+ ip: "",
196
+ proxy: false,
197
+ region: locationData.state,
198
+ region_short: locationData.state_short,
199
+ region_id: state?.id,
200
+ zip_code: locationData.postal_code
201
+ };
202
+ }
203
+ } catch (error) {
204
+ console.error("Geocoding error:", error);
205
+ throw error;
206
+ }
207
+ };
208
+ const extractLocationData = (results) => {
209
+ const data = {
210
+ city: "N/A",
211
+ country: "N/A",
212
+ country_code: "N/A",
213
+ state: "N/A",
214
+ state_short: "N/A",
215
+ postal_code: "N/A"
16
216
  };
217
+ for (const result of results) {
218
+ for (const component of result.address_components) {
219
+ if (component.types.includes("administrative_area_level_2")) {
220
+ data.city = component.long_name;
221
+ }
222
+ if (component.types.includes("country")) {
223
+ data.country = component.long_name;
224
+ data.country_code = component.short_name;
225
+ }
226
+ if (component.types.includes("administrative_area_level_1")) {
227
+ data.state = component.long_name;
228
+ data.state_short = component.short_name;
229
+ }
230
+ if (component.types.includes("postal_code")) {
231
+ data.postal_code = component.long_name;
232
+ }
233
+ }
234
+ }
235
+ return data;
236
+ };
237
+ const initializeCountriesAndStates = async () => {
238
+ try {
239
+ if (!countries.value || countries.value.length === 0) {
240
+ await countriesStore.getCountries();
241
+ }
242
+ await nextTick();
243
+ if (countries.value && countries.value.length > 0) {
244
+ getStates(companyCountryId.value);
245
+ const defaultCountry = countries.value.find((c) => c.id === companyCountryId.value);
246
+ if (defaultCountry) {
247
+ locationInputs.value.country = defaultCountry.name;
248
+ locationInputs.value.country_id = defaultCountry.id;
249
+ }
250
+ }
251
+ } catch (error) {
252
+ console.error("Error initializing countries and states:", error);
253
+ }
254
+ };
255
+ const getLocation = async (skipBrowserRequest = true) => {
256
+ try {
257
+ await initializeCountriesAndStates();
258
+ if (location.value) {
259
+ initLocationInputs();
260
+ return;
261
+ }
262
+ if (profile.value) {
263
+ profile.value.iplocation = true;
264
+ }
265
+ if (profile.value?.iplocation && !location.value) {
266
+ await locationStore.getLocation();
267
+ }
268
+ if (location.value) {
269
+ initLocationInputs();
270
+ }
271
+ } catch (error) {
272
+ console.error("Error getting location:", error);
273
+ }
17
274
  };
18
- const updateCountry = (country, countryCode) => {
19
- updateLocation({ country, countryCode });
275
+ const checkCurrentLocation = () => {
276
+ if (location.value?.region) {
277
+ locationInputs.value.region = location.value.region;
278
+ locationInputs.value.region_id = location.value.region_id || null;
279
+ if (location.value.country_id) {
280
+ getStates(location.value.country_id);
281
+ }
282
+ }
20
283
  };
21
- const shippingCountry = computed(() => location.value.country);
22
- const resetLocation = () => {
23
- locationCookie.value = { country: "US" };
284
+ const initLocationInputs = () => {
285
+ if (location.value) {
286
+ locationInputs.value = {
287
+ country: location.value.country_name || "Australia",
288
+ country_id: location.value.country_id || companyCountryId.value,
289
+ zip_code: location.value.zip_code || 3370,
290
+ region: location.value.region || "",
291
+ region_id: location.value.region_id || null
292
+ };
293
+ if (location.value.country_id) {
294
+ getStates(location.value.country_id);
295
+ }
296
+ }
24
297
  };
298
+ const loadLocation = () => {
299
+ const stored = localStorage.getItem("IpLocation");
300
+ if (stored) {
301
+ try {
302
+ const parsed = JSON.parse(stored);
303
+ return parsed.location || null;
304
+ } catch (error) {
305
+ console.error("Invalid IpLocation data:", error);
306
+ return null;
307
+ }
308
+ }
309
+ return null;
310
+ };
311
+ const openLocationModal = () => {
312
+ const changeLocationBtn = document.querySelector(".change_location");
313
+ if (changeLocationBtn) {
314
+ changeLocationBtn.click();
315
+ }
316
+ };
317
+ watch(location, (newLocation) => {
318
+ if (newLocation) {
319
+ initLocationInputs();
320
+ }
321
+ });
322
+ watch(countries, (newCountries) => {
323
+ if (newCountries && newCountries.length > 0) {
324
+ getStates(companyCountryId.value);
325
+ if (locationInputs.value.country_id) {
326
+ const country = newCountries.find((c) => c.id === locationInputs.value.country_id);
327
+ if (country) {
328
+ locationInputs.value.country = country.name;
329
+ }
330
+ }
331
+ }
332
+ });
25
333
  return {
26
- location: readonly(location),
27
- shippingCountry: readonly(shippingCountry),
28
- updateLocation,
29
- updateCountry,
30
- resetLocation
334
+ // State
335
+ states,
336
+ manualLocationHeading,
337
+ locationInputs,
338
+ // Computed
339
+ location,
340
+ countries,
341
+ loading,
342
+ companyCountryId,
343
+ // Methods
344
+ getStateShort,
345
+ getStates,
346
+ changeStates,
347
+ changeLocation,
348
+ updateLocationData,
349
+ getLocation,
350
+ checkCurrentLocation,
351
+ initLocationInputs,
352
+ loadLocation,
353
+ checkLocationPermission,
354
+ initializeCountriesAndStates,
355
+ requestBrowserLocation,
356
+ // NEW
357
+ openLocationModal
358
+ // NEW
31
359
  };
32
- };
360
+ }
@@ -11,7 +11,7 @@ export function META_page_view(to) {
11
11
  fbq("trackCustom", "virtualPageView", {
12
12
  content_type: "virtualPageView",
13
13
  content_name: to.meta?.head?.meta_title,
14
- currency: useCompanyProfile().profile?.currencyCode
14
+ currency: useCompanyProfile().profile?.data?.currencyCode
15
15
  });
16
16
  }
17
17
  }
@@ -25,7 +25,7 @@ export function META_view_item(product, price = 0, rp = 0) {
25
25
  content_name: product.name,
26
26
  discount,
27
27
  value: price,
28
- currency: useCompanyProfile().profile?.currencyCode
28
+ currency: useCompanyProfile().profile?.data?.currencyCode
29
29
  });
30
30
  }
31
31
  }
@@ -58,7 +58,7 @@ export function META_view_item_list(listItems = []) {
58
58
  contents: ecomarceItems,
59
59
  content_type: "Items List",
60
60
  value: 0,
61
- currency: useCompanyProfile().profile?.currencyCode || "GBP"
61
+ currency: useCompanyProfile().profile?.data?.currencyCode || "GBP"
62
62
  });
63
63
  }
64
64
  } catch (err) {
@@ -75,7 +75,7 @@ export function META_add_to_cart(lastitem = null) {
75
75
  content_name: lastitem.name,
76
76
  discount,
77
77
  value: lastitem.pricefloat,
78
- currency: useCompanyProfile().profile?.currencyCode
78
+ currency: useCompanyProfile().profile?.data?.currencyCode
79
79
  });
80
80
  }
81
81
  }
@@ -102,7 +102,7 @@ export function META_remove_from_cart(lastitem = null) {
102
102
  contents: ecomarceCartItems,
103
103
  content_type: "Items List",
104
104
  value: lastitem?.pricefloat,
105
- currency: useCompanyProfile().profile?.currencyCode
105
+ currency: useCompanyProfile().profile?.data?.currencyCode
106
106
  });
107
107
  }
108
108
  }
@@ -132,7 +132,7 @@ export function META_view_cart(cart = null) {
132
132
  contents: ecomarceCartItems,
133
133
  content_type: "View Cart",
134
134
  value: cart.totals.total,
135
- currency: useCompanyProfile().profile?.currencyCode
135
+ currency: useCompanyProfile().profile?.data?.currencyCode
136
136
  });
137
137
  }
138
138
  }
@@ -161,7 +161,7 @@ export function META_begin_checkout(cart = null) {
161
161
  contents: ecomarceCartItems,
162
162
  content_type: "Checkout",
163
163
  value: cart.totals.total,
164
- currency: useCompanyProfile().profile?.currencyCode
164
+ currency: useCompanyProfile().profile?.data?.currencyCode
165
165
  });
166
166
  }
167
167
  }
@@ -192,9 +192,9 @@ export function META_add_shipping_info(cart = null, shipping_tier = null) {
192
192
  });
193
193
  fbq("trackCustom", "add_shipping_info", {
194
194
  contents: ecomarceCartItems,
195
- content_type: shipping_tier?.title || "Shipping",
195
+ content_type: shipping_tier?.name || "Shipping",
196
196
  value: cart.totals.total,
197
- currency: useCompanyProfile().profile?.currencyCode
197
+ currency: useCompanyProfile().profile?.data?.currencyCode
198
198
  });
199
199
  }
200
200
  }
@@ -223,7 +223,7 @@ export function META_add_payment_info(cart = null, payment_type = "") {
223
223
  contents: ecomarceCartItems,
224
224
  content_type: payment_type || "Payment",
225
225
  value: cart.totals.total,
226
- currency: useCompanyProfile().profile?.currencyCode
226
+ currency: useCompanyProfile().profile?.data?.currencyCode
227
227
  });
228
228
  }
229
229
  }
@@ -257,7 +257,7 @@ export function META_purchase(orderData = null, cart = null) {
257
257
  tax: orderData.tax,
258
258
  shipping: orderData.shipping,
259
259
  coupon: orderData.vouchercode,
260
- currency: useCompanyProfile().profile?.currencyCode
260
+ currency: useCompanyProfile().profile?.data?.currencyCode
261
261
  });
262
262
  }
263
263
  }
@@ -0,0 +1,78 @@
1
+ export declare const useQuotationCheckout: () => {
2
+ inputData: import("vue").Ref<{
3
+ paymentmethod: string;
4
+ customertoken: string;
5
+ authoritytoleave: undefined;
6
+ register: string;
7
+ password: string;
8
+ password_confirmation: string;
9
+ passwordStrengthValue: string;
10
+ customernotes: string;
11
+ ewayKey: string;
12
+ eway_cardname: string;
13
+ eway_cardnumber: string;
14
+ eway_expirymonth: string;
15
+ eway_expiryyear: string;
16
+ eway_cvn: string;
17
+ till_cardname: string;
18
+ till_cardnumber: string;
19
+ till_cvn: string;
20
+ till_expirymonth: string;
21
+ till_expiryyear: string;
22
+ save_card_details: number;
23
+ }, {
24
+ paymentmethod: string;
25
+ customertoken: string;
26
+ authoritytoleave: undefined;
27
+ register: string;
28
+ password: string;
29
+ password_confirmation: string;
30
+ passwordStrengthValue: string;
31
+ customernotes: string;
32
+ ewayKey: string;
33
+ eway_cardname: string;
34
+ eway_cardnumber: string;
35
+ eway_expirymonth: string;
36
+ eway_expiryyear: string;
37
+ eway_cvn: string;
38
+ till_cardname: string;
39
+ till_cardnumber: string;
40
+ till_cvn: string;
41
+ till_expirymonth: string;
42
+ till_expiryyear: string;
43
+ save_card_details: number;
44
+ } | {
45
+ paymentmethod: string;
46
+ customertoken: string;
47
+ authoritytoleave: undefined;
48
+ register: string;
49
+ password: string;
50
+ password_confirmation: string;
51
+ passwordStrengthValue: string;
52
+ customernotes: string;
53
+ ewayKey: string;
54
+ eway_cardname: string;
55
+ eway_cardnumber: string;
56
+ eway_expirymonth: string;
57
+ eway_expiryyear: string;
58
+ eway_cvn: string;
59
+ till_cardname: string;
60
+ till_cardnumber: string;
61
+ till_cvn: string;
62
+ till_expirymonth: string;
63
+ till_expiryyear: string;
64
+ save_card_details: number;
65
+ }>;
66
+ publishableKey: import("vue").Ref<any, any>;
67
+ responseData: import("vue").Ref<any, any>;
68
+ QuotationData: import("vue").Ref<any, any>;
69
+ checkoutSession: import("vue").Ref<any, any>;
70
+ preference: import("vue").Ref<any, any>;
71
+ errorResponseData: import("vue").Ref<any, any>;
72
+ resetState: () => void;
73
+ getQuotation: (slug: string) => Promise<any>;
74
+ getGuestQuotation: (slug: string, query?: any) => Promise<any>;
75
+ GuestCheckoutQuotation: (slug: string, quotationData: any, query?: any) => Promise<any>;
76
+ paymentMethods: (formData: any) => Promise<any>;
77
+ submitCheckout: (slug: string, quotationData: any) => Promise<unknown>;
78
+ };
@@ -0,0 +1,137 @@
1
+ import { ref } from "vue";
2
+ export const useQuotationCheckout = () => {
3
+ const publishableKey = ref({});
4
+ const responseData = ref([]);
5
+ const QuotationData = ref([]);
6
+ const checkoutSession = ref([]);
7
+ const preference = ref({ data: { fields: {} } });
8
+ const errorResponseData = ref([]);
9
+ const inputData = ref({
10
+ paymentmethod: "",
11
+ customertoken: "",
12
+ authoritytoleave: void 0,
13
+ register: "",
14
+ password: "",
15
+ password_confirmation: "",
16
+ passwordStrengthValue: "",
17
+ customernotes: "",
18
+ ewayKey: "",
19
+ eway_cardname: "",
20
+ eway_cardnumber: "",
21
+ eway_expirymonth: "",
22
+ eway_expiryyear: "",
23
+ eway_cvn: "",
24
+ till_cardname: "",
25
+ till_cardnumber: "",
26
+ till_cvn: "",
27
+ till_expirymonth: "",
28
+ till_expiryyear: "",
29
+ save_card_details: 0
30
+ });
31
+ const resetState = () => {
32
+ publishableKey.value = {};
33
+ responseData.value = [];
34
+ checkoutSession.value = [];
35
+ preference.value = [];
36
+ errorResponseData.value = [];
37
+ };
38
+ const getQuotation = async (slug) => {
39
+ try {
40
+ const response = await $fetch(`/api/checkout/quotation/${slug}`, {
41
+ method: "GET"
42
+ });
43
+ if (response) {
44
+ publishableKey.value = response.data;
45
+ QuotationData.value = response;
46
+ }
47
+ return response;
48
+ } catch (error) {
49
+ errorResponseData.value = error.data || error;
50
+ throw error;
51
+ }
52
+ };
53
+ const getGuestQuotation = async (slug, query) => {
54
+ try {
55
+ const response = await $fetch(`/api/checkout/quotation/guest/${slug}`, {
56
+ method: "GET",
57
+ query
58
+ });
59
+ if (response) {
60
+ publishableKey.value = response.data;
61
+ QuotationData.value = response;
62
+ responseData.value = response;
63
+ }
64
+ return response;
65
+ } catch (error) {
66
+ errorResponseData.value = error.data || error;
67
+ throw error;
68
+ }
69
+ };
70
+ const GuestCheckoutQuotation = async (slug, quotationData, query) => {
71
+ try {
72
+ responseData.value = [];
73
+ errorResponseData.value = [];
74
+ const FormData = quotationData.fields;
75
+ const response = await $fetch(`/api/checkout/quotation/guest/${slug}`, {
76
+ method: "POST",
77
+ body: FormData,
78
+ query
79
+ });
80
+ if (response) {
81
+ publishableKey.value = response.data;
82
+ responseData.value = response;
83
+ }
84
+ return response;
85
+ } catch (error) {
86
+ errorResponseData.value = error.data || error;
87
+ throw error;
88
+ }
89
+ };
90
+ const paymentMethods = async (formData) => {
91
+ try {
92
+ const response = await $fetch("/api/checkout/paymentmethod", {
93
+ method: "POST",
94
+ body: formData
95
+ });
96
+ if (response) {
97
+ publishableKey.value = response.data;
98
+ }
99
+ return response;
100
+ } catch (error) {
101
+ errorResponseData.value = error.data || error;
102
+ throw error;
103
+ }
104
+ };
105
+ const submitCheckout = async (slug, quotationData) => {
106
+ try {
107
+ responseData.value = [];
108
+ errorResponseData.value = [];
109
+ const response = await $fetch(`/api/checkout/quotation/submit/${slug}`, {
110
+ method: "POST",
111
+ body: quotationData
112
+ });
113
+ if (response.status == "Success") {
114
+ responseData.value = response.data;
115
+ }
116
+ return response;
117
+ } catch (error) {
118
+ errorResponseData.value = error.data || error;
119
+ throw error;
120
+ }
121
+ };
122
+ return {
123
+ inputData,
124
+ publishableKey,
125
+ responseData,
126
+ QuotationData,
127
+ checkoutSession,
128
+ preference,
129
+ errorResponseData,
130
+ resetState,
131
+ getQuotation,
132
+ getGuestQuotation,
133
+ GuestCheckoutQuotation,
134
+ paymentMethods,
135
+ submitCheckout
136
+ };
137
+ };