@riosst100/pwa-marketplace 1.2.3 → 1.2.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 +2 -1
- package/src/components/Filter/index.js +7 -7
- package/src/components/OperatingHours/index.js +1 -0
- package/src/components/OperatingHours/operatingHours.js +32 -0
- package/src/components/Pagination/index.js +26 -17
- package/src/components/Search/index.js +1 -1
- package/src/components/Seller/index.js +1 -0
- package/src/components/Seller/seller.js +250 -0
- package/src/components/Seller/sellerAddressCard.js +48 -0
- package/src/components/SellerDetail/index.js +1 -0
- package/src/components/SellerDetail/sellerDetail.js +158 -0
- package/src/components/SellerInformation/sellerInformation.js +54 -44
- package/src/components/SellerLocation/sellerLocation.js +6 -2
- package/src/components/SellerLocation/sellerLocationItem.js +6 -8
- package/src/components/SellerPage/sellerPage.js +2 -112
- package/src/components/SellerProducts/sellerProducts.js +33 -12
- package/src/components/SellerReview/sellerReview.js +29 -29
- package/src/components/SellerReviewItem/sellerReviewItem.js +8 -8
- package/src/components/SortBy/index.js +13 -5
- package/src/components/commons/Slider/index.js +2 -2
- package/src/components/commons/Tabs/index.js +11 -9
- package/src/overwrites/venia-ui/lib/components/Header/header.js +46 -34
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +31 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +43 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +50 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.module.css +0 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -0
- package/src/talons/Seller/seller.gql.js +204 -0
- package/src/talons/Seller/useSeller.js +71 -0
- package/src/talons/SellerProducts/useSellerProducts.js +129 -0
- package/src/theme/vars.js +7 -0
- package/src/util/mapSeller.js +7 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useLazyQuery, useQuery } from '@apollo/client';
|
|
3
|
+
|
|
4
|
+
import mergeOperations from '../../../util/shallowMerge';
|
|
5
|
+
import { useEventingContext } from '../../../context/eventing';
|
|
6
|
+
|
|
7
|
+
import DEFAULT_OPERATIONS from './categoryContent.gql';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns props necessary to render the categoryContent component.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} props.data - The results of a getCategory GraphQL query.
|
|
13
|
+
*
|
|
14
|
+
* @returns {object} result
|
|
15
|
+
* @returns {string} result.categoryDescription - This category's description.
|
|
16
|
+
* @returns {string} result.categoryName - This category's name.
|
|
17
|
+
* @returns {object} result.filters - The filters object.
|
|
18
|
+
* @returns {object} result.items - The items in this category.
|
|
19
|
+
* @returns {number} result.totalPagesFromData - The total amount of pages for the query.
|
|
20
|
+
*/
|
|
21
|
+
export const useSellerProducts = props => {
|
|
22
|
+
const { categoryId, data, pageSize = 6 } = props;
|
|
23
|
+
|
|
24
|
+
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
getSellerProductsQuery,
|
|
28
|
+
getProductFiltersByCategoryQuery,
|
|
29
|
+
getCategoryAvailableSortMethodsQuery
|
|
30
|
+
} = operations;
|
|
31
|
+
|
|
32
|
+
const placeholderItems = Array.from({ length: pageSize }).fill(null);
|
|
33
|
+
|
|
34
|
+
const [getFilters, { data: filterData }] = useLazyQuery(
|
|
35
|
+
getProductFiltersByCategoryQuery,
|
|
36
|
+
{
|
|
37
|
+
fetchPolicy: 'cache-and-network',
|
|
38
|
+
nextFetchPolicy: 'cache-first'
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const [getSortMethods, { data: sortData }] = useLazyQuery(
|
|
43
|
+
getCategoryAvailableSortMethodsQuery,
|
|
44
|
+
{
|
|
45
|
+
fetchPolicy: 'cache-and-network',
|
|
46
|
+
nextFetchPolicy: 'cache-first'
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const { data: categoryData, loading: categoryLoading } = useQuery(
|
|
51
|
+
getSellerProductsQuery,
|
|
52
|
+
{
|
|
53
|
+
fetchPolicy: 'cache-and-network',
|
|
54
|
+
nextFetchPolicy: 'cache-first',
|
|
55
|
+
skip: !categoryId,
|
|
56
|
+
variables: {
|
|
57
|
+
id: categoryId
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const [, { dispatch }] = useEventingContext();
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (categoryId) {
|
|
66
|
+
getFilters({
|
|
67
|
+
variables: {
|
|
68
|
+
categoryIdFilter: {
|
|
69
|
+
eq: categoryId
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, [categoryId, getFilters]);
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (categoryId) {
|
|
78
|
+
getSortMethods({
|
|
79
|
+
variables: {
|
|
80
|
+
categoryIdFilter: {
|
|
81
|
+
in: categoryId
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}, [categoryId, getSortMethods]);
|
|
87
|
+
|
|
88
|
+
const filters = filterData ? filterData.products.aggregations : null;
|
|
89
|
+
const items = data ? data.products.items : placeholderItems;
|
|
90
|
+
const totalPagesFromData = data
|
|
91
|
+
? data.products.page_info.total_pages
|
|
92
|
+
: null;
|
|
93
|
+
const totalCount = data ? data.products.total_count : null;
|
|
94
|
+
const categoryName =
|
|
95
|
+
categoryData && categoryData.categories.items.length
|
|
96
|
+
? categoryData.categories.items[0].name
|
|
97
|
+
: null;
|
|
98
|
+
const categoryDescription =
|
|
99
|
+
categoryData && categoryData.categories.items.length
|
|
100
|
+
? categoryData.categories.items[0].description
|
|
101
|
+
: null;
|
|
102
|
+
const availableSortMethods = sortData
|
|
103
|
+
? sortData.products.sort_fields.options
|
|
104
|
+
: null;
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (!categoryLoading && categoryData.categories.items.length > 0) {
|
|
108
|
+
dispatch({
|
|
109
|
+
type: 'CATEGORY_PAGE_VIEW',
|
|
110
|
+
payload: {
|
|
111
|
+
id: categoryData.categories.items[0].uid,
|
|
112
|
+
name: categoryData.categories.items[0].name,
|
|
113
|
+
url_key: categoryData.categories.items[0].url_key,
|
|
114
|
+
url_path: categoryData.categories.items[0].url_path
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}, [categoryData, dispatch, categoryLoading]);
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
availableSortMethods,
|
|
122
|
+
categoryName,
|
|
123
|
+
categoryDescription,
|
|
124
|
+
filters,
|
|
125
|
+
items,
|
|
126
|
+
totalCount,
|
|
127
|
+
totalPagesFromData
|
|
128
|
+
};
|
|
129
|
+
};
|