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