@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,13 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
composes: border-t from global;
|
|
3
|
+
composes: border-solid from global;
|
|
4
|
+
composes: border-subtle from global;
|
|
5
|
+
composes: gap-3 from global;
|
|
6
|
+
composes: grid from global;
|
|
7
|
+
composes: pt-3 from global;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* TODO @TW: cannot compose */
|
|
11
|
+
.root:empty {
|
|
12
|
+
display: none;
|
|
13
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import { func, shape, string } from 'prop-types';
|
|
4
|
+
import { Link } from 'react-router-dom';
|
|
5
|
+
import { useSuggestedCategory } from '@magento/peregrine/lib/talons/SearchBar';
|
|
6
|
+
|
|
7
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
8
|
+
import defaultClasses from './suggestedCategory.module.css';
|
|
9
|
+
|
|
10
|
+
const SuggestedCategory = props => {
|
|
11
|
+
const { categoryId, label, onNavigate, value } = props;
|
|
12
|
+
const talonProps = useSuggestedCategory({
|
|
13
|
+
categoryId,
|
|
14
|
+
label,
|
|
15
|
+
onNavigate,
|
|
16
|
+
searchValue: value
|
|
17
|
+
});
|
|
18
|
+
const { destination, handleClick } = talonProps;
|
|
19
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Link className={classes.root} to={destination} onClick={handleClick}>
|
|
23
|
+
<strong className={classes.value}>{value}</strong>
|
|
24
|
+
<span className={classes.label}>
|
|
25
|
+
<FormattedMessage
|
|
26
|
+
id={'searchBar.label'}
|
|
27
|
+
defaultMessage={' in {label}'}
|
|
28
|
+
values={{
|
|
29
|
+
label
|
|
30
|
+
}}
|
|
31
|
+
/>
|
|
32
|
+
</span>
|
|
33
|
+
</Link>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default SuggestedCategory;
|
|
38
|
+
|
|
39
|
+
SuggestedCategory.propTypes = {
|
|
40
|
+
categoryId: string,
|
|
41
|
+
classes: shape({
|
|
42
|
+
label: string,
|
|
43
|
+
root: string,
|
|
44
|
+
value: string
|
|
45
|
+
}),
|
|
46
|
+
label: string.isRequired,
|
|
47
|
+
onNavigate: func,
|
|
48
|
+
value: string.isRequired
|
|
49
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { func, number, shape, string } from 'prop-types';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import Price from '@magento/venia-ui/lib/components/Price';
|
|
5
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
6
|
+
|
|
7
|
+
import Image from '@magento/venia-ui/lib/components/Image';
|
|
8
|
+
import defaultClasses from './suggestedProduct.module.css';
|
|
9
|
+
import { useSuggestedProduct } from '@magento/peregrine/lib/talons/SearchBar';
|
|
10
|
+
|
|
11
|
+
const IMAGE_WIDTH = 60;
|
|
12
|
+
|
|
13
|
+
const SuggestedProduct = props => {
|
|
14
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
15
|
+
const {
|
|
16
|
+
url_key,
|
|
17
|
+
small_image,
|
|
18
|
+
name,
|
|
19
|
+
onNavigate,
|
|
20
|
+
price,
|
|
21
|
+
price_range,
|
|
22
|
+
url_suffix,
|
|
23
|
+
sku
|
|
24
|
+
} = props;
|
|
25
|
+
|
|
26
|
+
const talonProps = useSuggestedProduct({
|
|
27
|
+
name,
|
|
28
|
+
price,
|
|
29
|
+
price_range,
|
|
30
|
+
onNavigate,
|
|
31
|
+
url_key,
|
|
32
|
+
url_suffix,
|
|
33
|
+
sku
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const { priceProps, handleClick, uri } = talonProps;
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Link
|
|
40
|
+
className={classes.root}
|
|
41
|
+
to={uri}
|
|
42
|
+
onClick={handleClick}
|
|
43
|
+
data-cy="SuggestedProduct-root"
|
|
44
|
+
>
|
|
45
|
+
<Image
|
|
46
|
+
alt={name}
|
|
47
|
+
classes={{ image: classes.thumbnail, root: classes.image }}
|
|
48
|
+
resource={small_image}
|
|
49
|
+
width={IMAGE_WIDTH}
|
|
50
|
+
data-cy="SuggestedProduct-image"
|
|
51
|
+
/>
|
|
52
|
+
<span className={classes.name}>{name}</span>
|
|
53
|
+
<span data-cy="SuggestedProduct-price" className={classes.price}>
|
|
54
|
+
<Price {...priceProps} />
|
|
55
|
+
</span>
|
|
56
|
+
</Link>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
SuggestedProduct.propTypes = {
|
|
61
|
+
url_key: string.isRequired,
|
|
62
|
+
small_image: string.isRequired,
|
|
63
|
+
name: string.isRequired,
|
|
64
|
+
onNavigate: func,
|
|
65
|
+
price: shape({
|
|
66
|
+
regularPrice: shape({
|
|
67
|
+
amount: shape({
|
|
68
|
+
currency: string,
|
|
69
|
+
value: number
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
}).isRequired,
|
|
73
|
+
price_range: shape({
|
|
74
|
+
maximum_price: shape({
|
|
75
|
+
final_price: shape({
|
|
76
|
+
currency: string,
|
|
77
|
+
value: number
|
|
78
|
+
}),
|
|
79
|
+
regular_price: shape({
|
|
80
|
+
currency: string,
|
|
81
|
+
value: number
|
|
82
|
+
}),
|
|
83
|
+
discount: shape({
|
|
84
|
+
amount_off: number
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
}),
|
|
88
|
+
classes: shape({
|
|
89
|
+
root: string,
|
|
90
|
+
image: string,
|
|
91
|
+
name: string,
|
|
92
|
+
price: string,
|
|
93
|
+
thumbnail: string
|
|
94
|
+
})
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default SuggestedProduct;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
composes: gap-xs from global;
|
|
3
|
+
composes: grid from global;
|
|
4
|
+
composes: grid-flow-col from global;
|
|
5
|
+
composes: items-center from global;
|
|
6
|
+
grid-template-columns: 60px 1fr;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.image {
|
|
10
|
+
composes: items-center from global;
|
|
11
|
+
composes: inline-flex from global;
|
|
12
|
+
composes: justify-center from global;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.thumbnail {
|
|
16
|
+
composes: h-[75px] from global;
|
|
17
|
+
composes: max-h-[75px] from global;
|
|
18
|
+
composes: object-contain from global;
|
|
19
|
+
composes: object-center from global;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.name {
|
|
23
|
+
composes: break-words from global;
|
|
24
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { arrayOf, func, number, oneOfType, shape, string } from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
5
|
+
import mapProduct from '@magento/venia-ui/lib/util/mapProduct';
|
|
6
|
+
import SuggestedProduct from './suggestedProduct';
|
|
7
|
+
import defaultClasses from './suggestedProducts.module.css';
|
|
8
|
+
|
|
9
|
+
const SuggestedProducts = props => {
|
|
10
|
+
const { limit, onNavigate, products } = props;
|
|
11
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
12
|
+
|
|
13
|
+
const items = products.slice(0, limit).map(product => (
|
|
14
|
+
<li key={product.id} className={classes.item}>
|
|
15
|
+
<SuggestedProduct
|
|
16
|
+
{...mapProduct(product)}
|
|
17
|
+
onNavigate={onNavigate}
|
|
18
|
+
/>
|
|
19
|
+
</li>
|
|
20
|
+
));
|
|
21
|
+
|
|
22
|
+
return <ul className={classes.root}>{items}</ul>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default SuggestedProducts;
|
|
26
|
+
|
|
27
|
+
SuggestedProducts.defaultProps = {
|
|
28
|
+
limit: 3
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
SuggestedProducts.propTypes = {
|
|
32
|
+
classes: shape({
|
|
33
|
+
item: string,
|
|
34
|
+
root: string
|
|
35
|
+
}),
|
|
36
|
+
limit: number.isRequired,
|
|
37
|
+
onNavigate: func,
|
|
38
|
+
products: arrayOf(
|
|
39
|
+
shape({
|
|
40
|
+
id: oneOfType([number, string]).isRequired
|
|
41
|
+
})
|
|
42
|
+
).isRequired
|
|
43
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.products {
|
|
2
|
+
composes: border-t from global;
|
|
3
|
+
composes: border-solid from global;
|
|
4
|
+
composes: border-subtle from global;
|
|
5
|
+
composes: gap-3 from global;
|
|
6
|
+
composes: grid from global;
|
|
7
|
+
composes: pt-3 from global;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* TODO @TW: cannot compose */
|
|
11
|
+
.products:empty {
|
|
12
|
+
display: none;
|
|
13
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import { arrayOf, bool, func, shape, string } from 'prop-types';
|
|
4
|
+
import { useSuggestions } from '@magento/peregrine/lib/talons/SearchBar';
|
|
5
|
+
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
import SuggestedCategories from './suggestedCategories';
|
|
8
|
+
import SuggestedProducts from './suggestedProducts';
|
|
9
|
+
import defaultClasses from './suggestions.module.css';
|
|
10
|
+
|
|
11
|
+
const Suggestions = props => {
|
|
12
|
+
const {
|
|
13
|
+
displayResult,
|
|
14
|
+
filters,
|
|
15
|
+
products,
|
|
16
|
+
searchValue,
|
|
17
|
+
setVisible,
|
|
18
|
+
visible
|
|
19
|
+
} = props;
|
|
20
|
+
const { items } = products;
|
|
21
|
+
|
|
22
|
+
const talonProps = useSuggestions({
|
|
23
|
+
displayResult,
|
|
24
|
+
filters,
|
|
25
|
+
items,
|
|
26
|
+
setVisible,
|
|
27
|
+
visible
|
|
28
|
+
});
|
|
29
|
+
const { categories, onNavigate, shouldRender } = talonProps;
|
|
30
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
31
|
+
|
|
32
|
+
// render null without data
|
|
33
|
+
if (!shouldRender) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Fragment>
|
|
39
|
+
<SuggestedCategories
|
|
40
|
+
categories={categories}
|
|
41
|
+
onNavigate={onNavigate}
|
|
42
|
+
value={searchValue}
|
|
43
|
+
/>
|
|
44
|
+
<h2 data-cy="Suggestions-heading" className={classes.heading}>
|
|
45
|
+
<span>
|
|
46
|
+
<FormattedMessage
|
|
47
|
+
id={'searchBar.heading'}
|
|
48
|
+
defaultMessage={'Product Suggestions'}
|
|
49
|
+
/>
|
|
50
|
+
</span>
|
|
51
|
+
</h2>
|
|
52
|
+
<SuggestedProducts onNavigate={onNavigate} products={items} />
|
|
53
|
+
</Fragment>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default Suggestions;
|
|
58
|
+
|
|
59
|
+
Suggestions.propTypes = {
|
|
60
|
+
classes: shape({
|
|
61
|
+
heading: string
|
|
62
|
+
}),
|
|
63
|
+
products: shape({
|
|
64
|
+
filters: arrayOf(
|
|
65
|
+
shape({
|
|
66
|
+
filter_items: arrayOf(shape({})),
|
|
67
|
+
name: string.isRequired
|
|
68
|
+
}).isRequired
|
|
69
|
+
),
|
|
70
|
+
items: arrayOf(shape({}))
|
|
71
|
+
}),
|
|
72
|
+
searchValue: string,
|
|
73
|
+
setVisible: func,
|
|
74
|
+
visible: bool
|
|
75
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const GET_STORE_CONFIG_DATA = gql`
|
|
4
|
+
query getStoreConfigData {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
|
+
storeConfig {
|
|
7
|
+
store_code
|
|
8
|
+
product_url_suffix
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const GET_SELLER_DETAIL_QUERY = gql`
|
|
14
|
+
query getSellerDetailForSellerPage($urlKey: String!, $getOtherInfo: Boolean, $getProducts: Boolean) {
|
|
15
|
+
sellerByUrl(seller_url: $urlKey, get_other_info: $getOtherInfo, get_products: $getProducts) {
|
|
16
|
+
seller_id
|
|
17
|
+
contact_number
|
|
18
|
+
shop_title
|
|
19
|
+
company
|
|
20
|
+
term_and_conditions
|
|
21
|
+
website_url
|
|
22
|
+
ship_to
|
|
23
|
+
ship_to_country
|
|
24
|
+
seller_rates {
|
|
25
|
+
total_count
|
|
26
|
+
page_info {
|
|
27
|
+
current_page
|
|
28
|
+
page_size
|
|
29
|
+
total_pages
|
|
30
|
+
}
|
|
31
|
+
items {
|
|
32
|
+
rating_id
|
|
33
|
+
seller_id
|
|
34
|
+
customer_id
|
|
35
|
+
rate1
|
|
36
|
+
rate2
|
|
37
|
+
rate3
|
|
38
|
+
rate4
|
|
39
|
+
rate5
|
|
40
|
+
rating
|
|
41
|
+
email
|
|
42
|
+
title
|
|
43
|
+
status
|
|
44
|
+
detail
|
|
45
|
+
nickname
|
|
46
|
+
created_at
|
|
47
|
+
verified_buyer
|
|
48
|
+
is_recommended
|
|
49
|
+
is_hidden
|
|
50
|
+
answer
|
|
51
|
+
admin_note
|
|
52
|
+
like_about
|
|
53
|
+
not_like_about
|
|
54
|
+
guest_email
|
|
55
|
+
plus_review
|
|
56
|
+
minus_review
|
|
57
|
+
report_abuse
|
|
58
|
+
country
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
products {
|
|
62
|
+
total_count
|
|
63
|
+
page_info {
|
|
64
|
+
current_page
|
|
65
|
+
page_size
|
|
66
|
+
total_pages
|
|
67
|
+
}
|
|
68
|
+
items {
|
|
69
|
+
name
|
|
70
|
+
sku
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
operating_hours {
|
|
74
|
+
day
|
|
75
|
+
status
|
|
76
|
+
time {
|
|
77
|
+
opening_time
|
|
78
|
+
closing_time
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
store_locators {
|
|
82
|
+
name
|
|
83
|
+
country
|
|
84
|
+
region
|
|
85
|
+
address_line_1
|
|
86
|
+
address_line_2
|
|
87
|
+
city
|
|
88
|
+
postcode
|
|
89
|
+
operating_hours {
|
|
90
|
+
day
|
|
91
|
+
status
|
|
92
|
+
time {
|
|
93
|
+
opening_time
|
|
94
|
+
closing_time
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
description
|
|
99
|
+
country
|
|
100
|
+
image
|
|
101
|
+
thumbnail
|
|
102
|
+
city
|
|
103
|
+
region
|
|
104
|
+
group
|
|
105
|
+
group_id
|
|
106
|
+
url
|
|
107
|
+
email
|
|
108
|
+
name
|
|
109
|
+
sale
|
|
110
|
+
creation_time
|
|
111
|
+
page_layout
|
|
112
|
+
status
|
|
113
|
+
position
|
|
114
|
+
twitter_id
|
|
115
|
+
facebook_id
|
|
116
|
+
gplus_id
|
|
117
|
+
youtube_id
|
|
118
|
+
vimeo_id
|
|
119
|
+
instagram_id
|
|
120
|
+
pinterest_id
|
|
121
|
+
linkedin_id
|
|
122
|
+
tw_active
|
|
123
|
+
fb_active
|
|
124
|
+
gplus_active
|
|
125
|
+
vimeo_active
|
|
126
|
+
instagram_active
|
|
127
|
+
pinterest_active
|
|
128
|
+
linkedin_active
|
|
129
|
+
banner_pic
|
|
130
|
+
shop_url
|
|
131
|
+
url_key
|
|
132
|
+
logo_pic
|
|
133
|
+
verify_status
|
|
134
|
+
product_count
|
|
135
|
+
telephone
|
|
136
|
+
creation_time
|
|
137
|
+
update_time
|
|
138
|
+
country_id
|
|
139
|
+
total_sold
|
|
140
|
+
operating_time
|
|
141
|
+
order_processing_time
|
|
142
|
+
shipping_partners
|
|
143
|
+
offers
|
|
144
|
+
benefits
|
|
145
|
+
product_shipping_info
|
|
146
|
+
prepare_time
|
|
147
|
+
response_ratio
|
|
148
|
+
response_time
|
|
149
|
+
store_id
|
|
150
|
+
seller_rates {
|
|
151
|
+
total_count
|
|
152
|
+
page_info {
|
|
153
|
+
page_size
|
|
154
|
+
current_page
|
|
155
|
+
}
|
|
156
|
+
items {
|
|
157
|
+
rating_id
|
|
158
|
+
seller_id
|
|
159
|
+
customer_id
|
|
160
|
+
rate1
|
|
161
|
+
rate2
|
|
162
|
+
rate3
|
|
163
|
+
rate4
|
|
164
|
+
rate5
|
|
165
|
+
rating
|
|
166
|
+
email
|
|
167
|
+
title
|
|
168
|
+
status
|
|
169
|
+
detail
|
|
170
|
+
nickname
|
|
171
|
+
created_at
|
|
172
|
+
verified_buyer
|
|
173
|
+
is_recommended
|
|
174
|
+
is_hidden
|
|
175
|
+
answer
|
|
176
|
+
admin_note
|
|
177
|
+
like_about
|
|
178
|
+
not_like_about
|
|
179
|
+
guest_email
|
|
180
|
+
plus_review
|
|
181
|
+
minus_review
|
|
182
|
+
report_abuse
|
|
183
|
+
country
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
products {
|
|
187
|
+
total_count
|
|
188
|
+
page_info {
|
|
189
|
+
page_size
|
|
190
|
+
current_page
|
|
191
|
+
}
|
|
192
|
+
items {
|
|
193
|
+
id
|
|
194
|
+
name
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
`;
|
|
200
|
+
|
|
201
|
+
export default {
|
|
202
|
+
getStoreConfigData: GET_STORE_CONFIG_DATA,
|
|
203
|
+
getSellerDetailQuery: GET_SELLER_DETAIL_QUERY
|
|
204
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client';
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
import { useAppContext } from '@magento/peregrine/lib/context/app';
|
|
5
|
+
|
|
6
|
+
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
7
|
+
import DEFAULT_OPERATIONS from './seller.gql';
|
|
8
|
+
|
|
9
|
+
export const useSeller = props => {
|
|
10
|
+
const { mapSeller } = props;
|
|
11
|
+
|
|
12
|
+
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
13
|
+
const { getStoreConfigData, getSellerDetailQuery } = operations;
|
|
14
|
+
const { pathname } = useLocation();
|
|
15
|
+
const [
|
|
16
|
+
,
|
|
17
|
+
{
|
|
18
|
+
actions: { setPageLoading }
|
|
19
|
+
}
|
|
20
|
+
] = useAppContext();
|
|
21
|
+
|
|
22
|
+
const { data: storeConfigData } = useQuery(getStoreConfigData, {
|
|
23
|
+
fetchPolicy: 'cache-and-network',
|
|
24
|
+
nextFetchPolicy: 'cache-first'
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const slug = pathname.split('/').pop();
|
|
28
|
+
const productUrlSuffix = storeConfigData?.storeConfig?.product_url_suffix;
|
|
29
|
+
const urlKey = productUrlSuffix ? slug.replace(productUrlSuffix, '') : slug;
|
|
30
|
+
|
|
31
|
+
const getOtherInfo = true;
|
|
32
|
+
const getProducts = true;
|
|
33
|
+
|
|
34
|
+
const { error, loading, data } = useQuery(getSellerDetailQuery, {
|
|
35
|
+
fetchPolicy: 'cache-and-network',
|
|
36
|
+
nextFetchPolicy: 'cache-first',
|
|
37
|
+
skip: !storeConfigData,
|
|
38
|
+
variables: {
|
|
39
|
+
urlKey,
|
|
40
|
+
getOtherInfo,
|
|
41
|
+
getProducts
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const isBackgroundLoading = !!data && loading;
|
|
46
|
+
|
|
47
|
+
const seller = useMemo(() => {
|
|
48
|
+
if (!data) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const seller = data.sellerByUrl;
|
|
53
|
+
|
|
54
|
+
if (!seller) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return mapSeller(seller);
|
|
59
|
+
}, [data, mapSeller, urlKey]);
|
|
60
|
+
|
|
61
|
+
// Update the page indicator if the GraphQL query is in flight.
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
setPageLoading(isBackgroundLoading);
|
|
64
|
+
}, [isBackgroundLoading, setPageLoading]);
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
error,
|
|
68
|
+
loading,
|
|
69
|
+
seller
|
|
70
|
+
};
|
|
71
|
+
};
|