flowrix 1.0.1-beta.8 → 1.0.1-beta.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/module.d.mts +1 -6
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +94 -29
  4. package/dist/runtime/composables/Blog/useBlogIndex.d.ts +2 -5
  5. package/dist/runtime/composables/Brand/brand.js +2 -0
  6. package/dist/runtime/composables/Cart/useCart.d.ts +40 -0
  7. package/dist/runtime/composables/Cart/useCart.js +10 -0
  8. package/dist/runtime/composables/Cart/useCartDetail.d.ts +15 -5
  9. package/dist/runtime/composables/Cart/useCartDetail.js +3 -0
  10. package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.d.ts +40 -1
  11. package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.js +2 -2
  12. package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.d.ts +40 -1
  13. package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.js +2 -2
  14. package/dist/runtime/composables/Checkout/PaymentMethods/usePaymentMethods.js +3 -14
  15. package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.d.ts +2 -2
  16. package/dist/runtime/composables/Checkout/useCheckout.d.ts +84 -73
  17. package/dist/runtime/composables/Checkout/useCheckout.js +36 -28
  18. package/dist/runtime/composables/Checkout/{useBillingAddress.d.ts → useCheckoutBillingAddress.d.ts} +6 -6
  19. package/dist/runtime/composables/Checkout/{useBillingAddress.js → useCheckoutBillingAddress.js} +6 -1
  20. package/dist/runtime/composables/Checkout/{useShippingAddress.d.ts → useCheckoutShippingAddress.d.ts} +1 -1
  21. package/dist/runtime/composables/Checkout/{useShippingAddress.js → useCheckoutShippingAddress.js} +7 -2
  22. package/dist/runtime/composables/Checkout/useCreateAccount.d.ts +7 -7
  23. package/dist/runtime/composables/Checkout/useCreateAccount.js +3 -1
  24. package/dist/runtime/composables/Checkout/useDeliveryMethod.d.ts +2 -2
  25. package/dist/runtime/composables/Checkout/useDeliveryMethod.js +8 -7
  26. package/dist/runtime/composables/Customer/useBillingAddress.d.ts +112 -0
  27. package/dist/runtime/composables/Customer/useBillingAddress.js +93 -0
  28. package/dist/runtime/composables/Customer/useLogin.d.ts +9 -0
  29. package/dist/runtime/composables/Customer/useLogin.js +34 -0
  30. package/dist/runtime/composables/Customer/useOrders.d.ts +29 -0
  31. package/dist/runtime/composables/Customer/useOrders.js +56 -0
  32. package/dist/runtime/composables/Customer/usePasswordReset.d.ts +26 -0
  33. package/dist/runtime/composables/Customer/usePasswordReset.js +258 -0
  34. package/dist/runtime/composables/Customer/useProfile.d.ts +75 -0
  35. package/dist/runtime/composables/Customer/useProfile.js +106 -0
  36. package/dist/runtime/composables/Customer/useQuotations.d.ts +32 -0
  37. package/dist/runtime/composables/Customer/useQuotations.js +40 -0
  38. package/dist/runtime/composables/Customer/useRegister.d.ts +120 -11
  39. package/dist/runtime/composables/Customer/useRegister.js +311 -34
  40. package/dist/runtime/composables/Customer/useShippingAddress.d.ts +121 -0
  41. package/dist/runtime/composables/Customer/useShippingAddress.js +145 -0
  42. package/dist/runtime/composables/Customer/useUpdatePassword.d.ts +21 -0
  43. package/dist/runtime/composables/Customer/useUpdatePassword.js +94 -0
  44. package/dist/runtime/composables/Customer/useUserCards.d.ts +22 -0
  45. package/dist/runtime/composables/Customer/useUserCards.js +65 -0
  46. package/dist/runtime/composables/{useWishlists.d.ts → Customer/useWishlists.d.ts} +6 -19
  47. package/dist/runtime/composables/{useWishlists.js → Customer/useWishlists.js} +21 -29
  48. package/dist/runtime/composables/Extras/useCountry.d.ts +11 -6
  49. package/dist/runtime/composables/Extras/useCountry.js +5 -4
  50. package/dist/runtime/composables/Header/useHeader.d.ts +6 -20
  51. package/dist/runtime/composables/Header/useHeader.js +3 -2
  52. package/dist/runtime/composables/Product/CustomProduct/useSteps.d.ts +1 -1
  53. package/dist/runtime/composables/Product/useProductSlug.d.ts +8 -1
  54. package/dist/runtime/composables/Product/useQuickView.d.ts +8 -0
  55. package/dist/runtime/composables/Product/useQuickView.js +27 -0
  56. package/dist/runtime/composables/Product/useService.d.ts +1 -1
  57. package/dist/runtime/composables/Product/useService.js +0 -3
  58. package/dist/runtime/composables/SideBar/Filters/useFilters.d.ts +2 -2
  59. package/dist/runtime/composables/SideBar/Filters/useSorting.d.ts +2 -2
  60. package/dist/runtime/composables/index.d.ts +15 -12
  61. package/dist/runtime/composables/index.js +15 -12
  62. package/dist/runtime/composables/useAddresses.js +6 -6
  63. package/dist/runtime/composables/useCards.js +2 -2
  64. package/dist/runtime/composables/useLocation.d.ts +2 -12
  65. package/dist/runtime/composables/useQuotationCheckout.d.ts +78 -0
  66. package/dist/runtime/composables/useQuotationCheckout.js +138 -0
  67. package/dist/runtime/middleware/flowrix.d.ts +5 -4
  68. package/dist/runtime/middleware/flowrix.js +41 -21
  69. package/dist/runtime/plugin.d.ts +1 -1
  70. package/dist/runtime/server/api/albums.js +1 -1
  71. package/dist/runtime/server/api/auth/forgot.js +1 -1
  72. package/dist/runtime/server/api/auth/login.js +5 -6
  73. package/dist/runtime/server/api/auth/logout.js +1 -1
  74. package/dist/runtime/server/api/auth/register.js +1 -1
  75. package/dist/runtime/server/api/auth/session.get.js +1 -1
  76. package/dist/runtime/server/api/auth/user/reset-password.js +1 -1
  77. package/dist/runtime/server/api/auth/user/session.js +1 -1
  78. package/dist/runtime/server/api/auth/user/verify-token.js +1 -1
  79. package/dist/runtime/server/api/banners.js +2 -2
  80. package/dist/runtime/server/api/brand/{[slug].js → [...slug].js} +17 -17
  81. package/dist/runtime/server/api/brand/index.d.ts +2 -0
  82. package/dist/runtime/server/api/brand/index.js +23 -0
  83. package/dist/runtime/server/api/cache/[...slug].delete.d.ts +2 -0
  84. package/dist/runtime/server/api/cache/[...slug].delete.js +40 -0
  85. package/dist/runtime/server/api/cache/clean.get.d.ts +5 -0
  86. package/dist/runtime/server/api/cache/clean.get.js +16 -0
  87. package/dist/runtime/server/api/cart/[slug]/add.js +1 -1
  88. package/dist/runtime/server/api/cart/[slug]/update.js +1 -1
  89. package/dist/runtime/server/api/cart/related.d.ts +2 -0
  90. package/dist/runtime/server/api/cart/related.js +21 -0
  91. package/dist/runtime/server/api/cart/remove.js +1 -1
  92. package/dist/runtime/server/api/cart/service/[slug]/add.js +1 -1
  93. package/dist/runtime/server/api/catalog/categories.js +5 -4
  94. package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
  95. package/dist/runtime/server/api/catalog/categoriesall.js +44 -0
  96. package/dist/runtime/server/api/catalog/featured.js +5 -4
  97. package/dist/runtime/server/api/catalog/samples.js +5 -4
  98. package/dist/runtime/server/api/catalog/search.js +5 -4
  99. package/dist/runtime/server/api/category/[...slug].js +18 -14
  100. package/dist/runtime/server/api/checkout/applyCoupon.js +1 -1
  101. package/dist/runtime/server/api/checkout/configs.d.ts +1 -1
  102. package/dist/runtime/server/api/checkout/configs.js +10 -11
  103. package/dist/runtime/server/api/checkout/countries.js +1 -1
  104. package/dist/runtime/server/api/checkout/paymentmethod.js +7 -7
  105. package/dist/runtime/server/api/checkout/quotation/[slug].d.ts +2 -0
  106. package/dist/runtime/server/api/checkout/quotation/[slug].js +21 -0
  107. package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +2 -0
  108. package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +37 -0
  109. package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +2 -0
  110. package/dist/runtime/server/api/checkout/quotation/guest/customer.js +21 -0
  111. package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +2 -0
  112. package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +23 -0
  113. package/dist/runtime/server/api/{blog/[slug].js → cmspost/[...slug].js} +7 -9
  114. package/dist/runtime/server/api/{blog/blog.js → cmspost/all.js} +2 -2
  115. package/dist/runtime/server/api/company/profile.d.ts +1 -1
  116. package/dist/runtime/server/api/company/profile.js +9 -9
  117. package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +1 -1
  118. package/dist/runtime/server/api/contact-center/webforms/create.js +1 -1
  119. package/dist/runtime/server/api/countries.d.ts +2 -0
  120. package/dist/runtime/server/api/countries.js +35 -0
  121. package/dist/runtime/server/api/customer/address/add.js +1 -1
  122. package/dist/runtime/server/api/customer/address/delete.js +2 -2
  123. package/dist/runtime/server/api/customer/address/setshipping.js +1 -1
  124. package/dist/runtime/server/api/customer/address/update.js +1 -1
  125. package/dist/runtime/server/api/customer/cards/delete.js +2 -2
  126. package/dist/runtime/server/api/customer/cards/get.js +2 -2
  127. package/dist/runtime/server/api/customer/change-password.js +2 -2
  128. package/dist/runtime/server/api/customer/checkout.js +1 -1
  129. package/dist/runtime/server/api/customer/orders.js +2 -2
  130. package/dist/runtime/server/api/customer/profile/update.js +1 -1
  131. package/dist/runtime/server/api/customer/quotations.js +2 -2
  132. package/dist/runtime/server/api/customer/search.js +1 -1
  133. package/dist/runtime/server/api/customer/tax-invoice.js +1 -1
  134. package/dist/runtime/server/api/customer/wishlist/add.js +1 -1
  135. package/dist/runtime/server/api/customer/wishlist/createWishList.js +1 -1
  136. package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +1 -1
  137. package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +1 -1
  138. package/dist/runtime/server/api/customer/wishlist/get.js +2 -2
  139. package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +1 -1
  140. package/dist/runtime/server/api/customer/wishlist/updateWishList.js +2 -2
  141. package/dist/runtime/server/api/featured.d.ts +2 -0
  142. package/dist/runtime/server/api/featured.js +16 -0
  143. package/dist/runtime/server/api/location.js +1 -1
  144. package/dist/runtime/server/api/nav/[id]/links.js +1 -1
  145. package/dist/runtime/server/api/page/{[slug].js → [...slug].js} +6 -8
  146. package/dist/runtime/server/api/product/[...slug].js +8 -5
  147. package/dist/runtime/server/api/quickview/[slug].d.ts +2 -0
  148. package/dist/runtime/server/api/quickview/[slug].js +16 -0
  149. package/dist/runtime/server/api/samples.d.ts +3 -0
  150. package/dist/runtime/server/api/samples.js +20 -0
  151. package/dist/runtime/server/api/search.d.ts +3 -0
  152. package/dist/runtime/server/api/search.js +15 -0
  153. package/dist/runtime/server/api/service/[slug].js +5 -4
  154. package/dist/runtime/server/api/service/availability.js +1 -1
  155. package/dist/runtime/server/api/service/getall.d.ts +3 -0
  156. package/dist/runtime/server/api/service/getall.js +52 -0
  157. package/dist/runtime/server/api/shop.d.ts +3 -0
  158. package/dist/runtime/server/api/shop.js +15 -0
  159. package/dist/runtime/server/api/subscribe.js +1 -1
  160. package/dist/runtime/server/api/v2/[...slug].js +3 -1
  161. package/dist/runtime/server/api/webform.d.ts +3 -0
  162. package/dist/runtime/server/api/webform.js +16 -0
  163. package/dist/runtime/stores/Cart.d.ts +12 -0
  164. package/dist/runtime/stores/Cart.js +50 -16
  165. package/dist/runtime/stores/Checkout.d.ts +9 -15
  166. package/dist/runtime/stores/Checkout.js +19 -5
  167. package/dist/runtime/stores/Search.d.ts +1 -1
  168. package/dist/runtime/stores/Services.js +2 -2
  169. package/dist/runtime/stores/auth.d.ts +8 -11
  170. package/dist/runtime/stores/auth.js +390 -8
  171. package/dist/runtime/stores/countries.d.ts +1 -3
  172. package/dist/runtime/stores/countries.js +4 -8
  173. package/dist/runtime/stores/product/slug.d.ts +1 -17
  174. package/dist/runtime/stores/wishlists.d.ts +114 -6
  175. package/dist/runtime/stores/wishlists.js +209 -9
  176. package/dist/runtime/utils/api.js +9 -13
  177. package/dist/runtime/utils/htmlCache.d.ts +5 -0
  178. package/dist/runtime/utils/htmlCache.js +60 -0
  179. package/dist/types.d.mts +6 -2
  180. package/package.json +32 -20
  181. package/dist/runtime/composables/useAuth.d.ts +0 -45
  182. package/dist/runtime/composables/useAuth.js +0 -180
  183. package/dist/runtime/composables/useCountries.d.ts +0 -12
  184. package/dist/runtime/composables/useCountries.js +0 -50
  185. package/dist/runtime/composables/useOrders.d.ts +0 -21
  186. package/dist/runtime/composables/useOrders.js +0 -82
  187. package/dist/runtime/composables/useQuotations.d.ts +0 -14
  188. package/dist/runtime/composables/useQuotations.js +0 -50
  189. /package/dist/runtime/server/api/brand/{[slug].d.ts → [...slug].d.ts} +0 -0
  190. /package/dist/runtime/server/api/{blog/[slug].d.ts → cmspost/[...slug].d.ts} +0 -0
  191. /package/dist/runtime/server/api/{blog/blog.d.ts → cmspost/all.d.ts} +0 -0
  192. /package/dist/runtime/server/api/page/{[slug].d.ts → [...slug].d.ts} +0 -0
