@riosst100/pwa-marketplace 2.1.3 → 2.1.5
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 +1 -1
- package/src/componentOverrideMapping.js +6 -0
- package/src/components/FavoriteSeller/AddToListButton/addToListButton.js +54 -54
- package/src/components/FavoriteSeller/AddToListButton/addToListButton.module.css +17 -17
- package/src/components/FavoriteSeller/AddToListButton/index.js +1 -1
- package/src/components/FavoriteSeller/AddToListButton/useCommonToasts.js +33 -33
- package/src/components/FilterTop/CustomFilters/customFilters.js +130 -132
- package/src/components/FilterTop/filterTop.js +1 -8
- package/src/components/LinkToOtherStores/index.js +61 -0
- package/src/components/NonSportCardsSets/nonSportCardsSets.js +0 -2
- package/src/components/RFQ/index.js +6 -3
- package/src/components/SellerDetail/sellerDetail.js +18 -1
- package/src/components/SellerInformation/sellerInformation.js +5 -3
- package/src/components/SellerSocialMedia/index.js +96 -0
- package/src/components/SetsData/index.js +2 -0
- package/src/components/SetsData/setsData.js +349 -0
- package/src/components/SetsData/setsData.module.css +76 -0
- package/src/components/SetsData/setsData.shimmer.js +50 -0
- package/src/components/ShopBy/shopBy.js +3 -2
- package/src/overwrites/pagebuilder/lib/ContentTypes/Products/products.js +13 -0
- package/src/overwrites/peregrine/lib/talons/MagentoRoute/magentoRoute.gql.js +27 -0
- package/src/overwrites/peregrine/lib/talons/MagentoRoute/useMagentoRoute.js +193 -0
- package/src/overwrites/peregrine/lib/talons/ProductFullDetail/useProductFullDetail.js +40 -9
- package/src/overwrites/peregrine/lib/talons/ProductImageCarousel/useProductImageCarousel.js +77 -0
- package/src/overwrites/peregrine/lib/talons/ProductOptions/useOption.js +59 -0
- package/src/overwrites/peregrine/lib/talons/ProductOptions/useTile.js +47 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryFragments.gql.js +13 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Product/productDetailFragment.gql.js +23 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +11 -3
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +0 -6
- package/src/overwrites/venia-ui/lib/components/AccountInformationPage/accountInformationPage.js +0 -1
- package/src/overwrites/venia-ui/lib/components/AccountInformationPage/editForm.js +0 -1
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +0 -3
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/OrderSummary/orderSummary.js +0 -1
- package/src/overwrites/venia-ui/lib/components/Gallery/item.js +17 -3
- package/src/overwrites/venia-ui/lib/components/Price/price.js +113 -0
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/components/auctionDetail.js +1 -1
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +77 -104
- package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.js +3 -1
- package/src/overwrites/venia-ui/lib/components/ProductOptions/option.js +112 -0
- package/src/overwrites/venia-ui/lib/components/ProductOptions/option.module.css +30 -0
- package/src/overwrites/venia-ui/lib/components/ProductOptions/options.js +49 -0
- package/src/overwrites/venia-ui/lib/components/ProductOptions/tile.js +118 -0
- package/src/overwrites/venia-ui/lib/components/ProductOptions/tile.module.css +68 -0
- package/src/overwrites/venia-ui/lib/components/ProductOptions/tileList.js +78 -0
- package/src/overwrites/venia-ui/lib/components/ProductOptions/tileList.module.css +6 -0
- package/src/overwrites/venia-ui/lib/components/ProductOptions/tileList.shimmer.js +32 -0
- package/src/talons/CustomFilters/useCustomFilters.js +0 -2
- package/src/talons/FavoriteSeller/AddToListButton/addToListButton.gql.js +30 -30
- package/src/talons/FavoriteSeller/AddToListButton/useAddToFavoriteListButton.js +0 -1
- package/src/talons/LegoSets/useLegoSets.js +0 -5
- package/src/talons/Seller/useSeller.js +1 -1
- package/src/talons/SetsData/setsData.gql.js +70 -0
- package/src/talons/SetsData/useSetsData.js +225 -0
- package/src/talons/ShopBy/shopBy.gql.js +12 -6
- package/src/talons/ShopBy/useShopBy.js +13 -4
- package/src/talons/TrainsSets/useTrainsSets.js +0 -3
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { useQuery, useLazyQuery } from '@apollo/client';
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
6
|
+
import DEFAULT_OPERATIONS from './setsData.gql';
|
|
7
|
+
import { getFilterInput, getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
8
|
+
|
|
9
|
+
export const useSetsData = props => {
|
|
10
|
+
|
|
11
|
+
const { searchQuery, setActive, currentSort, shopby, setType, categoryId, activeTab, activeFilter } = props
|
|
12
|
+
|
|
13
|
+
const { value: sortby } = currentSort
|
|
14
|
+
|
|
15
|
+
const operations = mergeOperations(DEFAULT_OPERATIONS, null);
|
|
16
|
+
const { getStoreConfigData, getSetsDataQuery, getCategoryContentQuery, getFilterInputsQuery } = operations;
|
|
17
|
+
const { pathname, search } = useLocation();
|
|
18
|
+
const [runQuery, queryResponse] = useLazyQuery(getSetsDataQuery, {
|
|
19
|
+
fetchPolicy: 'cache-and-network',
|
|
20
|
+
nextFetchPolicy: 'cache-first'
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const pathnameArr = pathname.split('/');
|
|
24
|
+
|
|
25
|
+
const categoryUrlKey = pathnameArr[pathnameArr.length - 1].replace('.html','');
|
|
26
|
+
const parentCategoryUrlKey = pathnameArr[pathnameArr.length - 2].replace('.html','');
|
|
27
|
+
const productType = shopby;
|
|
28
|
+
|
|
29
|
+
const { data: introspectionData } = useQuery(getFilterInputsQuery);
|
|
30
|
+
|
|
31
|
+
const filterTypeMap = useMemo(() => {
|
|
32
|
+
const typeMap = new Map();
|
|
33
|
+
if (introspectionData) {
|
|
34
|
+
introspectionData.__type.inputFields.forEach(({ name, type }) => {
|
|
35
|
+
typeMap.set(name, type.name);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return typeMap;
|
|
39
|
+
}, [introspectionData]);
|
|
40
|
+
const filters = getFiltersFromSearch(search);
|
|
41
|
+
|
|
42
|
+
// console.log(search)
|
|
43
|
+
|
|
44
|
+
// Construct the filter arg object.
|
|
45
|
+
const newFilters = {};
|
|
46
|
+
filters.forEach((values, key) => {
|
|
47
|
+
newFilters[key] = getFilterInput(values, filterTypeMap.get(key));
|
|
48
|
+
// console.log(key)
|
|
49
|
+
// console.log(values)
|
|
50
|
+
|
|
51
|
+
if (key == "sc_baseball_release") {
|
|
52
|
+
for(let item of values) {
|
|
53
|
+
if(item) {
|
|
54
|
+
// console.log(item.split(',')[0])
|
|
55
|
+
const data = search.split('&');
|
|
56
|
+
data.pop();
|
|
57
|
+
activeFilters.push(
|
|
58
|
+
{
|
|
59
|
+
'label': item.split(',')[0],
|
|
60
|
+
'path': data
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
// console.log("MASUK")
|
|
70
|
+
|
|
71
|
+
// if (queryResponse.data) {
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
// Use the category uid for the current category page regardless of the
|
|
76
|
+
// applied filters. Follow-up in PWA-404.
|
|
77
|
+
// newFilters['category_uid'] = { eq: id };
|
|
78
|
+
|
|
79
|
+
runQuery({
|
|
80
|
+
variables: {
|
|
81
|
+
filters: newFilters,
|
|
82
|
+
categoryUrlKey: pathname,
|
|
83
|
+
activeTab: activeTab,
|
|
84
|
+
shopby: shopby,
|
|
85
|
+
activeFilter: activeFilter
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
// }
|
|
89
|
+
}, [
|
|
90
|
+
runQuery,
|
|
91
|
+
activeTab,
|
|
92
|
+
activeFilter
|
|
93
|
+
// queryResponse
|
|
94
|
+
// filterTypeMap,
|
|
95
|
+
// search,
|
|
96
|
+
// newFilters,
|
|
97
|
+
// shopby,
|
|
98
|
+
// categoryUrlKey
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
const { data: storeConfigData } = useQuery(getStoreConfigData, {
|
|
102
|
+
fetchPolicy: 'cache-and-network',
|
|
103
|
+
nextFetchPolicy: 'cache-first'
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const categoryUrlSuffix = storeConfigData?.storeConfig?.category_url_suffix;
|
|
107
|
+
|
|
108
|
+
// { data: queryResponse, error, loading }
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
// console.log(data)
|
|
113
|
+
|
|
114
|
+
// const isBackgroundLoading = !!data && loading;
|
|
115
|
+
|
|
116
|
+
const availableLeagues = [];
|
|
117
|
+
|
|
118
|
+
// console.log(queryResponse.data)
|
|
119
|
+
|
|
120
|
+
const setsData = useMemo(() => {
|
|
121
|
+
if (!queryResponse) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// console.log(data)
|
|
126
|
+
|
|
127
|
+
const setsData = queryResponse?.data?.getSetsData?.data;
|
|
128
|
+
if (!setsData) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// return setsData.slice().sort((a, b) =>a.group.toLowerCase().localeCompare(b.group.toLowerCase()));
|
|
133
|
+
return setsData;
|
|
134
|
+
}, [queryResponse]);
|
|
135
|
+
|
|
136
|
+
const availableGroups = setsData && setsData.length ? setsData.map(({ group }) => group) : [];
|
|
137
|
+
|
|
138
|
+
// const availableLeagues = setsData && setsData.length ? setsData.map(({ sets }) => setsData.map(({ sc_league }) => sc_league)) : [];
|
|
139
|
+
// console.log(availableLeagues)
|
|
140
|
+
// sc_league
|
|
141
|
+
const attributeData = useMemo(() => {
|
|
142
|
+
if (!queryResponse) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return queryResponse?.data?.getSetsData?.attribute;
|
|
147
|
+
}, [queryResponse]);
|
|
148
|
+
|
|
149
|
+
const pageInfo = useMemo(() => {
|
|
150
|
+
if (!queryResponse) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return queryResponse?.data?.getSetsData?.page_info;
|
|
155
|
+
}, [queryResponse]);
|
|
156
|
+
|
|
157
|
+
const filteredSetsData = useMemo(() => {
|
|
158
|
+
if (!setsData) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const filteredSets = [];
|
|
163
|
+
|
|
164
|
+
if (searchQuery) {
|
|
165
|
+
|
|
166
|
+
// useEffect(() => {
|
|
167
|
+
// setActive('all')
|
|
168
|
+
// }, [active]);
|
|
169
|
+
|
|
170
|
+
setsData.map(({ group, sets }, index) => {
|
|
171
|
+
const newSets = sets.filter(function(set) {
|
|
172
|
+
return set.set_name.search(new RegExp(searchQuery, "i")) != -1 || group.search(new RegExp(searchQuery, "i")) != -1;
|
|
173
|
+
// return set.set_name.includes(searchQuery);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (newSets && newSets.length) {
|
|
177
|
+
filteredSets.push({
|
|
178
|
+
'group': group,
|
|
179
|
+
'sets': newSets
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return searchQuery ? filteredSets : setsData;
|
|
186
|
+
}, [setsData, searchQuery]);
|
|
187
|
+
|
|
188
|
+
// useEffect(() => {
|
|
189
|
+
// setPageLoading(isBackgroundLoading);
|
|
190
|
+
// }, [isBackgroundLoading, setPageLoading]);
|
|
191
|
+
|
|
192
|
+
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
193
|
+
getCategoryContentQuery,
|
|
194
|
+
{
|
|
195
|
+
fetchPolicy: 'cache-and-network',
|
|
196
|
+
nextFetchPolicy: 'cache-first',
|
|
197
|
+
skip: !categoryId,
|
|
198
|
+
variables: {
|
|
199
|
+
id: categoryId
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const category =
|
|
205
|
+
categoryData && categoryData.categories.items.length
|
|
206
|
+
? categoryData.categories.items[0]
|
|
207
|
+
: null;
|
|
208
|
+
|
|
209
|
+
const error = queryResponse?.error;
|
|
210
|
+
const loading = queryResponse?.loading;
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
error,
|
|
214
|
+
loading,
|
|
215
|
+
setsData,
|
|
216
|
+
filteredSetsData,
|
|
217
|
+
categoryUrlSuffix,
|
|
218
|
+
categoryUrlKey,
|
|
219
|
+
productType,
|
|
220
|
+
availableGroups,
|
|
221
|
+
category,
|
|
222
|
+
attributeData,
|
|
223
|
+
pageInfo
|
|
224
|
+
};
|
|
225
|
+
};
|
|
@@ -14,14 +14,20 @@ export const GET_STORE_CONFIG_DATA = gql`
|
|
|
14
14
|
export const GET_SHOP_BY_DATA_QUERY = gql`
|
|
15
15
|
query getShopByData($search: String, $activeFilter: String, $categoryUrlKey: String!, $attributeCode: String, $filters: ProductAttributeFilterInput!) {
|
|
16
16
|
shopByData(search: $search, activeFilter: $activeFilter, categoryUrlKey: $categoryUrlKey, attributeCode: $attributeCode, filters: $filters) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
page_info {
|
|
18
|
+
title
|
|
19
|
+
filter_group
|
|
20
|
+
}
|
|
21
|
+
data {
|
|
21
22
|
label
|
|
22
|
-
|
|
23
|
+
count
|
|
24
|
+
attribute_code
|
|
25
|
+
options {
|
|
26
|
+
label
|
|
27
|
+
value
|
|
28
|
+
}
|
|
29
|
+
position
|
|
23
30
|
}
|
|
24
|
-
position
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
`;
|
|
@@ -130,7 +130,7 @@ export const useShopBy = props => {
|
|
|
130
130
|
return null;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
const rawData = queryResponse?.data?.shopByData;
|
|
133
|
+
const rawData = queryResponse?.data?.shopByData?.data;
|
|
134
134
|
if (!rawData) {
|
|
135
135
|
return null;
|
|
136
136
|
}
|
|
@@ -160,7 +160,7 @@ export const useShopBy = props => {
|
|
|
160
160
|
return null;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
const rawData = queryResponse?.data?.shopByData;
|
|
163
|
+
const rawData = queryResponse?.data?.shopByData?.data;
|
|
164
164
|
if (!rawData) {
|
|
165
165
|
return null;
|
|
166
166
|
}
|
|
@@ -227,7 +227,7 @@ export const useShopBy = props => {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
|
|
230
|
-
const attributeData = queryResponse?.data?.shopByData && queryResponse?.data?.shopByData.length ? queryResponse.data.shopByData[0] : null
|
|
230
|
+
const attributeData = queryResponse?.data?.shopByData?.data && queryResponse?.data?.shopByData.data.length ? queryResponse.data.shopByData.data[0] : null
|
|
231
231
|
|
|
232
232
|
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
233
233
|
getCategoryContentQuery,
|
|
@@ -241,6 +241,14 @@ export const useShopBy = props => {
|
|
|
241
241
|
}
|
|
242
242
|
);
|
|
243
243
|
|
|
244
|
+
const pageInfo = useMemo(() => {
|
|
245
|
+
if (!queryResponse) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return queryResponse?.data?.shopByData?.page_info;
|
|
250
|
+
}, [queryResponse]);
|
|
251
|
+
|
|
244
252
|
const category =
|
|
245
253
|
categoryData && categoryData.categories.items.length
|
|
246
254
|
? categoryData.categories.items[0]
|
|
@@ -258,7 +266,8 @@ export const useShopBy = props => {
|
|
|
258
266
|
attributeData,
|
|
259
267
|
alpha,
|
|
260
268
|
category,
|
|
261
|
-
activeFilters
|
|
269
|
+
activeFilters,
|
|
270
|
+
pageInfo
|
|
262
271
|
// productType
|
|
263
272
|
};
|
|
264
273
|
};
|
|
@@ -133,7 +133,6 @@ export const useTrainsSets = props => {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
if (activeTab == "trains_gauge") {
|
|
136
|
-
console.log(activeFilter + ' dan '+set.trains_gauge)
|
|
137
136
|
return set.trains_gauge.search(new RegExp('<'+activeFilter+'>', "i")) != -1;
|
|
138
137
|
}
|
|
139
138
|
|
|
@@ -177,8 +176,6 @@ export const useTrainsSets = props => {
|
|
|
177
176
|
})
|
|
178
177
|
}
|
|
179
178
|
|
|
180
|
-
console.log(filteredSets)
|
|
181
|
-
|
|
182
179
|
return searchQuery || activeFilter ? filteredSets : trainsSets;
|
|
183
180
|
}, [trainsSets, searchQuery, activeFilter]);
|
|
184
181
|
|