@magento/venia-pwa-live-search 1.0.0-alpha10
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/package.json +31 -0
- package/postcss.config.js +3 -0
- package/src/api/fragments.js +193 -0
- package/src/api/graphql.js +26 -0
- package/src/api/mutations.js +94 -0
- package/src/api/queries.js +225 -0
- package/src/api/search.js +222 -0
- package/src/components/AddToCartButton/AddToCartButton.jsx +32 -0
- package/src/components/AddToCartButton/AddToCartButton.stories.mdx +14 -0
- package/src/components/AddToCartButton/index.js +10 -0
- package/src/components/Alert/Alert.jsx +155 -0
- package/src/components/Alert/index.js +11 -0
- package/src/components/Breadcrumbs/Breadcrumbs.jsx +34 -0
- package/src/components/Breadcrumbs/MockPages.js +14 -0
- package/src/components/Breadcrumbs/index.js +11 -0
- package/src/components/ButtonShimmer/ButtonShimmer.css +32 -0
- package/src/components/ButtonShimmer/ButtonShimmer.jsx +23 -0
- package/src/components/ButtonShimmer/index.js +11 -0
- package/src/components/CategoryFilters/CategoryFilters.jsx +59 -0
- package/src/components/CategoryFilters/index.js +10 -0
- package/src/components/Facets/Facets.jsx +50 -0
- package/src/components/Facets/Range/RangeFacet.js +20 -0
- package/src/components/Facets/Scalar/ScalarFacet.js +29 -0
- package/src/components/Facets/SelectedFilters.js +80 -0
- package/src/components/Facets/format.js +52 -0
- package/src/components/Facets/index.js +14 -0
- package/src/components/Facets/mocks.js +119 -0
- package/src/components/FacetsShimmer/FacetsShimmer.css +49 -0
- package/src/components/FacetsShimmer/FacetsShimmer.jsx +25 -0
- package/src/components/FacetsShimmer/index.js +11 -0
- package/src/components/FilterButton/FilterButton.jsx +40 -0
- package/src/components/FilterButton/index.js +11 -0
- package/src/components/ImageCarousel/Image.jsx +34 -0
- package/src/components/ImageCarousel/ImageCarousel.jsx +103 -0
- package/src/components/ImageCarousel/index.js +11 -0
- package/src/components/InputButtonGroup/InputButtonGroup.jsx +120 -0
- package/src/components/InputButtonGroup/index.js +11 -0
- package/src/components/LabelledInput/LabelledInput.jsx +51 -0
- package/src/components/LabelledInput/index.js +11 -0
- package/src/components/Loading/Loading.jsx +32 -0
- package/src/components/Loading/index.js +11 -0
- package/src/components/NoResults/NoResults.jsx +55 -0
- package/src/components/NoResults/index.js +11 -0
- package/src/components/Pagination/Pagination.jsx +105 -0
- package/src/components/Pagination/index.js +10 -0
- package/src/components/PerPagePicker/PerPagePicker.jsx +114 -0
- package/src/components/PerPagePicker/index.js +11 -0
- package/src/components/Pill/Pill.jsx +34 -0
- package/src/components/Pill/index.js +11 -0
- package/src/components/Pill/mock.js +23 -0
- package/src/components/ProductCardShimmer/ProductCardShimmer.css +72 -0
- package/src/components/ProductCardShimmer/ProductCardShimmer.jsx +28 -0
- package/src/components/ProductCardShimmer/index.js +11 -0
- package/src/components/ProductItem/MockData.js +508 -0
- package/src/components/ProductItem/ProductItem.css +84 -0
- package/src/components/ProductItem/ProductItem.jsx +347 -0
- package/src/components/ProductItem/ProductPrice.jsx +181 -0
- package/src/components/ProductItem/index.js +11 -0
- package/src/components/ProductList/MockData.js +190 -0
- package/src/components/ProductList/ProductList.jsx +127 -0
- package/src/components/ProductList/index.js +11 -0
- package/src/components/ProductList/product-list.css +18 -0
- package/src/components/SearchBar/SearchBar.jsx +33 -0
- package/src/components/SearchBar/index.js +11 -0
- package/src/components/Shimmer/Shimmer.css +82 -0
- package/src/components/Shimmer/Shimmer.jsx +66 -0
- package/src/components/Shimmer/index.js +11 -0
- package/src/components/Slider/Slider.css +61 -0
- package/src/components/Slider/Slider.jsx +103 -0
- package/src/components/Slider/index.jsx +11 -0
- package/src/components/SliderDoubleControl/SliderDoubleControl.css +83 -0
- package/src/components/SliderDoubleControl/SliderDoubleControl.jsx +220 -0
- package/src/components/SliderDoubleControl/index.js +11 -0
- package/src/components/SortDropdown/SortDropdown.jsx +126 -0
- package/src/components/SortDropdown/index.js +11 -0
- package/src/components/SwatchButton/SwatchButton.jsx +72 -0
- package/src/components/SwatchButton/index.js +11 -0
- package/src/components/SwatchButtonGroup/SwatchButtonGroup.jsx +86 -0
- package/src/components/SwatchButtonGroup/index.js +11 -0
- package/src/components/ViewSwitcher/ViewSwitcher.jsx +46 -0
- package/src/components/ViewSwitcher/index.js +11 -0
- package/src/components/WishlistButton/WishlistButton.jsx +67 -0
- package/src/components/WishlistButton/index.js +11 -0
- package/src/containers/App.jsx +145 -0
- package/src/containers/LiveSearchPLPLoader.jsx +24 -0
- package/src/containers/LiveSearchPopoverLoader.jsx +190 -0
- package/src/containers/LiveSearchSRLPLoader.jsx +24 -0
- package/src/containers/ProductListingPage.jsx +66 -0
- package/src/containers/ProductsContainer.jsx +145 -0
- package/src/containers/ProductsHeader.jsx +123 -0
- package/src/context/attributeMetadata.js +63 -0
- package/src/context/cart.js +97 -0
- package/src/context/displayChange.js +90 -0
- package/src/context/events.js +160 -0
- package/src/context/index.js +19 -0
- package/src/context/products.jsx +336 -0
- package/src/context/resultsModifierContext.js +35 -0
- package/src/context/search.jsx +127 -0
- package/src/context/store.jsx +93 -0
- package/src/context/translation.jsx +125 -0
- package/src/context/widgetConfig.jsx +120 -0
- package/src/context/wishlist.jsx +97 -0
- package/src/hooks/eventing/useEventListener.js +13 -0
- package/src/hooks/eventing/useLocation.js +21 -0
- package/src/hooks/eventing/useMagentoExtensionContext.js +28 -0
- package/src/hooks/eventing/usePageView.js +36 -0
- package/src/hooks/eventing/useShopperContext.js +33 -0
- package/src/hooks/eventing/useStorefrontInstanceContext.js +46 -0
- package/src/hooks/eventing/useViewedOffsets.js +74 -0
- package/src/hooks/useAccessibleDropdown.js +148 -0
- package/src/hooks/useLiveSearchPLPConfig.js +112 -0
- package/src/hooks/useLiveSearchPopoverConfig.js +83 -0
- package/src/hooks/useLiveSearchSRLPConfig.js +97 -0
- package/src/hooks/usePagination.js +83 -0
- package/src/hooks/useRangeFacet.js +62 -0
- package/src/hooks/useScalarFacet.js +61 -0
- package/src/hooks/useSliderFacet.js +43 -0
- package/src/i18n/Sorani.js +60 -0
- package/src/i18n/ar_AE.js +60 -0
- package/src/i18n/bg_BG.js +60 -0
- package/src/i18n/bn_IN.js +60 -0
- package/src/i18n/ca_ES.js +60 -0
- package/src/i18n/cs_CZ.js +60 -0
- package/src/i18n/da_DK.js +60 -0
- package/src/i18n/de_DE.js +60 -0
- package/src/i18n/el_GR.js +60 -0
- package/src/i18n/en_GA.js +60 -0
- package/src/i18n/en_GB.js +60 -0
- package/src/i18n/en_US.js +70 -0
- package/src/i18n/es_ES.js +60 -0
- package/src/i18n/et_EE.js +60 -0
- package/src/i18n/eu_ES.js +60 -0
- package/src/i18n/fa_IR.js +60 -0
- package/src/i18n/fi_FI.js +60 -0
- package/src/i18n/fr_FR.js +60 -0
- package/src/i18n/gl_ES.js +60 -0
- package/src/i18n/hi_IN.js +60 -0
- package/src/i18n/hu_HU.js +60 -0
- package/src/i18n/hy_AM.js +60 -0
- package/src/i18n/id_ID.js +60 -0
- package/src/i18n/index.js +89 -0
- package/src/i18n/it_IT.js +60 -0
- package/src/i18n/ja_JP.js +60 -0
- package/src/i18n/ko_KR.js +60 -0
- package/src/i18n/lt_LT.js +60 -0
- package/src/i18n/lv_LV.js +60 -0
- package/src/i18n/nb_NO.js +60 -0
- package/src/i18n/nl_NL.js +60 -0
- package/src/i18n/pt_BR.js +60 -0
- package/src/i18n/pt_PT.js +60 -0
- package/src/i18n/ro_RO.js +60 -0
- package/src/i18n/ru_RU.js +60 -0
- package/src/i18n/sv_SE.js +60 -0
- package/src/i18n/th_TH.js +60 -0
- package/src/i18n/tr_TR.js +60 -0
- package/src/i18n/zh_Hans_CN.js +60 -0
- package/src/i18n/zh_Hant_TW.js +60 -0
- package/src/icons/NoImage.svg +1 -0
- package/src/icons/adjustments.svg +3 -0
- package/src/icons/cart.svg +3 -0
- package/src/icons/checkmark.svg +3 -0
- package/src/icons/chevron.svg +3 -0
- package/src/icons/emptyHeart.svg +3 -0
- package/src/icons/error.svg +3 -0
- package/src/icons/filledHeart.svg +3 -0
- package/src/icons/filter.svg +29 -0
- package/src/icons/gridView.svg +11 -0
- package/src/icons/info.svg +3 -0
- package/src/icons/listView.svg +5 -0
- package/src/icons/loading.svg +6 -0
- package/src/icons/plus.svg +4 -0
- package/src/icons/sort.svg +18 -0
- package/src/icons/warning.svg +3 -0
- package/src/icons/x.svg +3 -0
- package/src/index.jsx +65 -0
- package/src/queries/customerGroupCode.gql.js +10 -0
- package/src/queries/eventing/getMagentoExtensionContext.gql.js +13 -0
- package/src/queries/eventing/getPageType.gql.js +14 -0
- package/src/queries/eventing/getStorefrontContext.gql.js +27 -0
- package/src/queries/index.js +3 -0
- package/src/queries/liveSearchPlpConfigs.gql.js +30 -0
- package/src/queries/liveSearchPopoverConfigs.gql.js +28 -0
- package/src/styles/autocomplete.module.css +56 -0
- package/src/styles/index.css +1638 -0
- package/src/styles/searchBar.module.css +119 -0
- package/src/styles/tokens.css +99 -0
- package/src/targets/intercept.js +21 -0
- package/src/utils/constants.js +26 -0
- package/src/utils/decodeHtmlString.js +13 -0
- package/src/utils/dom.js +14 -0
- package/src/utils/eventing/getCookie.js +9 -0
- package/src/utils/eventing/usePageTypeFromUrl.js +26 -0
- package/src/utils/getProductImage.js +94 -0
- package/src/utils/getProductPrice.js +83 -0
- package/src/utils/getUserViewHistory.js +27 -0
- package/src/utils/handleUrlFilters.js +164 -0
- package/src/utils/htmlStringDecode.js +13 -0
- package/src/utils/modifyResults.js +164 -0
- package/src/utils/sort.js +95 -0
- package/src/utils/useIntersectionObserver.js +27 -0
- package/src/utils/validateStoreDetails.js +39 -0
- package/src/wrappers/wrapUseApp.js +28 -0
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@magento/venia-pwa-live-search",
|
|
3
|
+
"version": "1.0.0-alpha10",
|
|
4
|
+
"description": "Live Search PWA Studio extension.",
|
|
5
|
+
"main": "src/index.jsx",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": " "
|
|
11
|
+
},
|
|
12
|
+
"repository": "https://github.com/github:magento/pwa-studio",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@adobe/magento-storefront-event-collector": "^1.13.0",
|
|
16
|
+
"@adobe/magento-storefront-events-sdk": "^1.13.0",
|
|
17
|
+
"@magento/pwa-buildpack": "~11.5.3",
|
|
18
|
+
"@magento/storefront-search-as-you-type": "~1.0.4",
|
|
19
|
+
"@magento/venia-ui": "~11.5.0",
|
|
20
|
+
"currency-symbol-map": "^5.1.0",
|
|
21
|
+
"lodash": "^4.17.21"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": "^17.0.2"
|
|
25
|
+
},
|
|
26
|
+
"pwa-studio": {
|
|
27
|
+
"targets": {
|
|
28
|
+
"intercept": "src/targets/intercept"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const Facet = `
|
|
11
|
+
fragment Facet on Aggregation {
|
|
12
|
+
title
|
|
13
|
+
attribute
|
|
14
|
+
buckets {
|
|
15
|
+
title
|
|
16
|
+
__typename
|
|
17
|
+
... on CategoryView {
|
|
18
|
+
name
|
|
19
|
+
count
|
|
20
|
+
path
|
|
21
|
+
}
|
|
22
|
+
... on ScalarBucket {
|
|
23
|
+
count
|
|
24
|
+
}
|
|
25
|
+
... on RangeBucket {
|
|
26
|
+
from
|
|
27
|
+
to
|
|
28
|
+
count
|
|
29
|
+
}
|
|
30
|
+
... on StatsBucket {
|
|
31
|
+
min
|
|
32
|
+
max
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const ProductView = `
|
|
39
|
+
fragment ProductView on ProductSearchItem {
|
|
40
|
+
productView {
|
|
41
|
+
id
|
|
42
|
+
__typename
|
|
43
|
+
sku
|
|
44
|
+
name
|
|
45
|
+
inStock
|
|
46
|
+
url
|
|
47
|
+
urlKey
|
|
48
|
+
images {
|
|
49
|
+
label
|
|
50
|
+
url
|
|
51
|
+
roles
|
|
52
|
+
}
|
|
53
|
+
... on ComplexProductView {
|
|
54
|
+
priceRange {
|
|
55
|
+
maximum {
|
|
56
|
+
final {
|
|
57
|
+
amount {
|
|
58
|
+
value
|
|
59
|
+
currency
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
regular {
|
|
63
|
+
amount {
|
|
64
|
+
value
|
|
65
|
+
currency
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
minimum {
|
|
70
|
+
final {
|
|
71
|
+
amount {
|
|
72
|
+
value
|
|
73
|
+
currency
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
regular {
|
|
77
|
+
amount {
|
|
78
|
+
value
|
|
79
|
+
currency
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
options {
|
|
85
|
+
id
|
|
86
|
+
title
|
|
87
|
+
values {
|
|
88
|
+
title
|
|
89
|
+
... on ProductViewOptionValueSwatch {
|
|
90
|
+
id
|
|
91
|
+
inStock
|
|
92
|
+
type
|
|
93
|
+
value
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
... on SimpleProductView {
|
|
99
|
+
price {
|
|
100
|
+
final {
|
|
101
|
+
amount {
|
|
102
|
+
value
|
|
103
|
+
currency
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
regular {
|
|
107
|
+
amount {
|
|
108
|
+
value
|
|
109
|
+
currency
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
highlights {
|
|
116
|
+
attribute
|
|
117
|
+
value
|
|
118
|
+
matched_words
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
const Product = `
|
|
124
|
+
fragment Product on ProductSearchItem {
|
|
125
|
+
product {
|
|
126
|
+
__typename
|
|
127
|
+
sku
|
|
128
|
+
description {
|
|
129
|
+
html
|
|
130
|
+
}
|
|
131
|
+
short_description {
|
|
132
|
+
html
|
|
133
|
+
}
|
|
134
|
+
name
|
|
135
|
+
canonical_url
|
|
136
|
+
small_image {
|
|
137
|
+
url
|
|
138
|
+
}
|
|
139
|
+
image {
|
|
140
|
+
url
|
|
141
|
+
}
|
|
142
|
+
thumbnail {
|
|
143
|
+
url
|
|
144
|
+
}
|
|
145
|
+
price_range {
|
|
146
|
+
minimum_price {
|
|
147
|
+
fixed_product_taxes {
|
|
148
|
+
amount {
|
|
149
|
+
value
|
|
150
|
+
currency
|
|
151
|
+
}
|
|
152
|
+
label
|
|
153
|
+
}
|
|
154
|
+
regular_price {
|
|
155
|
+
value
|
|
156
|
+
currency
|
|
157
|
+
}
|
|
158
|
+
final_price {
|
|
159
|
+
value
|
|
160
|
+
currency
|
|
161
|
+
}
|
|
162
|
+
discount {
|
|
163
|
+
percent_off
|
|
164
|
+
amount_off
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
maximum_price {
|
|
168
|
+
fixed_product_taxes {
|
|
169
|
+
amount {
|
|
170
|
+
value
|
|
171
|
+
currency
|
|
172
|
+
}
|
|
173
|
+
label
|
|
174
|
+
}
|
|
175
|
+
regular_price {
|
|
176
|
+
value
|
|
177
|
+
currency
|
|
178
|
+
}
|
|
179
|
+
final_price {
|
|
180
|
+
value
|
|
181
|
+
currency
|
|
182
|
+
}
|
|
183
|
+
discount {
|
|
184
|
+
percent_off
|
|
185
|
+
amount_off
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
`;
|
|
192
|
+
|
|
193
|
+
export { Facet, ProductView, Product };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
async function getGraphQL(
|
|
2
|
+
query = '',
|
|
3
|
+
variables = {},
|
|
4
|
+
store = '',
|
|
5
|
+
baseUrl = ''
|
|
6
|
+
) {
|
|
7
|
+
const graphqlEndpoint = baseUrl
|
|
8
|
+
? `${baseUrl}/graphql`
|
|
9
|
+
: `${window.origin}/graphql`;
|
|
10
|
+
|
|
11
|
+
const response = await fetch(graphqlEndpoint, {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
Store: store
|
|
16
|
+
},
|
|
17
|
+
body: JSON.stringify({
|
|
18
|
+
query,
|
|
19
|
+
variables
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return response.json();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { getGraphQL };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const CREATE_EMPTY_CART = `
|
|
2
|
+
mutation createEmptyCart($input: createEmptyCartInput) {
|
|
3
|
+
createEmptyCart(input: $input)
|
|
4
|
+
}
|
|
5
|
+
`;
|
|
6
|
+
|
|
7
|
+
const ADD_TO_CART = `
|
|
8
|
+
mutation addProductsToCart(
|
|
9
|
+
$cartId: String!
|
|
10
|
+
$cartItems: [CartItemInput!]!
|
|
11
|
+
) {
|
|
12
|
+
addProductsToCart(
|
|
13
|
+
cartId: $cartId
|
|
14
|
+
cartItems: $cartItems
|
|
15
|
+
) {
|
|
16
|
+
cart {
|
|
17
|
+
items {
|
|
18
|
+
product {
|
|
19
|
+
name
|
|
20
|
+
sku
|
|
21
|
+
}
|
|
22
|
+
quantity
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
user_errors {
|
|
26
|
+
code
|
|
27
|
+
message
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const ADD_TO_WISHLIST = `
|
|
34
|
+
mutation addProductsToWishlist(
|
|
35
|
+
$wishlistId: ID!
|
|
36
|
+
$wishlistItems: [WishlistItemInput!]!
|
|
37
|
+
) {
|
|
38
|
+
addProductsToWishlist(
|
|
39
|
+
wishlistId: $wishlistId
|
|
40
|
+
wishlistItems: $wishlistItems
|
|
41
|
+
) {
|
|
42
|
+
wishlist {
|
|
43
|
+
id
|
|
44
|
+
name
|
|
45
|
+
items_count
|
|
46
|
+
items_v2 {
|
|
47
|
+
items {
|
|
48
|
+
id
|
|
49
|
+
product {
|
|
50
|
+
uid
|
|
51
|
+
name
|
|
52
|
+
sku
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
const REMOVE_FROM_WISHLIST = `
|
|
62
|
+
mutation removeProductsFromWishlist (
|
|
63
|
+
$wishlistId: ID!
|
|
64
|
+
$wishlistItemsIds: [ID!]!
|
|
65
|
+
) {
|
|
66
|
+
removeProductsFromWishlist(
|
|
67
|
+
wishlistId: $wishlistId
|
|
68
|
+
wishlistItemsIds: $wishlistItemsIds
|
|
69
|
+
) {
|
|
70
|
+
wishlist {
|
|
71
|
+
id
|
|
72
|
+
name
|
|
73
|
+
items_count
|
|
74
|
+
items_v2 {
|
|
75
|
+
items {
|
|
76
|
+
id
|
|
77
|
+
product {
|
|
78
|
+
uid
|
|
79
|
+
name
|
|
80
|
+
sku
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
CREATE_EMPTY_CART,
|
|
91
|
+
ADD_TO_CART,
|
|
92
|
+
ADD_TO_WISHLIST,
|
|
93
|
+
REMOVE_FROM_WISHLIST
|
|
94
|
+
};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Facet, Product, ProductView } from './fragments';
|
|
11
|
+
|
|
12
|
+
const ATTRIBUTE_METADATA_QUERY = `
|
|
13
|
+
query attributeMetadata {
|
|
14
|
+
attributeMetadata {
|
|
15
|
+
sortable {
|
|
16
|
+
label
|
|
17
|
+
attribute
|
|
18
|
+
numeric
|
|
19
|
+
}
|
|
20
|
+
filterableInSearch {
|
|
21
|
+
label
|
|
22
|
+
attribute
|
|
23
|
+
numeric
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const QUICK_SEARCH_QUERY = `
|
|
30
|
+
query quickSearch(
|
|
31
|
+
$phrase: String!
|
|
32
|
+
$pageSize: Int = 20
|
|
33
|
+
$currentPage: Int = 1
|
|
34
|
+
$filter: [SearchClauseInput!]
|
|
35
|
+
$sort: [ProductSearchSortInput!]
|
|
36
|
+
$context: QueryContextInput
|
|
37
|
+
) {
|
|
38
|
+
productSearch(
|
|
39
|
+
phrase: $phrase
|
|
40
|
+
page_size: $pageSize
|
|
41
|
+
current_page: $currentPage
|
|
42
|
+
filter: $filter
|
|
43
|
+
sort: $sort
|
|
44
|
+
context: $context
|
|
45
|
+
) {
|
|
46
|
+
suggestions
|
|
47
|
+
items {
|
|
48
|
+
...Product
|
|
49
|
+
}
|
|
50
|
+
page_info {
|
|
51
|
+
current_page
|
|
52
|
+
page_size
|
|
53
|
+
total_pages
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
${Product}
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
const PRODUCT_SEARCH_QUERY = `
|
|
61
|
+
query productSearch(
|
|
62
|
+
$phrase: String!
|
|
63
|
+
$pageSize: Int
|
|
64
|
+
$currentPage: Int = 1
|
|
65
|
+
$filter: [SearchClauseInput!]
|
|
66
|
+
$sort: [ProductSearchSortInput!]
|
|
67
|
+
$context: QueryContextInput
|
|
68
|
+
) {
|
|
69
|
+
productSearch(
|
|
70
|
+
phrase: $phrase
|
|
71
|
+
page_size: $pageSize
|
|
72
|
+
current_page: $currentPage
|
|
73
|
+
filter: $filter
|
|
74
|
+
sort: $sort
|
|
75
|
+
context: $context
|
|
76
|
+
) {
|
|
77
|
+
total_count
|
|
78
|
+
items {
|
|
79
|
+
...Product
|
|
80
|
+
...ProductView
|
|
81
|
+
}
|
|
82
|
+
facets {
|
|
83
|
+
...Facet
|
|
84
|
+
}
|
|
85
|
+
page_info {
|
|
86
|
+
current_page
|
|
87
|
+
page_size
|
|
88
|
+
total_pages
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
attributeMetadata {
|
|
92
|
+
sortable {
|
|
93
|
+
label
|
|
94
|
+
attribute
|
|
95
|
+
numeric
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
${Product}
|
|
100
|
+
${ProductView}
|
|
101
|
+
${Facet}
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
const REFINE_PRODUCT_QUERY = `
|
|
105
|
+
query refineProduct(
|
|
106
|
+
$optionIds: [String!]!
|
|
107
|
+
$sku: String!
|
|
108
|
+
) {
|
|
109
|
+
refineProduct(
|
|
110
|
+
optionIds: $optionIds
|
|
111
|
+
sku: $sku
|
|
112
|
+
) {
|
|
113
|
+
__typename
|
|
114
|
+
id
|
|
115
|
+
sku
|
|
116
|
+
name
|
|
117
|
+
inStock
|
|
118
|
+
url
|
|
119
|
+
urlKey
|
|
120
|
+
images {
|
|
121
|
+
label
|
|
122
|
+
url
|
|
123
|
+
roles
|
|
124
|
+
}
|
|
125
|
+
... on SimpleProductView {
|
|
126
|
+
price {
|
|
127
|
+
final {
|
|
128
|
+
amount {
|
|
129
|
+
value
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
regular {
|
|
133
|
+
amount {
|
|
134
|
+
value
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
... on ComplexProductView {
|
|
140
|
+
options {
|
|
141
|
+
id
|
|
142
|
+
title
|
|
143
|
+
required
|
|
144
|
+
values {
|
|
145
|
+
id
|
|
146
|
+
title
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
priceRange {
|
|
150
|
+
maximum {
|
|
151
|
+
final {
|
|
152
|
+
amount {
|
|
153
|
+
value
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
regular {
|
|
157
|
+
amount {
|
|
158
|
+
value
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
minimum {
|
|
163
|
+
final {
|
|
164
|
+
amount {
|
|
165
|
+
value
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
regular {
|
|
169
|
+
amount {
|
|
170
|
+
value
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
|
|
180
|
+
const GET_CUSTOMER_CART = `
|
|
181
|
+
query customerCart {
|
|
182
|
+
customerCart {
|
|
183
|
+
id
|
|
184
|
+
items {
|
|
185
|
+
id
|
|
186
|
+
product {
|
|
187
|
+
name
|
|
188
|
+
sku
|
|
189
|
+
}
|
|
190
|
+
quantity
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
|
|
196
|
+
const GET_CUSTOMER_WISHLISTS = `
|
|
197
|
+
query customer {
|
|
198
|
+
customer {
|
|
199
|
+
wishlists {
|
|
200
|
+
id
|
|
201
|
+
name
|
|
202
|
+
items_count
|
|
203
|
+
items_v2 {
|
|
204
|
+
items {
|
|
205
|
+
id
|
|
206
|
+
product {
|
|
207
|
+
uid
|
|
208
|
+
name
|
|
209
|
+
sku
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
`;
|
|
217
|
+
|
|
218
|
+
export {
|
|
219
|
+
ATTRIBUTE_METADATA_QUERY,
|
|
220
|
+
PRODUCT_SEARCH_QUERY,
|
|
221
|
+
QUICK_SEARCH_QUERY,
|
|
222
|
+
REFINE_PRODUCT_QUERY,
|
|
223
|
+
GET_CUSTOMER_CART,
|
|
224
|
+
GET_CUSTOMER_WISHLISTS
|
|
225
|
+
};
|