@riosst100/pwa-marketplace 1.2.5 → 1.2.7
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/.github/workflows/dependabot.yml +28 -28
- package/package.json +18 -18
- 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/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 +249 -250
- 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/SellerInformation/index.js +1 -1
- package/src/components/SellerInformation/sellerInformation.js +90 -118
- package/src/components/SellerLocation/index.js +1 -1
- package/src/components/SellerLocation/sellerLocation.js +19 -23
- package/src/components/SellerLocation/sellerLocationItem.js +27 -25
- package/src/components/SellerPage/sellerPage.js +9 -9
- package/src/components/SellerProducts/sellerProducts.js +47 -67
- 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 +139 -204
- package/src/talons/Seller/useSeller.js +66 -71
- 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
- package/src/components/OperatingHours/index.js +0 -1
- package/src/components/OperatingHours/operatingHours.js +0 -32
- package/src/components/Seller/sellerAddressCard.js +0 -48
- package/src/components/SellerDetail/index.js +0 -1
- package/src/components/SellerDetail/sellerDetail.js +0 -158
- package/src/components/SellerPage/core.js +0 -10
- package/src/talons/SellerProducts/useSellerProducts.js +0 -129
|
@@ -1,43 +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
|
-
};
|
|
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
|
+
};
|
|
@@ -1,13 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,75 +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
|
-
};
|
|
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
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
.heading {
|
|
2
|
-
composes: pt-3 from global;
|
|
3
|
-
composes: text-sm from global;
|
|
4
|
-
composes: text-subtle from global;
|
|
5
|
-
composes: uppercase from global;
|
|
6
|
-
}
|
|
1
|
+
.heading {
|
|
2
|
+
composes: pt-3 from global;
|
|
3
|
+
composes: text-sm from global;
|
|
4
|
+
composes: text-subtle from global;
|
|
5
|
+
composes: uppercase from global;
|
|
6
|
+
}
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { useEffect, useMemo } from 'react';
|
|
2
|
-
import { useHistory } from 'react-router-dom';
|
|
3
|
-
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
4
|
-
|
|
5
|
-
const storage = new BrowserPersistence();
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This component checks for use of a store code in the url that is not the
|
|
9
|
-
* current base. If found, it updates the local storage values for code/currency
|
|
10
|
-
* and reloads the page so that they are used in the graphQL headers.
|
|
11
|
-
*/
|
|
12
|
-
const StoreCodeRoute = () => {
|
|
13
|
-
const history = useHistory();
|
|
14
|
-
|
|
15
|
-
const websiteCodes = [];
|
|
16
|
-
const websiteStores = useMemo(() => ({}), []);
|
|
17
|
-
const storeCurrencies = useMemo(() => ({}), []);
|
|
18
|
-
const storeSecureBaseMediaUrl = useMemo(() => ({}), []);
|
|
19
|
-
|
|
20
|
-
AVAILABLE_WEBSITES.forEach(store => {
|
|
21
|
-
websiteCodes.push(store.website_code);
|
|
22
|
-
websiteStores[store.website_code] = store.store_code;
|
|
23
|
-
storeCurrencies[store.store_code] = store.default_display_currency_code;
|
|
24
|
-
storeSecureBaseMediaUrl[store.store_code] = store.secure_base_media_url;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Sort by length (longest first) to avoid false hits ie "en" matching just
|
|
28
|
-
// the "/en" in "/en-us/home.html" when "en-us" is also in storeCodes.
|
|
29
|
-
websiteCodes.sort((a, b) => b.length - a.length);
|
|
30
|
-
|
|
31
|
-
// Find the store code in the url. This will always be the first path.
|
|
32
|
-
// ie `https://example.com/fr/foo/baz.html` => `fr`.
|
|
33
|
-
const { location } = globalThis;
|
|
34
|
-
const match = location && location.pathname.split("/")[1];
|
|
35
|
-
let websiteCodeInUrl = websiteCodes.find((str) => str === match);
|
|
36
|
-
|
|
37
|
-
// Determine what the current store code is using the configured basename.
|
|
38
|
-
const currentWebsiteCode = storage && storage.getItem('website_code') || process.env.WEBSITE_CODE;
|
|
39
|
-
|
|
40
|
-
// If we find a store code in the url that is not the current one, update
|
|
41
|
-
// the storage value and refresh so that we start using the new code.
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (!websiteCodeInUrl) {
|
|
44
|
-
history.replace(location.pathname)
|
|
45
|
-
} else if (websiteCodeInUrl && websiteCodeInUrl !== currentWebsiteCode) {
|
|
46
|
-
let storeCodeInUrl = websiteStores[websiteCodeInUrl];
|
|
47
|
-
|
|
48
|
-
storage.setItem('store_view_code', storeCodeInUrl);
|
|
49
|
-
storage.setItem('website_code', websiteCodeInUrl);
|
|
50
|
-
storage.setItem(
|
|
51
|
-
'store_view_currency',
|
|
52
|
-
storeCurrencies[storeCodeInUrl]
|
|
53
|
-
);
|
|
54
|
-
storage.setItem(
|
|
55
|
-
'store_view_secure_base_media_url',
|
|
56
|
-
storeSecureBaseMediaUrl[storeCodeInUrl]
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
// We're required to reload the page as the basename doesn't
|
|
60
|
-
// change entirely without a full page reload.
|
|
61
|
-
history.go(0);
|
|
62
|
-
}
|
|
63
|
-
}, [
|
|
64
|
-
websiteCodeInUrl,
|
|
65
|
-
// currentWebsiteCode,
|
|
66
|
-
history
|
|
67
|
-
// storeCodeInUrl,
|
|
68
|
-
// storeCurrencies,
|
|
69
|
-
// storeSecureBaseMediaUrl
|
|
70
|
-
]);
|
|
71
|
-
|
|
72
|
-
return null;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default StoreCodeRoute;
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { useHistory } from 'react-router-dom';
|
|
3
|
+
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
4
|
+
|
|
5
|
+
const storage = new BrowserPersistence();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This component checks for use of a store code in the url that is not the
|
|
9
|
+
* current base. If found, it updates the local storage values for code/currency
|
|
10
|
+
* and reloads the page so that they are used in the graphQL headers.
|
|
11
|
+
*/
|
|
12
|
+
const StoreCodeRoute = () => {
|
|
13
|
+
const history = useHistory();
|
|
14
|
+
|
|
15
|
+
const websiteCodes = [];
|
|
16
|
+
const websiteStores = useMemo(() => ({}), []);
|
|
17
|
+
const storeCurrencies = useMemo(() => ({}), []);
|
|
18
|
+
const storeSecureBaseMediaUrl = useMemo(() => ({}), []);
|
|
19
|
+
|
|
20
|
+
AVAILABLE_WEBSITES.forEach(store => {
|
|
21
|
+
websiteCodes.push(store.website_code);
|
|
22
|
+
websiteStores[store.website_code] = store.store_code;
|
|
23
|
+
storeCurrencies[store.store_code] = store.default_display_currency_code;
|
|
24
|
+
storeSecureBaseMediaUrl[store.store_code] = store.secure_base_media_url;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Sort by length (longest first) to avoid false hits ie "en" matching just
|
|
28
|
+
// the "/en" in "/en-us/home.html" when "en-us" is also in storeCodes.
|
|
29
|
+
websiteCodes.sort((a, b) => b.length - a.length);
|
|
30
|
+
|
|
31
|
+
// Find the store code in the url. This will always be the first path.
|
|
32
|
+
// ie `https://example.com/fr/foo/baz.html` => `fr`.
|
|
33
|
+
const { location } = globalThis;
|
|
34
|
+
const match = location && location.pathname.split("/")[1];
|
|
35
|
+
let websiteCodeInUrl = websiteCodes.find((str) => str === match);
|
|
36
|
+
|
|
37
|
+
// Determine what the current store code is using the configured basename.
|
|
38
|
+
const currentWebsiteCode = storage && storage.getItem('website_code') || process.env.WEBSITE_CODE;
|
|
39
|
+
|
|
40
|
+
// If we find a store code in the url that is not the current one, update
|
|
41
|
+
// the storage value and refresh so that we start using the new code.
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!websiteCodeInUrl) {
|
|
44
|
+
history.replace(location.pathname)
|
|
45
|
+
} else if (websiteCodeInUrl && websiteCodeInUrl !== currentWebsiteCode) {
|
|
46
|
+
let storeCodeInUrl = websiteStores[websiteCodeInUrl];
|
|
47
|
+
|
|
48
|
+
storage.setItem('store_view_code', storeCodeInUrl);
|
|
49
|
+
storage.setItem('website_code', websiteCodeInUrl);
|
|
50
|
+
storage.setItem(
|
|
51
|
+
'store_view_currency',
|
|
52
|
+
storeCurrencies[storeCodeInUrl]
|
|
53
|
+
);
|
|
54
|
+
storage.setItem(
|
|
55
|
+
'store_view_secure_base_media_url',
|
|
56
|
+
storeSecureBaseMediaUrl[storeCodeInUrl]
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// We're required to reload the page as the basename doesn't
|
|
60
|
+
// change entirely without a full page reload.
|
|
61
|
+
history.go(0);
|
|
62
|
+
}
|
|
63
|
+
}, [
|
|
64
|
+
websiteCodeInUrl,
|
|
65
|
+
// currentWebsiteCode,
|
|
66
|
+
history
|
|
67
|
+
// storeCodeInUrl,
|
|
68
|
+
// storeCurrencies,
|
|
69
|
+
// storeSecureBaseMediaUrl
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
return null;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default StoreCodeRoute;
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module VeniaUI/Targets
|
|
3
|
-
*/
|
|
4
|
-
const { Targetables } = require('@magento/pwa-buildpack');
|
|
5
|
-
const CategoryListProductAttributes = require('./CategoryListProductAttributes');
|
|
6
|
-
const RichContentRendererList = require('./RichContentRendererList');
|
|
7
|
-
const makeRoutesTarget = require('./makeRoutesTarget');
|
|
8
|
-
const CheckoutPagePaymentsList = require('./CheckoutPagePaymentsList');
|
|
9
|
-
const SavedPaymentTypes = require('./SavedPaymentTypes');
|
|
10
|
-
const EditablePaymentTypes = require('./EditablePaymentTypes');
|
|
11
|
-
const SummaryPaymentTypes = require('./SummaryPaymentTypes');
|
|
12
|
-
const RootShimmerTypes = require('./RootShimmerTypes');
|
|
13
|
-
|
|
14
|
-
module.exports = veniaTargets => {
|
|
15
|
-
const venia = Targetables.using(veniaTargets);
|
|
16
|
-
|
|
17
|
-
venia.setSpecialFeatures(
|
|
18
|
-
'cssModules',
|
|
19
|
-
'esModules',
|
|
20
|
-
'graphqlQueries',
|
|
21
|
-
'rootComponents',
|
|
22
|
-
'upward'
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
makeRoutesTarget(venia);
|
|
26
|
-
|
|
27
|
-
const renderers = new RichContentRendererList(venia);
|
|
28
|
-
|
|
29
|
-
renderers.add({
|
|
30
|
-
componentName: 'PlainHtmlRenderer',
|
|
31
|
-
importPath: './plainHtmlRenderer'
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const checkoutPagePaymentsList = new CheckoutPagePaymentsList(venia);
|
|
35
|
-
checkoutPagePaymentsList.add({
|
|
36
|
-
paymentCode: 'braintree',
|
|
37
|
-
importPath:
|
|
38
|
-
'@magento/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard'
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const savedPaymentTypes = new SavedPaymentTypes(venia);
|
|
42
|
-
savedPaymentTypes.add({
|
|
43
|
-
paymentCode: 'braintree',
|
|
44
|
-
importPath:
|
|
45
|
-
'@magento/venia-ui/lib/components/SavedPaymentsPage/creditCard'
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const editablePayments = new EditablePaymentTypes(venia);
|
|
49
|
-
editablePayments.add({
|
|
50
|
-
paymentCode: 'braintree',
|
|
51
|
-
importPath:
|
|
52
|
-
'@magento/venia-ui/lib/components/CheckoutPage/PaymentInformation/editCard'
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const summaryPagePaymentTypes = new SummaryPaymentTypes(venia);
|
|
56
|
-
summaryPagePaymentTypes.add({
|
|
57
|
-
paymentCode: 'braintree',
|
|
58
|
-
importPath:
|
|
59
|
-
'@magento/venia-ui/lib/components/CheckoutPage/PaymentInformation/braintreeSummary'
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
new CategoryListProductAttributes(venia);
|
|
63
|
-
|
|
64
|
-
const rootShimmerTypes = new RootShimmerTypes(venia);
|
|
65
|
-
rootShimmerTypes.add({
|
|
66
|
-
shimmerType: 'CATEGORY_SHIMMER',
|
|
67
|
-
importPath:
|
|
68
|
-
'@magento/venia-ui/lib/RootComponents/Category/categoryContent.shimmer'
|
|
69
|
-
});
|
|
70
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @module VeniaUI/Targets
|
|
3
|
+
*/
|
|
4
|
+
const { Targetables } = require('@magento/pwa-buildpack');
|
|
5
|
+
const CategoryListProductAttributes = require('./CategoryListProductAttributes');
|
|
6
|
+
const RichContentRendererList = require('./RichContentRendererList');
|
|
7
|
+
const makeRoutesTarget = require('./makeRoutesTarget');
|
|
8
|
+
const CheckoutPagePaymentsList = require('./CheckoutPagePaymentsList');
|
|
9
|
+
const SavedPaymentTypes = require('./SavedPaymentTypes');
|
|
10
|
+
const EditablePaymentTypes = require('./EditablePaymentTypes');
|
|
11
|
+
const SummaryPaymentTypes = require('./SummaryPaymentTypes');
|
|
12
|
+
const RootShimmerTypes = require('./RootShimmerTypes');
|
|
13
|
+
|
|
14
|
+
module.exports = veniaTargets => {
|
|
15
|
+
const venia = Targetables.using(veniaTargets);
|
|
16
|
+
|
|
17
|
+
venia.setSpecialFeatures(
|
|
18
|
+
'cssModules',
|
|
19
|
+
'esModules',
|
|
20
|
+
'graphqlQueries',
|
|
21
|
+
'rootComponents',
|
|
22
|
+
'upward'
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
makeRoutesTarget(venia);
|
|
26
|
+
|
|
27
|
+
const renderers = new RichContentRendererList(venia);
|
|
28
|
+
|
|
29
|
+
renderers.add({
|
|
30
|
+
componentName: 'PlainHtmlRenderer',
|
|
31
|
+
importPath: './plainHtmlRenderer'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const checkoutPagePaymentsList = new CheckoutPagePaymentsList(venia);
|
|
35
|
+
checkoutPagePaymentsList.add({
|
|
36
|
+
paymentCode: 'braintree',
|
|
37
|
+
importPath:
|
|
38
|
+
'@magento/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard'
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const savedPaymentTypes = new SavedPaymentTypes(venia);
|
|
42
|
+
savedPaymentTypes.add({
|
|
43
|
+
paymentCode: 'braintree',
|
|
44
|
+
importPath:
|
|
45
|
+
'@magento/venia-ui/lib/components/SavedPaymentsPage/creditCard'
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const editablePayments = new EditablePaymentTypes(venia);
|
|
49
|
+
editablePayments.add({
|
|
50
|
+
paymentCode: 'braintree',
|
|
51
|
+
importPath:
|
|
52
|
+
'@magento/venia-ui/lib/components/CheckoutPage/PaymentInformation/editCard'
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const summaryPagePaymentTypes = new SummaryPaymentTypes(venia);
|
|
56
|
+
summaryPagePaymentTypes.add({
|
|
57
|
+
paymentCode: 'braintree',
|
|
58
|
+
importPath:
|
|
59
|
+
'@magento/venia-ui/lib/components/CheckoutPage/PaymentInformation/braintreeSummary'
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
new CategoryListProductAttributes(venia);
|
|
63
|
+
|
|
64
|
+
const rootShimmerTypes = new RootShimmerTypes(venia);
|
|
65
|
+
rootShimmerTypes.add({
|
|
66
|
+
shimmerType: 'CATEGORY_SHIMMER',
|
|
67
|
+
importPath:
|
|
68
|
+
'@magento/venia-ui/lib/RootComponents/Category/categoryContent.shimmer'
|
|
69
|
+
});
|
|
70
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
query getAvailableWebsitesConfigData {
|
|
2
|
-
availableStoresByUserIp {
|
|
3
|
-
store_code
|
|
4
|
-
id
|
|
5
|
-
secure_base_media_url
|
|
6
|
-
store_name
|
|
7
|
-
default_display_currency_code
|
|
8
|
-
website_code
|
|
9
|
-
is_default_store
|
|
10
|
-
website_code
|
|
11
|
-
website_name
|
|
12
|
-
is_suggested
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
query getAvailableWebsitesConfigData {
|
|
2
|
+
availableStoresByUserIp {
|
|
3
|
+
store_code
|
|
4
|
+
id
|
|
5
|
+
secure_base_media_url
|
|
6
|
+
store_name
|
|
7
|
+
default_display_currency_code
|
|
8
|
+
website_code
|
|
9
|
+
is_default_store
|
|
10
|
+
website_code
|
|
11
|
+
website_name
|
|
12
|
+
is_suggested
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/queries/index.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Normal `require` doesn't know what to do with .graphql files, so this helper function
|
|
6
|
-
* simply imports their contents as a string.
|
|
7
|
-
* @see https://github.com/apollographql/apollo-server/issues/1175#issuecomment-397257339.
|
|
8
|
-
*
|
|
9
|
-
* @param {String} filepath - A relative path to a .graphql file to read.
|
|
10
|
-
* @returns {String} - The contents of the file as a string.
|
|
11
|
-
*/
|
|
12
|
-
const requireGraphQL = filePath => {
|
|
13
|
-
const absolutePath = path.resolve(__dirname, filePath);
|
|
14
|
-
return stripComments(fs.readFileSync(absolutePath, { encoding: 'utf8' }));
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const singleLineCommentRegex = /(^#.*\n)/gm;
|
|
18
|
-
const stripComments = string => {
|
|
19
|
-
return string.replace(singleLineCommentRegex, '');
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Import all the build-time queries.
|
|
23
|
-
const getAvailableWebsitesConfigData = requireGraphQL(
|
|
24
|
-
'./getAvailableWebsitesConfigData.graphql'
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
// Export the queries for use by the rest of buildpack.
|
|
28
|
-
module.exports = {
|
|
29
|
-
getAvailableWebsitesConfigData
|
|
30
|
-
};
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Normal `require` doesn't know what to do with .graphql files, so this helper function
|
|
6
|
+
* simply imports their contents as a string.
|
|
7
|
+
* @see https://github.com/apollographql/apollo-server/issues/1175#issuecomment-397257339.
|
|
8
|
+
*
|
|
9
|
+
* @param {String} filepath - A relative path to a .graphql file to read.
|
|
10
|
+
* @returns {String} - The contents of the file as a string.
|
|
11
|
+
*/
|
|
12
|
+
const requireGraphQL = filePath => {
|
|
13
|
+
const absolutePath = path.resolve(__dirname, filePath);
|
|
14
|
+
return stripComments(fs.readFileSync(absolutePath, { encoding: 'utf8' }));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const singleLineCommentRegex = /(^#.*\n)/gm;
|
|
18
|
+
const stripComments = string => {
|
|
19
|
+
return string.replace(singleLineCommentRegex, '');
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Import all the build-time queries.
|
|
23
|
+
const getAvailableWebsitesConfigData = requireGraphQL(
|
|
24
|
+
'./getAvailableWebsitesConfigData.graphql'
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// Export the queries for use by the rest of buildpack.
|
|
28
|
+
module.exports = {
|
|
29
|
+
getAvailableWebsitesConfigData
|
|
30
|
+
};
|