@riosst100/pwa-marketplace 1.2.7 → 1.2.8
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 +57 -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 +161 -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,105 +1,105 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shape, string } from 'prop-types';
|
|
3
|
-
|
|
4
|
-
import { useStoreSwitcher } from '@magento/peregrine/lib/talons/Header/useStoreSwitcher';
|
|
5
|
-
import { availableRoutes } from '@magento/venia-ui/lib/components/Routes/routes';
|
|
6
|
-
|
|
7
|
-
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
8
|
-
import defaultClasses from '@magento/venia-ui/lib/components/Header/storeSwitcher.module.css';
|
|
9
|
-
import SwitcherItem from '@magento/venia-ui/lib/components/Header/switcherItem';
|
|
10
|
-
import Shimmer from '@magento/venia-ui/lib/components/Header/storeSwitcher.shimmer';
|
|
11
|
-
|
|
12
|
-
const StoreSwitcher = props => {
|
|
13
|
-
const {
|
|
14
|
-
availableStores,
|
|
15
|
-
currentGroupName,
|
|
16
|
-
currentStoreName,
|
|
17
|
-
handleSwitchStore,
|
|
18
|
-
storeGroups,
|
|
19
|
-
storeMenuRef,
|
|
20
|
-
storeMenuTriggerRef,
|
|
21
|
-
storeMenuIsOpen,
|
|
22
|
-
handleTriggerClick
|
|
23
|
-
} = useStoreSwitcher({ availableRoutes });
|
|
24
|
-
|
|
25
|
-
const classes = useStyle(defaultClasses, props.classes);
|
|
26
|
-
const menuClassName = storeMenuIsOpen ? classes.menu_open : classes.menu;
|
|
27
|
-
|
|
28
|
-
if (!availableStores) return <Shimmer />;
|
|
29
|
-
|
|
30
|
-
const groups = [];
|
|
31
|
-
|
|
32
|
-
storeGroups.forEach((group, key) => {
|
|
33
|
-
const stores = [];
|
|
34
|
-
group.forEach(({ storeName, isCurrent, storeCode, websiteCode }) => {
|
|
35
|
-
let label = `${storeName}`;
|
|
36
|
-
|
|
37
|
-
stores.push(
|
|
38
|
-
<li
|
|
39
|
-
aria-selected={currentStoreName}
|
|
40
|
-
role="option"
|
|
41
|
-
key={storeCode}
|
|
42
|
-
className={classes.menuItem}
|
|
43
|
-
data-cy="StoreSwitcher-view"
|
|
44
|
-
>
|
|
45
|
-
<SwitcherItem
|
|
46
|
-
active={isCurrent}
|
|
47
|
-
onClick={handleSwitchStore}
|
|
48
|
-
option={storeCode}
|
|
49
|
-
option2={websiteCode}
|
|
50
|
-
>
|
|
51
|
-
{label}
|
|
52
|
-
</SwitcherItem>
|
|
53
|
-
</li>
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
groups.push(
|
|
58
|
-
<ul
|
|
59
|
-
role="listbox"
|
|
60
|
-
className={classes.groupList}
|
|
61
|
-
key={key}
|
|
62
|
-
data-cy="StoreSwitcher-group"
|
|
63
|
-
>
|
|
64
|
-
{stores}
|
|
65
|
-
</ul>
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<div className={classes.root} data-cy="StoreSwitcher-root">
|
|
71
|
-
<button
|
|
72
|
-
data-cy="StoreSwitcher-triggerButton"
|
|
73
|
-
className={classes.trigger}
|
|
74
|
-
aria-label={currentStoreName || ''}
|
|
75
|
-
onClick={handleTriggerClick}
|
|
76
|
-
ref={storeMenuTriggerRef}
|
|
77
|
-
data-cy="StoreSwitcher-trigger"
|
|
78
|
-
aria-expanded={storeMenuIsOpen}
|
|
79
|
-
>
|
|
80
|
-
{currentStoreName || ''}
|
|
81
|
-
</button>
|
|
82
|
-
<div
|
|
83
|
-
ref={storeMenuRef}
|
|
84
|
-
className={menuClassName}
|
|
85
|
-
data-cy="StoreSwitcher-menu"
|
|
86
|
-
>
|
|
87
|
-
<div className={classes.groups}>{groups}</div>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default StoreSwitcher;
|
|
94
|
-
|
|
95
|
-
StoreSwitcher.propTypes = {
|
|
96
|
-
classes: shape({
|
|
97
|
-
groupList: string,
|
|
98
|
-
groups: string,
|
|
99
|
-
menu: string,
|
|
100
|
-
menu_open: string,
|
|
101
|
-
menuItem: string,
|
|
102
|
-
root: string,
|
|
103
|
-
trigger: string
|
|
104
|
-
})
|
|
105
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shape, string } from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useStoreSwitcher } from '@magento/peregrine/lib/talons/Header/useStoreSwitcher';
|
|
5
|
+
import { availableRoutes } from '@magento/venia-ui/lib/components/Routes/routes';
|
|
6
|
+
|
|
7
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
8
|
+
import defaultClasses from '@magento/venia-ui/lib/components/Header/storeSwitcher.module.css';
|
|
9
|
+
import SwitcherItem from '@magento/venia-ui/lib/components/Header/switcherItem';
|
|
10
|
+
import Shimmer from '@magento/venia-ui/lib/components/Header/storeSwitcher.shimmer';
|
|
11
|
+
|
|
12
|
+
const StoreSwitcher = props => {
|
|
13
|
+
const {
|
|
14
|
+
availableStores,
|
|
15
|
+
currentGroupName,
|
|
16
|
+
currentStoreName,
|
|
17
|
+
handleSwitchStore,
|
|
18
|
+
storeGroups,
|
|
19
|
+
storeMenuRef,
|
|
20
|
+
storeMenuTriggerRef,
|
|
21
|
+
storeMenuIsOpen,
|
|
22
|
+
handleTriggerClick
|
|
23
|
+
} = useStoreSwitcher({ availableRoutes });
|
|
24
|
+
|
|
25
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
26
|
+
const menuClassName = storeMenuIsOpen ? classes.menu_open : classes.menu;
|
|
27
|
+
|
|
28
|
+
if (!availableStores) return <Shimmer />;
|
|
29
|
+
|
|
30
|
+
const groups = [];
|
|
31
|
+
|
|
32
|
+
storeGroups.forEach((group, key) => {
|
|
33
|
+
const stores = [];
|
|
34
|
+
group.forEach(({ storeName, isCurrent, storeCode, websiteCode }) => {
|
|
35
|
+
let label = `${storeName}`;
|
|
36
|
+
|
|
37
|
+
stores.push(
|
|
38
|
+
<li
|
|
39
|
+
aria-selected={currentStoreName}
|
|
40
|
+
role="option"
|
|
41
|
+
key={storeCode}
|
|
42
|
+
className={classes.menuItem}
|
|
43
|
+
data-cy="StoreSwitcher-view"
|
|
44
|
+
>
|
|
45
|
+
<SwitcherItem
|
|
46
|
+
active={isCurrent}
|
|
47
|
+
onClick={handleSwitchStore}
|
|
48
|
+
option={storeCode}
|
|
49
|
+
option2={websiteCode}
|
|
50
|
+
>
|
|
51
|
+
{label}
|
|
52
|
+
</SwitcherItem>
|
|
53
|
+
</li>
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
groups.push(
|
|
58
|
+
<ul
|
|
59
|
+
role="listbox"
|
|
60
|
+
className={classes.groupList}
|
|
61
|
+
key={key}
|
|
62
|
+
data-cy="StoreSwitcher-group"
|
|
63
|
+
>
|
|
64
|
+
{stores}
|
|
65
|
+
</ul>
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div className={classes.root} data-cy="StoreSwitcher-root">
|
|
71
|
+
<button
|
|
72
|
+
data-cy="StoreSwitcher-triggerButton"
|
|
73
|
+
className={classes.trigger}
|
|
74
|
+
aria-label={currentStoreName || ''}
|
|
75
|
+
onClick={handleTriggerClick}
|
|
76
|
+
ref={storeMenuTriggerRef}
|
|
77
|
+
data-cy="StoreSwitcher-trigger"
|
|
78
|
+
aria-expanded={storeMenuIsOpen}
|
|
79
|
+
>
|
|
80
|
+
{currentStoreName || ''}
|
|
81
|
+
</button>
|
|
82
|
+
<div
|
|
83
|
+
ref={storeMenuRef}
|
|
84
|
+
className={menuClassName}
|
|
85
|
+
data-cy="StoreSwitcher-menu"
|
|
86
|
+
>
|
|
87
|
+
<div className={classes.groups}>{groups}</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default StoreSwitcher;
|
|
94
|
+
|
|
95
|
+
StoreSwitcher.propTypes = {
|
|
96
|
+
classes: shape({
|
|
97
|
+
groupList: string,
|
|
98
|
+
groups: string,
|
|
99
|
+
menu: string,
|
|
100
|
+
menu_open: string,
|
|
101
|
+
menuItem: string,
|
|
102
|
+
root: string,
|
|
103
|
+
trigger: string
|
|
104
|
+
})
|
|
105
|
+
};
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { Check } from 'react-feather';
|
|
3
|
-
import { bool, func, shape, string } from 'prop-types';
|
|
4
|
-
|
|
5
|
-
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
6
|
-
import Icon from '@magento/venia-ui/lib/components/Icon/icon';
|
|
7
|
-
import defaultClasses from '@magento/venia-ui/lib/components/Header/switcherItem.module.css';
|
|
8
|
-
|
|
9
|
-
const SwitcherItem = props => {
|
|
10
|
-
const { active, onClick, option, option2, children } = props;
|
|
11
|
-
const classes = useStyle(defaultClasses, props.classes);
|
|
12
|
-
|
|
13
|
-
const handleClick = useCallback(() => {
|
|
14
|
-
onClick(option, option2);
|
|
15
|
-
}, [option, option2, onClick]);
|
|
16
|
-
|
|
17
|
-
const activeIcon = active ? (
|
|
18
|
-
<Icon data-cy="SwitcherItem-activeIcon" size={20} src={Check} />
|
|
19
|
-
) : null;
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<button
|
|
23
|
-
data-cy="SwitcherItem-button"
|
|
24
|
-
className={classes.root}
|
|
25
|
-
disabled={active}
|
|
26
|
-
onClick={handleClick}
|
|
27
|
-
>
|
|
28
|
-
<span className={classes.content}>
|
|
29
|
-
<span className={classes.text}>{children}</span>
|
|
30
|
-
{activeIcon}
|
|
31
|
-
</span>
|
|
32
|
-
</button>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
SwitcherItem.propTypes = {
|
|
37
|
-
active: bool,
|
|
38
|
-
classes: shape({
|
|
39
|
-
content: string,
|
|
40
|
-
root: string,
|
|
41
|
-
text: string
|
|
42
|
-
}),
|
|
43
|
-
onClick: func,
|
|
44
|
-
option: string
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default SwitcherItem;
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { Check } from 'react-feather';
|
|
3
|
+
import { bool, func, shape, string } from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
6
|
+
import Icon from '@magento/venia-ui/lib/components/Icon/icon';
|
|
7
|
+
import defaultClasses from '@magento/venia-ui/lib/components/Header/switcherItem.module.css';
|
|
8
|
+
|
|
9
|
+
const SwitcherItem = props => {
|
|
10
|
+
const { active, onClick, option, option2, children } = props;
|
|
11
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
12
|
+
|
|
13
|
+
const handleClick = useCallback(() => {
|
|
14
|
+
onClick(option, option2);
|
|
15
|
+
}, [option, option2, onClick]);
|
|
16
|
+
|
|
17
|
+
const activeIcon = active ? (
|
|
18
|
+
<Icon data-cy="SwitcherItem-activeIcon" size={20} src={Check} />
|
|
19
|
+
) : null;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<button
|
|
23
|
+
data-cy="SwitcherItem-button"
|
|
24
|
+
className={classes.root}
|
|
25
|
+
disabled={active}
|
|
26
|
+
onClick={handleClick}
|
|
27
|
+
>
|
|
28
|
+
<span className={classes.content}>
|
|
29
|
+
<span className={classes.text}>{children}</span>
|
|
30
|
+
{activeIcon}
|
|
31
|
+
</span>
|
|
32
|
+
</button>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
SwitcherItem.propTypes = {
|
|
37
|
+
active: bool,
|
|
38
|
+
classes: shape({
|
|
39
|
+
content: string,
|
|
40
|
+
root: string,
|
|
41
|
+
text: string
|
|
42
|
+
}),
|
|
43
|
+
onClick: func,
|
|
44
|
+
option: string
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default SwitcherItem;
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
-
|
|
4
|
-
import { createTestInstance } from '@magento/peregrine';
|
|
5
|
-
import { useIsInViewport } from '@magento/peregrine/lib/hooks/useIsInViewport';
|
|
6
|
-
|
|
7
|
-
import MegaMenu from '../megaMenu';
|
|
8
|
-
|
|
9
|
-
jest.mock('@magento/venia-ui/lib/classify');
|
|
10
|
-
jest.mock('@magento/peregrine/lib/hooks/useIsInViewport');
|
|
11
|
-
jest.mock('@magento/peregrine/lib/talons/MegaMenu/useMegaMenu', () => ({
|
|
12
|
-
useMegaMenu: jest.fn().mockReturnValue({
|
|
13
|
-
megaMenuData: {
|
|
14
|
-
id: 1,
|
|
15
|
-
name: 'Clothing',
|
|
16
|
-
children: [
|
|
17
|
-
{
|
|
18
|
-
id: 2,
|
|
19
|
-
name: 'Women',
|
|
20
|
-
url_path: 'women',
|
|
21
|
-
children: [
|
|
22
|
-
{
|
|
23
|
-
id: 5,
|
|
24
|
-
name: 'Bottoms',
|
|
25
|
-
url_path: 'bottoms',
|
|
26
|
-
isActive: true,
|
|
27
|
-
children: []
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: 3,
|
|
33
|
-
name: 'Men',
|
|
34
|
-
url_path: 'men',
|
|
35
|
-
children: []
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: 4,
|
|
39
|
-
name: 'Gear',
|
|
40
|
-
url_path: 'gear',
|
|
41
|
-
children: []
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
activeCategoryId: 5,
|
|
46
|
-
categoryUrlSuffix: '.html',
|
|
47
|
-
useOutsideAlerter: () => {}
|
|
48
|
-
})
|
|
49
|
-
}));
|
|
50
|
-
|
|
51
|
-
describe('#MegaMenu', () => {
|
|
52
|
-
test('useEffect', () => {
|
|
53
|
-
const useEffect = jest.spyOn(React, 'useEffect');
|
|
54
|
-
|
|
55
|
-
const mockUseEffect = () => {
|
|
56
|
-
useEffect.mockImplementationOnce(mockFunction => mockFunction());
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
mockUseEffect();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('not resetting the menu', () => {
|
|
63
|
-
const handleClickOutside = jest.fn();
|
|
64
|
-
|
|
65
|
-
expect(handleClickOutside).toHaveBeenCalledTimes(0);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('renders empty div if not in viewport', () => {
|
|
69
|
-
useIsInViewport.mockReturnValue(false);
|
|
70
|
-
|
|
71
|
-
const instance = createTestInstance(
|
|
72
|
-
<MemoryRouter>
|
|
73
|
-
<MegaMenu />
|
|
74
|
-
</MemoryRouter>
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('renders menu if in viewport', () => {
|
|
81
|
-
useIsInViewport.mockReturnValue(true);
|
|
82
|
-
|
|
83
|
-
const instance = createTestInstance(
|
|
84
|
-
<MemoryRouter>
|
|
85
|
-
<MegaMenu />
|
|
86
|
-
</MemoryRouter>
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
90
|
-
});
|
|
91
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
5
|
+
import { useIsInViewport } from '@magento/peregrine/lib/hooks/useIsInViewport';
|
|
6
|
+
|
|
7
|
+
import MegaMenu from '../megaMenu';
|
|
8
|
+
|
|
9
|
+
jest.mock('@magento/venia-ui/lib/classify');
|
|
10
|
+
jest.mock('@magento/peregrine/lib/hooks/useIsInViewport');
|
|
11
|
+
jest.mock('@magento/peregrine/lib/talons/MegaMenu/useMegaMenu', () => ({
|
|
12
|
+
useMegaMenu: jest.fn().mockReturnValue({
|
|
13
|
+
megaMenuData: {
|
|
14
|
+
id: 1,
|
|
15
|
+
name: 'Clothing',
|
|
16
|
+
children: [
|
|
17
|
+
{
|
|
18
|
+
id: 2,
|
|
19
|
+
name: 'Women',
|
|
20
|
+
url_path: 'women',
|
|
21
|
+
children: [
|
|
22
|
+
{
|
|
23
|
+
id: 5,
|
|
24
|
+
name: 'Bottoms',
|
|
25
|
+
url_path: 'bottoms',
|
|
26
|
+
isActive: true,
|
|
27
|
+
children: []
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 3,
|
|
33
|
+
name: 'Men',
|
|
34
|
+
url_path: 'men',
|
|
35
|
+
children: []
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 4,
|
|
39
|
+
name: 'Gear',
|
|
40
|
+
url_path: 'gear',
|
|
41
|
+
children: []
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
activeCategoryId: 5,
|
|
46
|
+
categoryUrlSuffix: '.html',
|
|
47
|
+
useOutsideAlerter: () => {}
|
|
48
|
+
})
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
describe('#MegaMenu', () => {
|
|
52
|
+
test('useEffect', () => {
|
|
53
|
+
const useEffect = jest.spyOn(React, 'useEffect');
|
|
54
|
+
|
|
55
|
+
const mockUseEffect = () => {
|
|
56
|
+
useEffect.mockImplementationOnce(mockFunction => mockFunction());
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
mockUseEffect();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('not resetting the menu', () => {
|
|
63
|
+
const handleClickOutside = jest.fn();
|
|
64
|
+
|
|
65
|
+
expect(handleClickOutside).toHaveBeenCalledTimes(0);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('renders empty div if not in viewport', () => {
|
|
69
|
+
useIsInViewport.mockReturnValue(false);
|
|
70
|
+
|
|
71
|
+
const instance = createTestInstance(
|
|
72
|
+
<MemoryRouter>
|
|
73
|
+
<MegaMenu />
|
|
74
|
+
</MemoryRouter>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('renders menu if in viewport', () => {
|
|
81
|
+
useIsInViewport.mockReturnValue(true);
|
|
82
|
+
|
|
83
|
+
const instance = createTestInstance(
|
|
84
|
+
<MemoryRouter>
|
|
85
|
+
<MegaMenu />
|
|
86
|
+
</MemoryRouter>
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
90
|
+
});
|
|
91
|
+
});
|