@riosst100/pwa-marketplace 1.2.7 → 1.2.9
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/Utilities/graphQL.js +76 -76
- package/src/componentOverrideMapping.js +17 -17
- package/src/components/BecomeSeller/becomeSeller.js +335 -335
- package/src/components/BecomeSeller/becomeSeller.module.css +46 -46
- package/src/components/BecomeSellerLink/becomeSellerLink.js +52 -52
- package/src/components/BecomeSellerLink/becomeSellerLink.module.css +12 -12
- package/src/components/BecomeSellerPage/becomeSellerPage.js +45 -45
- package/src/components/BecomeSellerPage/becomeSellerPage.module.css +21 -21
- package/src/components/Filter/index.js +53 -53
- package/src/components/Header/becomeSellerLink.js +28 -28
- package/src/components/Header/becomeSellerLink.module.css +12 -12
- package/src/components/Header/websiteSwitcher.js +109 -109
- package/src/components/OperatingHours/index.js +1 -0
- package/src/components/OperatingHours/operatingHours.js +35 -0
- package/src/components/Pagination/index.js +49 -49
- package/src/components/PhoneTextInput/phoneTextInput.module.css +21 -21
- package/src/components/ProductItem/index.js +50 -50
- package/src/components/Search/index.js +16 -16
- package/src/components/Seller/index.js +1 -1
- package/src/components/Seller/seller.js +42 -249
- package/src/components/Seller/sellerAddressCard.js +48 -0
- package/src/components/SellerAccountPage/sellerAccountPage.js +110 -110
- package/src/components/SellerAccountPage/sellerAccountPage.module.css +55 -55
- package/src/components/SellerCountry/sellerCountry.gql.js +11 -11
- package/src/components/SellerDetail/index.js +1 -0
- package/src/components/SellerDetail/sellerDetail.js +166 -0
- package/src/components/SellerInformation/index.js +1 -1
- package/src/components/SellerInformation/sellerInformation.js +86 -90
- package/src/components/SellerLocation/index.js +1 -1
- package/src/components/SellerLocation/sellerLocation.js +19 -19
- package/src/components/SellerLocation/sellerLocationItem.js +27 -27
- package/src/components/SellerPage/sellerPage.js +9 -9
- package/src/components/SellerProducts/sellerProducts.js +46 -46
- package/src/components/SellerReview/index.js +1 -1
- package/src/components/SellerReview/sellerReview.js +143 -143
- package/src/components/SellerReviewItem/sellerReviewItem.js +60 -60
- package/src/components/SellerVerification/sellerVerification.js +198 -198
- package/src/components/SellerVerification/sellerVerification.module.css +47 -47
- package/src/components/SellerVerificationPage/sellerVerificationPage.js +43 -43
- package/src/components/SellerVerificationPage/sellerVerificationPage.module.css +21 -21
- package/src/components/SortBy/index.js +24 -24
- package/src/components/WebsiteSwitcher/websiteSwitcher.js +109 -109
- package/src/components/commons/Slider/index.js +13 -13
- package/src/components/commons/Tabs/index.js +64 -64
- package/src/index.js +6 -6
- package/src/intercept.js +113 -113
- package/src/moduleOverrideWebpackPlugin.js +70 -70
- package/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js +96 -96
- package/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js +74 -74
- package/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js +208 -208
- package/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js +45 -45
- package/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js +204 -204
- package/src/overwrites/peregrine/lib/talons/Region/useRegion.js +102 -102
- package/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js +56 -56
- package/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js +226 -226
- package/src/overwrites/peregrine/lib/util/deriveErrorMessage.js +34 -34
- package/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql +11 -11
- package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +112 -112
- package/src/overwrites/venia-ui/lib/components/Header/header.js +130 -130
- package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +105 -105
- package/src/overwrites/venia-ui/lib/components/Header/switcherItem.js +47 -47
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -91
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -123
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -61
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -50
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -114
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -71
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -59
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -34
- package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -1
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -90
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -12
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -156
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +30 -30
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -89
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +42 -42
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -99
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -28
- package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -11
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -72
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -30
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -69
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -7
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -12
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -52
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -82
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -87
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -45
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -43
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -45
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -110
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -172
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -62
- package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -1
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -74
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +49 -49
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -40
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -48
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -13
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -49
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -97
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -24
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -43
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -13
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -75
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -6
- package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +75 -75
- package/src/overwrites/venia-ui/lib/targets/venia-ui-intercept.js +70 -70
- package/src/queries/getAvailableWebsitesConfigData.graphql +14 -14
- package/src/queries/index.js +30 -30
- package/src/talons/BecomeSeller/becomeSeller.gql.js +45 -45
- package/src/talons/BecomeSeller/useBecomeSeller.js +145 -145
- package/src/talons/BecomeSellerLink/useBecomeSellerLink.js +11 -11
- package/src/talons/BecomeSellerPage/useBecomeSellerPage.js +76 -76
- package/src/talons/Header/useBecomeSellerLink.js +13 -13
- package/src/talons/Header/useWebsiteSwitcher.js +218 -218
- package/src/talons/Seller/seller.gql.js +204 -139
- package/src/talons/Seller/useSeller.js +71 -66
- package/src/talons/SellerAccountPage/useSellerAccountPage.js +174 -174
- package/src/talons/SellerCountry/useSellerCountry.js +25 -25
- package/src/talons/WebsiteByIp/getWebsiteByIp.gql.js +13 -13
- package/src/talons/WebsiteByIp/useWebsiteByIp.js +34 -34
- package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +218 -218
- package/src/theme/vars.js +6 -6
- package/src/util/mapSeller.js +7 -7
|
@@ -1,139 +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
|
|
15
|
-
sellerByUrl(seller_url: $urlKey) {
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
};
|
|
@@ -1,66 +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
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
+
};
|