@@ -0,0 +1,15 @@
1
+ import { defineEventHandler, getQuery } from "h3";
2
+ import { $fetch } from "ofetch";
3
+ export const Page = /* @__PURE__ */ new Map();
4
+ export default defineEventHandler(async (event) => {
5
+ const params = getQuery(event);
6
+ const search = await $fetch(`${process.env.FLOWRIX_API_BASE}search`, {
7
+ headers: {
8
+ "x-public-key": process.env.FLOWRIX_API_KEY,
9
+ "x-api-secret": process.env.FLOWRIX_API_SECRET,
10
+ "Origin": process.env.FLOWRIX_API_ORIGIN
11
+ },
12
+ params
13
+ });
14
+ return search;
15
+ });
@@ -1,8 +1,8 @@
1
- import { defineEventHandler, getRouterParam, getQuery, createError, readBody } from "h3";
1
+ import { defineEventHandler, getRouterParam, getQuery, createError, readBody, getCookie } from "h3";
2
2
  import { $fetch } from "ofetch";
3
3
  import { writeFile, mkdir, readFile } from "fs/promises";
4
4
  import { join } from "path";
5
- const CACHE_DIR = join(process.cwd(), ".nuxt", "cache", "nitro", "services");
5
+ const CACHE_DIR = join("/tmp", ".cache", "nitro", "services");
6
6
  export const serviceCache = /* @__PURE__ */ new Map();
