cloudcommerce 0.37.0 → 0.37.1
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/.github/workflows/test-apps.yml +2 -2
- package/.gitmodules +0 -3
- package/.vscode/settings.json +0 -1
- package/CHANGELOG.md +14 -0
- package/action.yml +2 -2
- package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
- package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
- package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/barra-doce/package.json +2 -2
- package/package.json +2 -2
- package/packages/api/package.json +1 -1
- package/packages/apps/affilate-program/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/package.json +1 -1
- package/packages/apps/fb-conversions/package.json +1 -1
- package/packages/apps/flash-courier/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/galaxpay/package.json +1 -1
- package/packages/apps/google-analytics/package.json +1 -1
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/mandae/package.json +1 -1
- package/packages/apps/melhor-envio/package.json +1 -1
- package/packages/apps/mercadopago/package.json +1 -1
- package/packages/apps/pagarme/package.json +1 -1
- package/packages/apps/pagarme-v5/package.json +1 -1
- package/packages/apps/paghiper/package.json +1 -1
- package/packages/apps/pix/package.json +1 -1
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/apps/webhooks/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +1 -1
- package/packages/eslint/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/feeds/package.json +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/package.json +3 -3
- package/packages/storefront/src/helpers/sf-utils.ts +8 -5
- package/packages/storefront/src/lib/composables/use-search-modal.ts +30 -26
- package/packages/storefront/src/lib/composables/use-shop-header.ts +69 -1
- package/packages/storefront/src/lib/state/search-engine.ts +20 -4
- package/packages/storefront/src/lib/state/use-analytics.ts +27 -11
- package/packages/test-base/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/ecomplus-stores/monocard/.devcontainer/devcontainer.json +0 -30
- package/ecomplus-stores/monocard/.editorconfig +0 -13
- package/ecomplus-stores/monocard/.eslintrc.cjs +0 -3
- package/ecomplus-stores/monocard/.firebaserc +0 -5
- package/ecomplus-stores/monocard/.github/build-and-deploy +0 -1
- package/ecomplus-stores/monocard/.github/renovate.json +0 -5
- package/ecomplus-stores/monocard/.github/workflows/build-and-deploy.yml +0 -37
- package/ecomplus-stores/monocard/.github/workflows/calibreapp-image-actions.yml +0 -23
- package/ecomplus-stores/monocard/.gitpod.yml +0 -12
- package/ecomplus-stores/monocard/.idx/dev.nix +0 -24
- package/ecomplus-stores/monocard/.nvmrc +0 -1
- package/ecomplus-stores/monocard/.vscode/extensions.json +0 -8
- package/ecomplus-stores/monocard/.vscode/launch.json +0 -11
- package/ecomplus-stores/monocard/.vscode/settings.json +0 -13
- package/ecomplus-stores/monocard/LICENSE.md +0 -230
- package/ecomplus-stores/monocard/README.md +0 -31
- package/ecomplus-stores/monocard/SETUP.md +0 -129
- package/ecomplus-stores/monocard/SETUP.pt-BR.md +0 -129
- package/ecomplus-stores/monocard/functions/config.json +0 -3
- package/ecomplus-stores/monocard/functions/example.env +0 -10
- package/ecomplus-stores/monocard/functions/many/index.js +0 -14
- package/ecomplus-stores/monocard/functions/many/package.json +0 -22
- package/ecomplus-stores/monocard/functions/ssr/.eslintrc.cjs +0 -6
- package/ecomplus-stores/monocard/functions/ssr/astro.config.mjs +0 -4
- package/ecomplus-stores/monocard/functions/ssr/content/blog/.gitkeep +0 -0
- package/ecomplus-stores/monocard/functions/ssr/content/extra-pages/terms.json +0 -11
- package/ecomplus-stores/monocard/functions/ssr/content/extra-pages/trocas.json +0 -11
- package/ecomplus-stores/monocard/functions/ssr/content/layout.json +0 -52
- package/ecomplus-stores/monocard/functions/ssr/content/pages/home.json +0 -20
- package/ecomplus-stores/monocard/functions/ssr/content/pages/products.json +0 -18
- package/ecomplus-stores/monocard/functions/ssr/content/settings.json +0 -78
- package/ecomplus-stores/monocard/functions/ssr/index.js +0 -18
- package/ecomplus-stores/monocard/functions/ssr/package.json +0 -36
- package/ecomplus-stores/monocard/functions/ssr/public/admin/.gitkeep +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/assets/lotties/img_1.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/assets/lotties/img_1.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/assets/lotties/phone-nfc.json +0 -1
- package/ecomplus-stores/monocard/functions/ssr/public/img/icon.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/large-icon.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/card-phone.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/devices.jpg +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/ecom-icon.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/edit-suit.jpg +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/favicon.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/icon.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/large-icon.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo-arcelor-mittal.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo-azul.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo-banco-pan.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo-brinks.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo-mastercard.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo-pfizer.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo-prudential.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo-unimed.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/logo.webp +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/mockup-editar.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/og-image.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/padronagem-tilada.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/qrcode-camera.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/img/uploads/sua-logo-aqui.png +0 -0
- package/ecomplus-stores/monocard/functions/ssr/public/robots.txt +0 -6
- package/ecomplus-stores/monocard/functions/ssr/scripts/build.sh +0 -14
- package/ecomplus-stores/monocard/functions/ssr/src/assets/card.css +0 -99
- package/ecomplus-stores/monocard/functions/ssr/src/assets/style.css +0 -79
- package/ecomplus-stores/monocard/functions/ssr/src/components/AccountMenu.vue +0 -97
- package/ecomplus-stores/monocard/functions/ssr/src/components/AccountPage.vue +0 -62
- package/ecomplus-stores/monocard/functions/ssr/src/components/Banner.vue +0 -59
- package/ecomplus-stores/monocard/functions/ssr/src/components/BannersGrid.astro +0 -25
- package/ecomplus-stores/monocard/functions/ssr/src/components/Breadcrumbs.astro +0 -44
- package/ecomplus-stores/monocard/functions/ssr/src/components/CartItem.vue +0 -64
- package/ecomplus-stores/monocard/functions/ssr/src/components/CartSidebar.vue +0 -69
- package/ecomplus-stores/monocard/functions/ssr/src/components/CasesGrid.astro +0 -49
- package/ecomplus-stores/monocard/functions/ssr/src/components/CheckoutPage.vue +0 -33
- package/ecomplus-stores/monocard/functions/ssr/src/components/Collapse.vue +0 -19
- package/ecomplus-stores/monocard/functions/ssr/src/components/DemoVideo.vue +0 -10
- package/ecomplus-stores/monocard/functions/ssr/src/components/DocDescription.vue +0 -28
- package/ecomplus-stores/monocard/functions/ssr/src/components/FeatureTabs.vue +0 -286
- package/ecomplus-stores/monocard/functions/ssr/src/components/FeaturesSection.astro +0 -28
- package/ecomplus-stores/monocard/functions/ssr/src/components/FooterStamps.vue +0 -63
- package/ecomplus-stores/monocard/functions/ssr/src/components/ImagesGallery.vue +0 -154
- package/ecomplus-stores/monocard/functions/ssr/src/components/LoginForm.vue +0 -107
- package/ecomplus-stores/monocard/functions/ssr/src/components/LottiePhoneNFC.vue +0 -20
- package/ecomplus-stores/monocard/functions/ssr/src/components/MonocardCustomizer.vue +0 -261
- package/ecomplus-stores/monocard/functions/ssr/src/components/PitchBar.vue +0 -61
- package/ecomplus-stores/monocard/functions/ssr/src/components/Prices.vue +0 -95
- package/ecomplus-stores/monocard/functions/ssr/src/components/ProductCard.vue +0 -117
- package/ecomplus-stores/monocard/functions/ssr/src/components/ProductDetails.vue +0 -122
- package/ecomplus-stores/monocard/functions/ssr/src/components/ProductShelf.vue +0 -57
- package/ecomplus-stores/monocard/functions/ssr/src/components/ProductSpecifications.vue +0 -42
- package/ecomplus-stores/monocard/functions/ssr/src/components/SearchModal.vue +0 -6
- package/ecomplus-stores/monocard/functions/ssr/src/components/ShopFooter.vue +0 -71
- package/ecomplus-stores/monocard/functions/ssr/src/components/ShopHeader.vue +0 -137
- package/ecomplus-stores/monocard/functions/ssr/src/components/ShopHeaderMenu.vue +0 -92
- package/ecomplus-stores/monocard/functions/ssr/src/components/ShopSidenav.vue +0 -64
- package/ecomplus-stores/monocard/functions/ssr/src/components/ShopSidenavCategory.vue +0 -77
- package/ecomplus-stores/monocard/functions/ssr/src/components/SkuSelector.vue +0 -58
- package/ecomplus-stores/monocard/functions/ssr/src/env.d.ts +0 -13
- package/ecomplus-stores/monocard/functions/ssr/src/layouts/Base.astro +0 -15
- package/ecomplus-stores/monocard/functions/ssr/src/layouts/PageFooter.astro +0 -53
- package/ecomplus-stores/monocard/functions/ssr/src/layouts/PageHeader.astro +0 -35
- package/ecomplus-stores/monocard/functions/ssr/src/main/Fallback.astro +0 -10
- package/ecomplus-stores/monocard/functions/ssr/src/main/Home.astro +0 -95
- package/ecomplus-stores/monocard/functions/ssr/src/main/Sections.astro +0 -52
- package/ecomplus-stores/monocard/functions/ssr/src/main/Wildcard.astro +0 -18
- package/ecomplus-stores/monocard/functions/ssr/src/pages/[...slug].astro +0 -42
- package/ecomplus-stores/monocard/functions/ssr/src/pages/_vue.ts +0 -10
- package/ecomplus-stores/monocard/functions/ssr/src/pages/app/account.astro +0 -34
- package/ecomplus-stores/monocard/functions/ssr/src/pages/app/index.astro +0 -62
- package/ecomplus-stores/monocard/functions/ssr/src/pages/comprar/index.astro +0 -52
- package/ecomplus-stores/monocard/functions/ssr/src/pages/index.astro +0 -32
- package/ecomplus-stores/monocard/functions/ssr/src/pages/~fallback.astro +0 -23
- package/ecomplus-stores/monocard/functions/ssr/src/scripts/InlineScripts.astro +0 -10
- package/ecomplus-stores/monocard/functions/ssr/tailwind.config.cjs +0 -18
- package/ecomplus-stores/monocard/functions/ssr/tsconfig.json +0 -12
- package/ecomplus-stores/monocard/functions/ssr/uno.config.cjs +0 -5
- package/ecomplus-stores/monocard/functions/with-apps/index.js +0 -12
- package/ecomplus-stores/monocard/functions/with-apps/package.json +0 -22
- package/ecomplus-stores/monocard/package.json +0 -31
- package/ecomplus-stores/monocard/scripts/install.sh +0 -24
|
@@ -3,13 +3,9 @@ import type {
|
|
|
3
3
|
Brands,
|
|
4
4
|
Collections,
|
|
5
5
|
} from '@cloudcommerce/api/types';
|
|
6
|
-
import type { Orama } from '@orama/orama';
|
|
7
6
|
import { ref, watch, toRef } from 'vue';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
search as oramaSearch,
|
|
11
|
-
insert as oramaInsert,
|
|
12
|
-
} from '@orama/orama';
|
|
7
|
+
import Wade from 'wade';
|
|
8
|
+
import { clearAccents } from '@@sf/sf-lib';
|
|
13
9
|
import { SearchEngine, searchHistory } from '@@sf/state/search-engine';
|
|
14
10
|
|
|
15
11
|
export interface Props {
|
|
@@ -18,36 +14,37 @@ export interface Props {
|
|
|
18
14
|
productsLimit?: number;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
const oramaDocSchema = {
|
|
22
|
-
name: 'string',
|
|
23
|
-
slug: 'string',
|
|
24
|
-
short_description: 'string',
|
|
25
|
-
} as const;
|
|
26
|
-
const oramaDocs: Array<{ [k:string]:any } & { name: string, slug: string }> = [];
|
|
27
17
|
const storefrontData = globalThis.$storefront.data as {
|
|
28
18
|
categories?: Array<Partial<Categories>>,
|
|
29
19
|
brands?: Array<Partial<Brands>>,
|
|
30
20
|
collections?: Array<Partial<Collections>>,
|
|
31
21
|
};
|
|
22
|
+
const wadeDocs: Array<{
|
|
23
|
+
text: string,
|
|
24
|
+
type: 'categories' | 'brands' | 'collections' | 'blog',
|
|
25
|
+
data: Record<string, any> & { name: string, slug: string },
|
|
26
|
+
}> = [];
|
|
32
27
|
(['categories', 'brands', 'collections'] as const).forEach((resource) => {
|
|
33
28
|
const docsList = storefrontData[resource];
|
|
34
29
|
if (docsList) {
|
|
35
30
|
for (let i = 0; i < docsList.length; i++) {
|
|
36
31
|
const doc = docsList[i];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
if (doc.name && doc.slug) {
|
|
33
|
+
wadeDocs.push({
|
|
34
|
+
text: clearAccents(`${doc.name} ${(doc as Categories).short_description}`),
|
|
35
|
+
type: resource,
|
|
36
|
+
data: doc as typeof wadeDocs[number]['data'],
|
|
37
|
+
});
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
});
|
|
44
|
-
let
|
|
45
|
-
if (
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})();
|
|
42
|
+
let wadeSearch: ((t: string) => { index: number, score: number }[]) | undefined;
|
|
43
|
+
if (wadeDocs.length) {
|
|
44
|
+
if (globalThis.$storefront.settings.lang === 'pt_br') {
|
|
45
|
+
Wade.config.stopWords = ['e', 'a', 'o', 'de', 'para', 'com', 'tem'];
|
|
46
|
+
}
|
|
47
|
+
wadeSearch = Wade(wadeDocs.map(({ text }) => text));
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
export const useSearchModal = (props: Props) => {
|
|
@@ -61,9 +58,10 @@ export const useSearchModal = (props: Props) => {
|
|
|
61
58
|
const linkHits = ref<Array<{ title: string, href: string }>>([]);
|
|
62
59
|
watch(toRef(props, 'term'), async (term) => {
|
|
63
60
|
searchEngine.fetch(term);
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
linkHits.value =
|
|
61
|
+
if (wadeSearch) {
|
|
62
|
+
const wadeResults = wadeSearch(clearAccents(term));
|
|
63
|
+
linkHits.value = wadeResults.map(({ index }) => {
|
|
64
|
+
const { name, slug } = wadeDocs[index].data;
|
|
67
65
|
return { title: name, href: `/${slug}` };
|
|
68
66
|
});
|
|
69
67
|
}
|
|
@@ -73,8 +71,14 @@ export const useSearchModal = (props: Props) => {
|
|
|
73
71
|
watch(searchEngine.meta, () => {
|
|
74
72
|
productCount.value = searchEngine.meta.count || 0;
|
|
75
73
|
});
|
|
74
|
+
const filteredHistory = ref<string[]>([]);
|
|
75
|
+
watch(searchHistory, () => {
|
|
76
|
+
filteredHistory.value = searchHistory.filter((term) => term !== props.term);
|
|
77
|
+
}, {
|
|
78
|
+
immediate: true,
|
|
79
|
+
});
|
|
76
80
|
return {
|
|
77
|
-
searchHistory,
|
|
81
|
+
searchHistory: filteredHistory,
|
|
78
82
|
searchEngine,
|
|
79
83
|
isFetching: searchEngine.isFetching,
|
|
80
84
|
productHits: searchEngine.products,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { Ref } from 'vue';
|
|
2
2
|
import type { Categories } from '@cloudcommerce/api/types';
|
|
3
|
-
import { computed } from 'vue';
|
|
3
|
+
import { ref, computed, watch } from 'vue';
|
|
4
|
+
import { watchOnce } from '@vueuse/core';
|
|
5
|
+
import { totalItems } from '@@sf/state/shopping-cart';
|
|
4
6
|
import useStickyHeader from '@@sf/composables/use-sticky-header';
|
|
5
7
|
|
|
6
8
|
type PartCategory = Partial<Categories>;
|
|
7
9
|
|
|
8
10
|
export interface Props {
|
|
9
11
|
header: Ref<HTMLElement | null>;
|
|
12
|
+
searchInput?: Ref<HTMLInputElement | null>;
|
|
10
13
|
categories?: PartCategory[];
|
|
11
14
|
menuCategorySlugs?: string[];
|
|
12
15
|
menuRandomCategories?: number;
|
|
@@ -78,6 +81,7 @@ const filterSubcategories = (
|
|
|
78
81
|
const useShopHeader = (props: Props) => {
|
|
79
82
|
const {
|
|
80
83
|
header,
|
|
84
|
+
searchInput,
|
|
81
85
|
categories = (globalThis.$storefront.data.categories || []) as PartCategory[],
|
|
82
86
|
menuCategorySlugs,
|
|
83
87
|
menuRandomCategories = 7,
|
|
@@ -120,6 +124,61 @@ const useShopHeader = (props: Props) => {
|
|
|
120
124
|
}
|
|
121
125
|
return false;
|
|
122
126
|
});
|
|
127
|
+
|
|
128
|
+
const isSearchOpen = ref(false);
|
|
129
|
+
const isSearchOpenOnce = ref(false);
|
|
130
|
+
watchOnce(isSearchOpen, () => {
|
|
131
|
+
isSearchOpenOnce.value = true;
|
|
132
|
+
});
|
|
133
|
+
const searchTerm = ref('');
|
|
134
|
+
const isSearchPage = !import.meta.env.SSR && window.location.pathname === '/s';
|
|
135
|
+
const urlSearchQ = isSearchPage
|
|
136
|
+
? new URLSearchParams(window.location.search).get('q')
|
|
137
|
+
: undefined;
|
|
138
|
+
if (typeof urlSearchQ === 'string') {
|
|
139
|
+
searchTerm.value = urlSearchQ;
|
|
140
|
+
}
|
|
141
|
+
const quickSearchTerm = computed(() => {
|
|
142
|
+
if (searchTerm.value && searchTerm.value.length >= 2
|
|
143
|
+
&& searchTerm.value !== urlSearchQ) {
|
|
144
|
+
return searchTerm.value;
|
|
145
|
+
}
|
|
146
|
+
return '';
|
|
147
|
+
});
|
|
148
|
+
const toggleSearch = (ev: Event) => {
|
|
149
|
+
if (isSearchOpen.value && searchTerm.value) return;
|
|
150
|
+
ev.preventDefault();
|
|
151
|
+
isSearchOpen.value = !isSearchOpen.value;
|
|
152
|
+
if (isSearchOpen.value && searchInput) {
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
if (!searchInput.value) return;
|
|
155
|
+
const { length } = searchTerm.value;
|
|
156
|
+
searchInput.value.setSelectionRange(length, length);
|
|
157
|
+
searchInput.value.focus();
|
|
158
|
+
}, 50);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const isCartOpen = ref(false);
|
|
162
|
+
const isCartOpenOnce = ref(false);
|
|
163
|
+
watchOnce(isCartOpen, () => {
|
|
164
|
+
isCartOpenOnce.value = true;
|
|
165
|
+
});
|
|
166
|
+
const delayedCartItems = ref(0);
|
|
167
|
+
const handleOnMounted = () => {
|
|
168
|
+
watch(totalItems, (newTotalItems, prevTotalItems) => {
|
|
169
|
+
if (typeof prevTotalItems === 'number') {
|
|
170
|
+
if (prevTotalItems < newTotalItems) {
|
|
171
|
+
isCartOpen.value = true;
|
|
172
|
+
} else if (prevTotalItems && !newTotalItems) {
|
|
173
|
+
isCartOpen.value = false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
delayedCartItems.value = newTotalItems;
|
|
177
|
+
}, {
|
|
178
|
+
immediate: true,
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
|
|
123
182
|
return {
|
|
124
183
|
isSticky,
|
|
125
184
|
staticHeight,
|
|
@@ -130,6 +189,15 @@ const useShopHeader = (props: Props) => {
|
|
|
130
189
|
getCategoryTree,
|
|
131
190
|
categoryTrees,
|
|
132
191
|
inlineMenuTrees,
|
|
192
|
+
isSearchOpen,
|
|
193
|
+
isSearchOpenOnce,
|
|
194
|
+
searchTerm,
|
|
195
|
+
quickSearchTerm,
|
|
196
|
+
toggleSearch,
|
|
197
|
+
isCartOpen,
|
|
198
|
+
isCartOpenOnce,
|
|
199
|
+
cartTotalItems: delayedCartItems,
|
|
200
|
+
handleOnMounted,
|
|
133
201
|
};
|
|
134
202
|
};
|
|
135
203
|
|
|
@@ -8,6 +8,13 @@ const storageKey = 'ecomSeachHistory';
|
|
|
8
8
|
|
|
9
9
|
export const searchHistory = useStorage<string[]>(storageKey, []);
|
|
10
10
|
|
|
11
|
+
for (let i = 0; i < searchHistory.length; i++) {
|
|
12
|
+
if (typeof searchHistory[i] !== 'string') {
|
|
13
|
+
searchHistory.splice(i, 1);
|
|
14
|
+
i -= 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
export const search = async ({
|
|
12
19
|
term,
|
|
13
20
|
params,
|
|
@@ -31,11 +38,20 @@ export const search = async ({
|
|
|
31
38
|
},
|
|
32
39
|
});
|
|
33
40
|
if (response.data.result.length) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
const completeTermIndex = searchHistory.findIndex((_term) => {
|
|
42
|
+
return _term.includes(term) && !(_term.replace(term, '')).includes(' ');
|
|
43
|
+
});
|
|
44
|
+
if (completeTermIndex > -1) {
|
|
45
|
+
const completeTerm = searchHistory[completeTermIndex];
|
|
46
|
+
searchHistory.splice(completeTermIndex, 1);
|
|
47
|
+
searchHistory.unshift(completeTerm);
|
|
48
|
+
} else {
|
|
49
|
+
const termIndex = searchHistory.findIndex((_term) => term.startsWith(_term));
|
|
50
|
+
if (termIndex > -1) {
|
|
51
|
+
searchHistory.splice(termIndex, 1);
|
|
52
|
+
}
|
|
53
|
+
searchHistory.unshift(term);
|
|
37
54
|
}
|
|
38
|
-
searchHistory.unshift(term);
|
|
39
55
|
while (searchHistory.length > 20) {
|
|
40
56
|
searchHistory.pop();
|
|
41
57
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Products, Carts, SearchItem } from '@cloudcommerce/types';
|
|
2
|
+
import { watch } from 'vue';
|
|
2
3
|
import { watchOnce } from '@vueuse/core';
|
|
3
4
|
import { price as getPrice, name as getName } from '@ecomplus/utils';
|
|
4
5
|
import { customer, isLogged } from '@@sf/state/customer-session';
|
|
5
6
|
import { cartEvents } from '@@sf/state/shopping-cart';
|
|
7
|
+
import { searchHistory } from '@@sf/state/search-engine';
|
|
6
8
|
import utm from '@@sf/scripts/session-utm';
|
|
7
9
|
|
|
8
10
|
export const trackingIds: {
|
|
@@ -218,17 +220,6 @@ export const getGtagItem = (product: Partial<Products> | SearchItem | CartItem)
|
|
|
218
220
|
|
|
219
221
|
export const useAnalytics = () => {
|
|
220
222
|
document.addEventListener('astro:beforeload', resetPageViewPromise);
|
|
221
|
-
if (isLogged.value) {
|
|
222
|
-
emitGtagEvent('login', {});
|
|
223
|
-
} else {
|
|
224
|
-
watchOnce(isLogged, () => emitGtagEvent('login', {}));
|
|
225
|
-
}
|
|
226
|
-
cartEvents.on('*', (evName, cartItem) => {
|
|
227
|
-
emitGtagEvent(
|
|
228
|
-
evName === 'addCartItem' ? 'add_to_cart' : 'remove_from_cart',
|
|
229
|
-
{ items: [getGtagItem(cartItem)] },
|
|
230
|
-
);
|
|
231
|
-
});
|
|
232
223
|
const {
|
|
233
224
|
gtag,
|
|
234
225
|
GTAG_TAG_ID,
|
|
@@ -279,6 +270,31 @@ export const useAnalytics = () => {
|
|
|
279
270
|
}
|
|
280
271
|
storage.setItem(`analytics_${key}`, trackingIds[key]);
|
|
281
272
|
});
|
|
273
|
+
if (isLogged.value) {
|
|
274
|
+
emitGtagEvent('login', {});
|
|
275
|
+
} else {
|
|
276
|
+
watchOnce(isLogged, () => emitGtagEvent('login', {}));
|
|
277
|
+
}
|
|
278
|
+
cartEvents.on('*', (evName, cartItem) => {
|
|
279
|
+
emitGtagEvent(
|
|
280
|
+
evName === 'addCartItem' ? 'add_to_cart' : 'remove_from_cart',
|
|
281
|
+
{ items: [getGtagItem(cartItem)] },
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
watch(searchHistory, () => {
|
|
285
|
+
const term = searchHistory[0];
|
|
286
|
+
if (term) {
|
|
287
|
+
emitGtagEvent('search', { search_term: term });
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
if (window.location.pathname === '/s') {
|
|
291
|
+
setTimeout(() => {
|
|
292
|
+
const urlSearchQ = new URLSearchParams(window.location.search).get('q');
|
|
293
|
+
if (urlSearchQ && typeof urlSearchQ === 'string') {
|
|
294
|
+
emitGtagEvent('view_search_results', { search_term: urlSearchQ });
|
|
295
|
+
}
|
|
296
|
+
}, 300);
|
|
297
|
+
}
|
|
282
298
|
};
|
|
283
299
|
|
|
284
300
|
export default useAnalytics;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"postCreateCommand": "npm i && npm i --prefix=functions/ssr",
|
|
3
|
-
"waitFor": "postCreateCommand",
|
|
4
|
-
"portsAttributes": {
|
|
5
|
-
"3000": {
|
|
6
|
-
"label": "Application",
|
|
7
|
-
"onAutoForward": "openPreview"
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
"forwardPorts": [
|
|
11
|
-
3000
|
|
12
|
-
],
|
|
13
|
-
"postAttachCommand": {
|
|
14
|
-
"Server": "npm run dev"
|
|
15
|
-
},
|
|
16
|
-
"customizations": {
|
|
17
|
-
"codespaces": {
|
|
18
|
-
"openFiles": [
|
|
19
|
-
"functions/ssr/src/main/Home.astro"
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
"vscode": {
|
|
23
|
-
"extensions": [
|
|
24
|
-
"astro-build.astro-vscode",
|
|
25
|
-
"vue.volar",
|
|
26
|
-
"bradlc.vscode-tailwindcss"
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
name: Build and deploy
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
paths:
|
|
8
|
-
- 'functions/**'
|
|
9
|
-
- 'package-lock.json'
|
|
10
|
-
- '.firebaserc'
|
|
11
|
-
- '.ecomplus/**'
|
|
12
|
-
- '.github/build-and-deploy'
|
|
13
|
-
- '.github/workflows/build-and-deploy.yml'
|
|
14
|
-
pull_request:
|
|
15
|
-
paths:
|
|
16
|
-
- 'functions/ssr/**'
|
|
17
|
-
- '.firebaserc'
|
|
18
|
-
- 'package-lock.json'
|
|
19
|
-
|
|
20
|
-
jobs:
|
|
21
|
-
build-and-deploy:
|
|
22
|
-
name: Cloud Commerce build and deploy
|
|
23
|
-
runs-on: ubuntu-latest
|
|
24
|
-
if: |
|
|
25
|
-
github.event.head_commit.message != 'Initial commit' &&
|
|
26
|
-
!contains(github.event.head_commit.message, '[skip ci]')
|
|
27
|
-
steps:
|
|
28
|
-
- uses: actions/checkout@v3
|
|
29
|
-
with:
|
|
30
|
-
fetch-depth: 0
|
|
31
|
-
- uses: ecomplus/cloud-commerce@main
|
|
32
|
-
with:
|
|
33
|
-
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
34
|
-
firebase-service-account: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
|
|
35
|
-
ecom-authentication-id: ${{ secrets.ECOM_AUTHENTICATION_ID }}
|
|
36
|
-
ecom-api-key: ${{ secrets.ECOM_API_KEY }}
|
|
37
|
-
ecom-store-id: ${{ secrets.ECOM_STORE_ID }}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: Compress images
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
paths:
|
|
6
|
-
- '**.jpg'
|
|
7
|
-
- '**.jpeg'
|
|
8
|
-
- '**.png'
|
|
9
|
-
- '**.webp'
|
|
10
|
-
- 'package-lock.json'
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
build:
|
|
14
|
-
# Only run on Pull Requests within the same repository, and not from forks.
|
|
15
|
-
if: github.event.pull_request.head.repo.full_name == github.repository
|
|
16
|
-
name: calibreapp/image-actions
|
|
17
|
-
runs-on: ubuntu-latest
|
|
18
|
-
steps:
|
|
19
|
-
- uses: actions/checkout@v3
|
|
20
|
-
- name: Compress images
|
|
21
|
-
uses: calibreapp/image-actions@main
|
|
22
|
-
with:
|
|
23
|
-
githubToken: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{pkgs}: {
|
|
2
|
-
channel = "stable-23.05"; # "stable-23.05" or "unstable"
|
|
3
|
-
packages = [
|
|
4
|
-
pkgs.nodejs_18
|
|
5
|
-
pkgs.nodePackages.firebase-tools
|
|
6
|
-
];
|
|
7
|
-
idx.extensions = [
|
|
8
|
-
"vue.volar"
|
|
9
|
-
# Other recommended extensions crashing launch
|
|
10
|
-
# "dbaeumer.vscode-eslint",
|
|
11
|
-
# "astro-build.astro-vscode",
|
|
12
|
-
# "bradlc.vscode-tailwindcss",
|
|
13
|
-
];
|
|
14
|
-
idx.previews = {
|
|
15
|
-
enable = true;
|
|
16
|
-
previews = [
|
|
17
|
-
{
|
|
18
|
-
command = ["npm" "run" "dev" "--" "--port" "$PORT" "--host"];
|
|
19
|
-
manager = "web";
|
|
20
|
-
id = "web";
|
|
21
|
-
}
|
|
22
|
-
];
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
18
|