flowrix 1.0.1-beta.101 → 1.0.1-beta.103

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.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "flowrix",
3
3
  "configKey": "flowrix",
4
- "version": "1.0.1-beta.101",
4
+ "version": "1.0.1-beta.103",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -0,0 +1 @@
1
+ export declare const useCartComponent: () => Promise<void>;
@@ -0,0 +1,10 @@
1
+ import { GTM_view_cart } from "../useDataLayer.js";
2
+ import { META_view_cart } from "../useMetaLayer.js";
3
+ import { TikTok_view_cart } from "../useTikTokDatalayer.js";
4
+ export const useCartComponent = async () => {
5
+ const cartStore = useCartStore();
6
+ const cartItems = cartStore.cart.items;
7
+ GTM_view_cart(cartItems);
8
+ META_view_cart(cartItems);
9
+ TikTok_view_cart(cartItems);
10
+ };
@@ -1,33 +1,26 @@
1
- import { type Ref, type ComputedRef } from 'vue';
2
- interface CategoryData {
3
- status: string;
4
- message: number;
5
- data: {
6
- template: any;
7
- type: string;
8
- record: {
9
- category: object;
10
- products: object;
11
- brands: object[];
12
- filter_values: object[];
13
- filters: object[];
14
- categories: object[];
15
- prices: object;
16
- breadcrumb: string;
1
+ export declare const useCategoryIndex: (props: any) => {
2
+ catData: any;
3
+ pending: any;
4
+ error: any;
5
+ transformedApiData: import("vue").ComputedRef<{
6
+ status: any;
7
+ message: any;
8
+ data: {
9
+ template: any;
10
+ type: any;
11
+ record: {
12
+ category: any;
13
+ products: any;
14
+ brands: any;
15
+ filter_values: any;
16
+ filters: any;
17
+ categories: any;
18
+ prices: any;
19
+ breadcrumb: any;
20
+ };
17
21
  };
18
- };
19
- }
20
- interface CategoryIndexProps {
21
- data: CategoryData;
22
- }
23
- interface UseCategoryIndexReturn {
24
- catData: Ref<any>;
25
- error: Ref<any>;
26
- pending: Ref<boolean>;
27
- transformedApiData: ComputedRef<CategoryData | null>;
28
- renderData: ComputedRef<CategoryData>;
29
- refresh: () => Promise<void>;
30
- getSelectedTemplate: (templateComponents: Record<string, any>) => ComputedRef<any>;
31
- }
32
- export declare const useCategoryIndex: (props: CategoryIndexProps) => UseCategoryIndexReturn;
33
- export {};
22
+ } | null>;
23
+ renderData: import("vue").ComputedRef<any>;
24
+ refresh: any;
25
+ getSelectedTemplate: (templateComponents: any) => import("vue").ComputedRef<any>;
26
+ };
@@ -1,49 +1,48 @@
1
- import { useRoute, useFetch } from "#imports";
2
- import { watch, computed } from "vue";
1
+ import { useHead, useRoute, useAsyncData } from "#imports";
2
+ import { computed } from "vue";
3
3
  export const useCategoryIndex = (props) => {
4
4
  const route = useRoute();
5
5
  const slug = route.params.slug;
6
- const { data: catData, error, pending, refresh } = useFetch(`/api/category/${slug}`, {
7
- method: "GET",
8
- query: route.query
9
- });
10
- watch(catData, (newData) => {
11
- }, { immediate: true });
12
- watch(
13
- () => [route.path, route.query],
14
- async () => {
15
- pending.value = true;
16
- const response = await useFetch(`/api/category/${slug}`, {
17
- method: "GET",
18
- query: route.query
19
- });
20
- catData.value = response.data.value;
21
- pending.value = false;
22
- },
23
- { deep: true }
6
+ const { data: catData, pending, error, refresh } = useAsyncData(
7
+ `category-${slug}-${JSON.stringify(route.query)}`,
8
+ () => $fetch(`/api/category/${slug}`, { query: route.query })
24
9
  );
10
+ const meta = computed(() => {
11
+ const category = catData.value?.category || {};
12
+ return {
13
+ title: category.meta_title || category.name || "",
14
+ description: category.meta_description || "",
15
+ robots: category.robots || "index,follow"
16
+ };
17
+ });
18
+ useHead(() => ({
19
+ title: `${meta.value.title} -- ${meta.value.robots}`,
20
+ meta: [
21
+ { name: "robots", content: meta.value.robots },
22
+ { name: "description", content: meta.value.description }
23
+ ]
24
+ }));
25
25
  const transformedApiData = computed(() => {
26
- if (catData.value && catData.value.status === "Success") {
27
- return {
28
- status: catData.value.status,
29
- message: catData.value.message,
30
- data: {
31
- template: catData.value.data?.category?.template || "default",
32
- type: catData.value.data?.type || "category",
33
- record: {
34
- category: catData.value.data?.category || {},
35
- products: catData.value.data?.products || {},
36
- brands: catData.value.data?.brands || [],
37
- filter_values: catData.value.data?.filter_values || [],
38
- filters: catData.value.data?.filters || [],
39
- categories: catData.value.data?.categories || [],
40
- prices: catData.value.data?.prices || {},
41
- breadcrumb: catData.value.data?.breadcrumb || ""
42
- }
26
+ const d = catData.value?.data;
27
+ if (!d) return null;
28
+ return {
29
+ status: catData.value.status,
30
+ message: catData.value.message,
31
+ data: {
32
+ template: d.category?.template || "default",
33
+ type: d.type || "category",
34
+ record: {
35
+ category: d.category || {},
36
+ products: d.products || {},
37
+ brands: d.brands || [],
38
+ filter_values: d.filter_values || [],
39
+ filters: d.filters || [],
40
+ categories: d.categories || [],
41
+ prices: d.prices || {},
42
+ breadcrumb: d.breadcrumb || ""
43
43
  }
44
- };
45
- }
46
- return null;
44
+ }
45
+ };
47
46
  });
48
47
  const renderData = computed(() => transformedApiData.value || props.data);
49
48
  const getSelectedTemplate = (templateComponents) => {
@@ -52,13 +51,11 @@ export const useCategoryIndex = (props) => {
52
51
  });
53
52
  };
54
53
  return {
55
- // State
56
54
  catData,
57
- error,
58
55
  pending,
56
+ error,
59
57
  transformedApiData,
60
58
  renderData,
61
- // Methods
62
59
  refresh,
63
60
  getSelectedTemplate
64
61
  };
@@ -337,6 +337,7 @@ export default function() {
337
337
  }
338
338
  } else if (chckoutResponse.data.url) {
339
339
  var url = chckoutResponse.data.url;
340
+ window.location.href = url;
340
341
  } else {
341
342
  window.location.href = url_success;
342
343
  }
@@ -1,5 +1,7 @@
1
1
  import { defineAsyncComponent } from "vue";
2
2
  import { GTM_view_item } from "../useDataLayer.js";
3
+ import { META_view_item } from "../useMetaLayer.js";
4
+ import { TikTok_view_item } from "../useTikTokDatalayer.js";
3
5
  export function useProductComponent(product) {
4
6
  const templateName = "Template-" + product.template;
5
7
  const components = import.meta.glob(
@@ -17,6 +19,8 @@ export function useProductComponent(product) {
17
19
  }
18
20
  });
19
21
  GTM_view_item(product, product.rrpfloat, product.rpfloat);
22
+ META_view_item(product, product.rrpfloat, product.rpfloat);
23
+ TikTok_view_item(product, product.rrpfloat, product.rpfloat);
20
24
  return {
21
25
  Template
22
26
  };
@@ -7,6 +7,7 @@ export * from './Blog/useMagazineCard.js';
7
7
  export * from './Blog/useSingleBlogMain.js';
8
8
  export * from './Brand/brand.js';
9
9
  export * from './Cart/useCartDetail.js';
10
+ export * from './Cart/useCartComponent.js';
10
11
  export * from './Category/useCategoryContent.js';
11
12
  export * from './Category/useCategoryGrid.js';
12
13
  export * from './Category/useCategoryIndex.js';
@@ -7,6 +7,7 @@ export * from "./Blog/useMagazineCard.js";
7
7
  export * from "./Blog/useSingleBlogMain.js";
8
8
  export * from "./Brand/brand.js";
9
9
  export * from "./Cart/useCartDetail.js";
10
+ export * from "./Cart/useCartComponent.js";
10
11
  export * from "./Category/useCategoryContent.js";
11
12
  export * from "./Category/useCategoryGrid.js";
12
13
  export * from "./Category/useCategoryIndex.js";
@@ -1,10 +1,29 @@
1
- import { useHead } from "#imports";
1
+ import { useHead, useRequestEvent } from "#imports";
2
+ import { getRequestURL } from "h3";
2
3
  import { useCompanyProfile } from "../stores/useCompanyProfile.js";
3
4
  export const useApp = () => {
4
5
  const companyProfile = useCompanyProfile();
5
6
  const gtmId = companyProfile.profile?.data?.integrations["google-tag-manager"]["script"] || "";
6
7
  const tiktok = companyProfile.profile?.data?.integrations["tiktok"]["script"] || "";
8
+ const facebookMeta = companyProfile.profile?.data?.integrations["meta"]["script"] || "";
9
+ const sitename = companyProfile.profile?.data?.name || "";
10
+ const meta_title = companyProfile.profile?.data?.meta_title || "";
11
+ const meta_description = companyProfile.profile?.data?.meta_description || "";
12
+ const robots = companyProfile.profile?.data?.robots || "";
13
+ let websiteurl = "";
14
+ if (process.server) {
15
+ const event = useRequestEvent();
16
+ websiteurl = getRequestURL(event).origin;
17
+ } else {
18
+ websiteurl = window.location.origin;
19
+ }
7
20
  useHead({
21
+ meta: [
22
+ {
23
+ name: "robots",
24
+ content: robots
25
+ }
26
+ ],
8
27
  script: [
9
28
  {
10
29
  children: `
@@ -17,6 +36,26 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
17
36
  },
18
37
  {
19
38
  children: `${tiktok}`
39
+ },
40
+ {
41
+ children: `${facebookMeta}`
42
+ },
43
+ {
44
+ type: "application/ld+json",
45
+ children: JSON.stringify({
46
+ "@context": "https://schema.org",
47
+ "@type": "WebSite",
48
+ "url": "https://www.example.com",
49
+ "name": sitename,
50
+ "alternateName": meta_title,
51
+ "description": meta_description,
52
+ "inLanguage": "en",
53
+ "potentialAction": {
54
+ "@type": "SearchAction",
55
+ "target": `${websiteurl}/search?search={search_term_string}`,
56
+ "query-input": "required name=search_term_string"
57
+ }
58
+ })
20
59
  }
21
60
  ]
22
61
  });
@@ -1,17 +1,17 @@
1
+ import { useRuntimeConfig } from "#imports";
1
2
  import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
2
- import { $fetch } from "ofetch";
3
3
  export default defineEventHandler(async (event) => {
4
4
  const slug = getRouterParam(event, "slug");
5
5
  const body = await readBody(event);
6
6
  try {
7
- const productResponse = await $fetch(`${process.env.FLOWRIX_API_BASE}cart/relatedproducts`, {
8
- method: "POST",
9
- headers: {
10
- "x-public-key": process.env.FLOWRIX_API_KEY,
11
- "Origin": process.env.FLOWRIX_API_ORIGIN
12
- },
13
- body
14
- });
7
+ const config = useRuntimeConfig();
8
+ const productResponse = await flowrixApi.post(
9
+ `cart/relatedproducts`,
10
+ config,
11
+ {
12
+ body
13
+ }
14
+ );
15
15
  return productResponse;
16
16
  } catch (error) {
17
17
  setResponseStatus(event, 500);
@@ -1,17 +1,17 @@
1
+ import { useRuntimeConfig } from "#imports";
1
2
  import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
2
- import { $fetch } from "ofetch";
3
3
  export default defineEventHandler(async (event) => {
4
4
  const slug = getRouterParam(event, "slug");
5
5
  const body = await readBody(event);
6
6
  try {
7
- const productResponse = await $fetch(`${process.env.FLOWRIX_API_BASE}cart/remove`, {
8
- method: "POST",
9
- headers: {
10
- "x-public-key": process.env.FLOWRIX_API_KEY,
11
- "Origin": process.env.FLOWRIX_API_ORIGIN
12
- },
13
- body
14
- });
7
+ const config = useRuntimeConfig();
8
+ const productResponse = await flowrixApi.post(
9
+ `cart/remove`,
10
+ config,
11
+ {
12
+ body
13
+ }
14
+ );
15
15
  return productResponse;
16
16
  } catch (error) {
17
17
  setResponseStatus(event, 500);
@@ -3,6 +3,8 @@ import { flowrixApi } from "../middleware/flowrix.js";
3
3
  import { useCheckoutStore } from "./Checkout.js";
4
4
  import { useRuntimeConfig } from "#imports";
5
5
  import { GTM_add_to_cart, GTM_remove_from_cart } from "../composables/useDataLayer.js";
6
+ import { META_add_to_cart, META_remove_from_cart } from "../composables/useMetaLayer.js";
7
+ import { TikTok_add_to_cart, TikTok_remove_from_cart } from "../composables/useTikTokDatalayer.js";
6
8
  export const useCartStore = defineStore("cart", {
7
9
  state: () => ({
8
10
  cart: {},
@@ -82,6 +84,8 @@ export const useCartStore = defineStore("cart", {
82
84
  };
83
85
  this.lastitem = response?.data.lastitem;
84
86
  GTM_add_to_cart(response?.data.lastitem);
87
+ META_add_to_cart(response?.data.lastitem);
88
+ TikTok_add_to_cart(response?.data.lastitem);
85
89
  useCheckoutStore().saveToCheckoutSession({
86
90
  cart: response?.data,
87
91
  calculations: response?.data.calculations,
@@ -182,9 +186,11 @@ export const useCartStore = defineStore("cart", {
182
186
  if (qty < product.qty) {
183
187
  GTM_remove_from_cart(this.lastitem);
184
188
  META_remove_from_cart(this.lastitem);
189
+ TikTok_remove_from_cart(this.lastitem);
185
190
  } else {
186
191
  GTM_add_to_cart(this.lastitem);
187
192
  META_add_to_cart(this.lastitem);
193
+ TikTok_add_to_cart(this.lastitem);
188
194
  }
189
195
  useCheckoutStore().saveToCheckoutSession({
190
196
  cart: response.data.cart,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowrix",
3
- "version": "1.0.1-beta.101",
3
+ "version": "1.0.1-beta.103",
4
4
  "description": "Plug-and-play Nuxt eCommerce cart powered by FLOWRiX. Subscription required.",
5
5
  "license": "MIT",
6
6
  "type": "module",