7
7
  async function ensureCacheDir() {
8
8
  try {
@@ -13,6 +13,7 @@ async function ensureCacheDir() {
13
13
  }
14
14
  export default defineEventHandler(async (event) => {
15
15
  const slug = getRouterParam(event, "slug");
16
+ const customerType = getCookie(event, "customertype") || "";
16
17
  const query = getQuery(event);
17
18
  const body = await readBody(event);
18
19
  if (!slug) {
@@ -23,7 +24,7 @@ export default defineEventHandler(async (event) => {
23
24
  }
24
25
  const cacheKey = `${slug}-${JSON.stringify(query)}`;
25
26
  const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
26
- const filePath = join(CACHE_DIR, `${fileName}.json`);
27
+ const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
27
28
  try {
28
29
  const fileContent = await readFile(filePath, "utf-8");
29
30
  const service = JSON.parse(fileContent);
@@ -33,7 +34,7 @@ export default defineEventHandler(async (event) => {
33
34
  try {
34
35
  const service = await $fetch(`${process.env.FLOWRIX_API_BASE}services/${slug}`, {
35
36
  headers: {
36
- "x-api-key": process.env.FLOWRIX_API_KEY,
37
+ "x-public-key": process.env.FLOWRIX_API_KEY,
37
38
  "x-api-secret": process.env.FLOWRIX_API_SECRET,
38
39
  "Origin": process.env.FLOWRIX_API_ORIGIN
39
40
  }
@@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
5
5
  const response = await fetch(`${process.env.FLOWRIX_API_BASE}services/availability`, {
6
6
  method: "POST",
7
7
  headers: {
8
- "x-api-key": process.env.FLOWRIX_API_KEY || "",
8
+ "x-public-key": process.env.FLOWRIX_API_KEY || "",
9
9
  "x-api-secret": process.env.FLOWRIX_API_SECRET || "",
10
10
  "Origin": process.env.FLOWRIX_API_ORIGIN || "",
11
11
  "Content-Type": "application/json",
@@ -0,0 +1,3 @@
1
+ export declare const serviceCache: Map<any, any>;
2
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
+ export default _default;
@@ -0,0 +1,52 @@
1
+ import { defineEventHandler, getQuery, createError, readBody, getCookie } from "h3";
2
+ import { $fetch } from "ofetch";
3
+ import { writeFile, mkdir, readFile } from "fs/promises";
4
+ import { join } from "path";
5
+ const CACHE_DIR = join("/tmp", ".cache", "nitro", "services");
6
+ export const serviceCache = /* @__PURE__ */ new Map();
7
+ async function ensureCacheDir() {
8
+ try {
9
+ await mkdir(CACHE_DIR, { recursive: true });
10
+ } catch (error) {
11
+ console.error("Error creating cache directory:", error);
12
+ }
13
+ }
14
+ export default defineEventHandler(async (event) => {
15
+ const slug = "all";
16
+ const customerType = getCookie(event, "customertype") || "";
17
+ const query = getQuery(event);
18
+ const body = await readBody(event);
19
+ if (!slug) {
20
+ throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
21
+ }
22
+ if (!/^[a-zA-Z0-9-_]+$/.test(slug)) {
23
+ throw createError({ statusCode: 400, statusMessage: "Invalid slug" });
24
+ }
25
+ const cacheKey = `${slug}-${JSON.stringify(query)}`;
26
+ const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
27
+ const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
28
+ try {
29
+ const fileContent = await readFile(filePath, "utf-8");
30
+ const service = JSON.parse(fileContent);
31
+ return service;
32
+ } catch (error) {
33
+ }
34
+ try {
35
+ const service = await $fetch(`${process.env.FLOWRIX_API_BASE}services`, {
36
+ headers: {
37
+ "x-public-key": process.env.FLOWRIX_API_KEY,
38
+ "x-api-secret": process.env.FLOWRIX_API_SECRET,
39
+ "Origin": process.env.FLOWRIX_API_ORIGIN
40
+ }
41
+ });
42
+ await ensureCacheDir();
43
+ await writeFile(filePath, JSON.stringify(service, null, 2), "utf-8");
44
+ return service;
45
+ } catch (error) {
46
+ throw createError({
47
+ statusCode: 500,
48
+ statusMessage: `Failed to fetch services`,
49
+ data: error.message
50
+ });
51
+ }
52
+ });
@@ -0,0 +1,3 @@
1
+ export declare const Page: Map<any, any>;
2
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import { defineEventHandler, getQuery } from "h3";
2
+ import { $fetch } from "ofetch";
3
+ export const Page = /* @__PURE__ */ new Map();
4
+ export default defineEventHandler(async (event) => {
5
+ const query = getQuery(event);
6
+ const page = await $fetch(`${process.env.FLOWRIX_API_BASE}search`, {
7
+ headers: {
8
+ "x-public-key": process.env.FLOWRIX_API_KEY,
9
+ "x-api-secret": process.env.FLOWRIX_API_SECRET,
10
+ "Origin": process.env.FLOWRIX_API_ORIGIN
11
+ },
12
+ query
13
+ });
14
+ return page;
15
+ });
@@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
5
5
  const subscribe = await $fetch(`${process.env.FLOWRIX_API_BASE}subscribe`, {
6
6
  method: "POST",
7
7
  headers: {
8
- "x-api-key": process.env.FLOWRIX_API_KEY,
8
+ "x-public-key": process.env.FLOWRIX_API_KEY,
9
9
  "x-api-secret": process.env.FLOWRIX_API_SECRET,
10
10
  "Origin": process.env.FLOWRIX_API_ORIGIN,
11
11
  "Content-Type": "application/json"
@@ -1,9 +1,11 @@
1
1
  import { defineEventHandler } from "h3";
2
2
  import { flowrixApi } from "../../../middleware/flowrix.js";
3
+ import { useRuntimeConfig } from "#imports";
3
4
  export const Page = /* @__PURE__ */ new Map();
4
5
  export default defineEventHandler(async (event) => {
5
6
  const slug = event.context.params._;
6
- const page = await flowrixApi.get(`permalink/${slug}`, "", "v2");
7
+ let config = useRuntimeConfig();
8
+ const page = await flowrixApi.get(`permalink/${slug}`, config);
7
9
  Page.set(slug, page);
8
10
  return page;
9
11
  });
@@ -0,0 +1,3 @@
1
+ export declare const Page: Map<any, any>;
2
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { defineEventHandler, getRouterParam } from "h3";
2
+ import { $fetch } from "ofetch";
3
+ export const Page = /* @__PURE__ */ new Map();
4
+ export default defineEventHandler(async (event) => {
5
+ const slug = getRouterParam(event, "slug");
6
+ const query = getQuery(event);
7
+ const page = await $fetch(`${process.env.FLOWRIX_API_BASE}contact-center/webforms/${query.id}/details`, {
8
+ headers: {
9
+ "x-public-key": process.env.FLOWRIX_API_KEY,
10
+ "x-api-secret": process.env.FLOWRIX_API_SECRET,
11
+ "Origin": process.env.FLOWRIX_API_ORIGIN
12
+ },
13
+ query
14
+ });
15
+ return page;
16
+ });
@@ -36,6 +36,17 @@ export interface CartData {
36
36
  shippingmethod?: string | number;
37
37
  vouchercodes?: string[];
38
38
  }
39
+ export interface RelatedData {
40
+ cart: Record<string, CartItem> | undefined;
41
+ qty?: number;
42
+ abndToken?: string;
43
+ deliverymethod?: number | string;
44
+ shipping_state?: string | number;
45
+ shipping_postcode?: number;
46
+ shipping_country?: string | number;
47
+ shippingmethod?: string | number;
48
+ vouchercodes?: string[];
49
+ }
39
50
  export interface FormData {
40
51
  cart: Record<string, CartItem> | undefined;
41
52
  qty: number;
@@ -63,5 +74,6 @@ export interface CartState {
63
74
  responseData: [];
64
75
  errorResponseData: Record<string, any>;
65
76
  addedResponse: string;
77
+ relatedProducts: any[];
66
78
  }
67
79
  export declare const useCartStore: import("pinia").StoreDefinition<"cart", CartState, {}, {}>;
@@ -1,7 +1,7 @@
1
1
  import { defineStore } from "pinia";
2
2
  import { flowrixApi } from "../middleware/flowrix.js";
3
3
  import { useCheckoutStore } from "./Checkout.js";
4
- import { useApi } from "../utils/api.js";
4
+ import { useRuntimeConfig } from "#imports";
5
5
  export const useCartStore = defineStore("cart", {
6
6
  state: () => ({
7
7
  cart: {},
@@ -31,7 +31,6 @@ export const useCartStore = defineStore("cart", {
31
31
  return { attribute_id, fraction };
32
32
  },
33
33
  async addToCart(product, qty, data, productId = "", service = []) {
34
- const { post } = useApi();
35
34
  const checkoutSession = useCheckoutStore().checkoutSession;
36
35
  let formData = {
37
36
  cart: void 0,
@@ -65,9 +64,14 @@ export const useCartStore = defineStore("cart", {
65
64
  apiUrl = `cart/service/${service.slug}/add`;
66
65
  }
67
66
  try {
68
- const response = await flowrixApi.post(apiUrl, {
69
- body: formData
70
- });
67
+ const config = useRuntimeConfig();
68
+ const response = await flowrixApi.post(
69
+ apiUrl,
70
+ config,
71
+ {
72
+ body: formData
73
+ }
74
+ );
71
75
  if (response?.status == "Success") {
72
76
  this.addedResponse = "success";
73
77
  this.cart = {
@@ -90,9 +94,23 @@ export const useCartStore = defineStore("cart", {
90
94
  this.addedResponse = "";
91
95
  }
92
96
  },
97
+ async fetchRelated() {
98
+ try {
99
+ const request = {
100
+ cart: this.cart.items
101
+ };
102
+ const apiUrl = `/api/cart/related`;
103
+ const response = await $fetch(apiUrl, {
104
+ method: "POST",
105
+ body: request
106
+ });
107
+ return response;
108
+ } catch (error) {
109
+ console.error("Error removing from cart:", error);
110
+ }
111
+ },
93
112
  async removeFromCart(id, product) {
94
113
  try {
95
- const { post } = useApi();
96
114
  const checkoutSession = useCheckoutStore().checkoutSession;
97
115
  const apiUrl = `cart/remove`;
98
116
  const request = {
@@ -108,7 +126,10 @@ export const useCartStore = defineStore("cart", {
108
126
  if (this.coupon?.length > 0) {
109
127
  request.vouchercodes = this.coupon;
110
128
  }
111
- const response = await post(apiUrl, request);
129
+ const config = useRuntimeConfig();
130
+ const response = await flowrixApi.post(apiUrl, config, {
131
+ body: request
132
+ });
112
133
  if (response?.status == "Success") {
113
134
  this.cart = {
114
135
  ["items"]: response?.data.cart,
@@ -132,23 +153,22 @@ export const useCartStore = defineStore("cart", {
132
153
  async updateQuantity(product, qty) {
133
154
  try {
134
155
  const checkoutSession = useCheckoutStore().checkoutSession;
135
- const { post } = useApi();
136
156
  const apiUrl = `cart/${product.slug}/update`;
137
157
  const request = {
138
158
  cart: this.cart.items,
139
159
  rowId: product.rowId,
140
160
  qty,
141
161
  deliverymethod: checkoutSession?.fields?.deliverymethod,
142
- // shipping_state: checkoutSession?.fields?.shipping_state,
143
- // shipping_postcode: checkoutSession?.fields?.shipping_postcode,
144
- // shipping_country: checkoutSession?.fields?.shipping_country,
145
162
  shippingmethod: checkoutSession?.fields?.shippingmethod,
146
163
  abndToken: this.cart.abndToken
147
164
  };
148
165
  if (this.coupon?.length > 0) {
149
166
  request.vouchercodes = this.coupon;
150
167
  }
151
- const response = await post(apiUrl, request);
168
+ const config = useRuntimeConfig();
169
+ const response = await flowrixApi.post(apiUrl, config, {
170
+ body: request
171
+ });
152
172
  if (response?.status == "Success") {
153
173
  this.cart = {
154
174
  ["items"]: response?.data.cart,
@@ -180,12 +200,11 @@ export const useCartStore = defineStore("cart", {
180
200
  try {
181
201
  let couponsCodes = this.coupon || [];
182
202
  const checkoutSession = useCheckoutStore().checkoutSession;
183
- const { post } = useApi();
184
- let apiUrl = "/checkout/applyCoupon";
203
+ let apiUrl = "checkout/applyCoupon";
185
204
  const removeValue = coupon.remove ?? void 0;
186
205
  if (removeValue !== void 0) {
187
206
  couponsCodes.splice(removeValue, 1);
188
- apiUrl = "/checkout/remove-coupon";
207
+ apiUrl = "checkout/remove-coupon";
189
208
  }
190
209
  const couponData = {
191
210
  cart: this.cart.items,
@@ -194,7 +213,10 @@ export const useCartStore = defineStore("cart", {
194
213
  code: removeValue === void 0 ? coupon.code : "",
195
214
  abndToken: this.cart.abndToken
196
215
  };
197
- const response = await post(apiUrl, couponData);
216
+ const config = useRuntimeConfig();
217
+ const response = await flowrixApi.post(apiUrl, config, {
218
+ body: couponData
219
+ });
198
220
  if (response?.status === "Success" && response?.data?.calculations) {
199
221
  this.cart.totals = response.data.calculations;
200
222
  if (removeValue === void 0) {
@@ -203,6 +225,18 @@ export const useCartStore = defineStore("cart", {
203
225
  this.coupon = Array.from(new Set(couponsCodes));
204
226
  useCheckoutStore().saveToCheckoutSession(response.data);
205
227
  this.errorResponseData = {};
228
+ this.cart = {
229
+ ["items"]: response?.data.cart,
230
+ ["totals"]: response?.data.calculations,
231
+ ["abndToken"]: response?.data.abndToken
232
+ };
233
+ this.lastitem = response?.data.lastItem;
234
+ useCheckoutStore().saveToCheckoutSession({
235
+ cart: response?.data,
236
+ calculations: response?.data.calculations,
237
+ abndToken: response?.data.abndToken,
238
+ fields: checkoutSession?.fields
239
+ });
206
240
  return response;
207
241
  } else {
208
242
  const errorMessage = response?.message || "Failed to apply coupon";
@@ -1,18 +1,21 @@
1
- interface PreferenceData {
1
+ export interface PreferenceData {
2
2
  fields?: Record<string, any>;
3
3
  deliverytype?: string;
4
4
  order_no?: string;
5
5
  publishableKey?: any;
6
6
  [key: string]: any;
7
7
  }
8
- interface CartItem {
8
+ export interface CartItem {
9
9
  fields?: Record<string, any>;
10
10
  deliverytype?: string;
11
11
  order_no?: string;
12
12
  publishableKey?: any;
13
13
  [key: string]: any;
14
14
  }
15
- interface ConfigData {
15
+ export interface Country {
16
+ id: number | string;
17
+ }
18
+ export interface ConfigData {
16
19
  preferences?: Record<string, any>[];
17
20
  outlets?: Record<string, any>[];
18
21
  deliverytype?: string;
@@ -24,7 +27,7 @@ interface ConfigData {
24
27
  totals?: Record<string, any>;
25
28
  [key: string]: any;
26
29
  }
27
- interface FieldData {
30
+ export interface FieldData {
28
31
  billing_state?: number | string;
29
32
  billing_firstname?: string | number;
30
33
  firstname?: string | number;
@@ -58,7 +61,7 @@ interface FieldData {
58
61
  quotation_no?: string;
59
62
  [key: string]: any;
60
63
  }
61
- interface CheckoutState {
64
+ export interface CheckoutState {
62
65
  publishableKey: Record<string, any>;
63
66
  responseData: any[];
64
67
  config: ConfigData;
@@ -73,13 +76,4 @@ interface CheckoutState {
73
76
  PaymentErrors: any;
74
77
  loading: boolean;
75
78
  }
76
- export declare const useCheckoutStore: import("pinia").StoreDefinition<"checkout", CheckoutState, {}, {
77
- resetState(): void;
78
- paymentMethods(formData: any): Promise<any>;
79
- getConfig(): Promise<void>;
80
- submitCheckout(): Promise<any>;
81
- confirmPayment(checkoutId: string): Promise<void>;
82
- CheckUserAccount(email: string): Promise<any>;
83
- saveToCheckoutSession(fieldsData: FieldData): Promise<void>;
84
- }>;
85
- export {};
79
+ export declare const useCheckoutStore: import("pinia").StoreDefinition<"checkout", CheckoutState, {}, {}>;
@@ -1,6 +1,8 @@
1
1
  import { useCartStore } from "./Cart.js";
2
2
  import { defineStore } from "pinia";
3
+ import { flowrixApi } from "../middleware/flowrix.js";
3
4
  import { useApi } from "../utils/api.js";
5
+ import { useRuntimeConfig } from "#imports";
4
6
  export const useCheckoutStore = defineStore("checkout", {
5
7
  state: () => ({
6
8
  publishableKey: {},
@@ -81,7 +83,14 @@ export const useCheckoutStore = defineStore("checkout", {
81
83
  formData.cart = useCartStore().cart.items;
82
84
  formData.abndToken = useCartStore().cart.abndToken;
83
85
  const apiUrl = `checkout/configs`;
84
- const response = await post(apiUrl, formData);
86
+ const config = useRuntimeConfig();
87
+ const response = await flowrixApi.post(
88
+ apiUrl,
89
+ config,
90
+ {
91
+ body: formData
92
+ }
93
+ );
85
94
  if (response?.data) {
86
95
  this.config = response.data;
87
96
  const shippingMethods = response.data.shippingmethods;
@@ -120,11 +129,11 @@ export const useCheckoutStore = defineStore("checkout", {
120
129
  async submitCheckout() {
121
130
  try {
122
131
  this.loading = true;
123
- const { post } = useApi();
124
132
  const formData = this.checkoutSession.fields || {};
125
133
  const apiUrl = `customer/checkout`;
126
134
  formData.billing_address2 = formData.billing_address;
127
- const response = await post(apiUrl, formData);
135
+ const config = useRuntimeConfig();
136
+ const response = await flowrixApi.post(apiUrl, config, { body: formData });
128
137
  if (response?.data?.order || response?.data?.order_no) {
129
138
  const orderData = response.data.order || response.data;
130
139
  const invoiceId = orderData.order_no;
@@ -148,7 +157,7 @@ export const useCheckoutStore = defineStore("checkout", {
148
157
  invoice: error?.data?.data?.order_no
149
158
  };
150
159
  this.loading = false;
151
- return error;
160
+ return error.data;
152
161
  }
153
162
  },
154
163
  async confirmPayment(checkoutId) {
@@ -209,5 +218,10 @@ export const useCheckoutStore = defineStore("checkout", {
209
218
  }
210
219
  }
211
220
  },
212
- persist: true
221
+ persist: {
222
+ enabled: true,
223
+ // simple shape that works with most versions:
224
+ key: "checkoutSession",
225
+ storage: typeof window !== "undefined" ? localStorage : void 0
226
+ }
213
227
  });
@@ -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
  }>;
@@ -8,9 +8,9 @@ export const useServiceStore = defineStore("ServiceStore", {
8
8
  actions: {
9
9
  async getAllServices() {
10
10
  try {
11
- const apiUrl = `/api/services/getall`;
11
+ const apiUrl = `/api/service/getall`;
12
12
  const response = await $fetch(apiUrl, {
13
- method: "GET",
13
+ method: "POST",
14
14
  headers: {
15
15
  "Content-Type": "application/json"
16
16
  }
@@ -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
+ }, {}>;