@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.
Files changed (126) hide show
  1. package/package.json +1 -1
  2. package/src/Utilities/graphQL.js +76 -76
  3. package/src/componentOverrideMapping.js +17 -17
  4. package/src/components/BecomeSeller/becomeSeller.js +335 -335
  5. package/src/components/BecomeSeller/becomeSeller.module.css +46 -46
  6. package/src/components/BecomeSellerLink/becomeSellerLink.js +52 -52
  7. package/src/components/BecomeSellerLink/becomeSellerLink.module.css +12 -12
  8. package/src/components/BecomeSellerPage/becomeSellerPage.js +45 -45
  9. package/src/components/BecomeSellerPage/becomeSellerPage.module.css +21 -21
  10. package/src/components/Filter/index.js +53 -53
  11. package/src/components/Header/becomeSellerLink.js +28 -28
  12. package/src/components/Header/becomeSellerLink.module.css +12 -12
  13. package/src/components/Header/websiteSwitcher.js +109 -109
  14. package/src/components/OperatingHours/index.js +1 -0
  15. package/src/components/OperatingHours/operatingHours.js +35 -0
  16. package/src/components/Pagination/index.js +49 -49
  17. package/src/components/PhoneTextInput/phoneTextInput.module.css +21 -21
  18. package/src/components/ProductItem/index.js +50 -50
  19. package/src/components/Search/index.js +16 -16
  20. package/src/components/Seller/index.js +1 -1
  21. package/src/components/Seller/seller.js +57 -249
  22. package/src/components/Seller/sellerAddressCard.js +48 -0
  23. package/src/components/SellerAccountPage/sellerAccountPage.js +110 -110
  24. package/src/components/SellerAccountPage/sellerAccountPage.module.css +55 -55
  25. package/src/components/SellerCountry/sellerCountry.gql.js +11 -11
  26. package/src/components/SellerDetail/index.js +1 -0
  27. package/src/components/SellerDetail/sellerDetail.js +161 -0
  28. package/src/components/SellerInformation/index.js +1 -1
  29. package/src/components/SellerInformation/sellerInformation.js +86 -90
  30. package/src/components/SellerLocation/index.js +1 -1
  31. package/src/components/SellerLocation/sellerLocation.js +19 -19
  32. package/src/components/SellerLocation/sellerLocationItem.js +27 -27
  33. package/src/components/SellerPage/sellerPage.js +9 -9
  34. package/src/components/SellerProducts/sellerProducts.js +46 -46
  35. package/src/components/SellerReview/index.js +1 -1
  36. package/src/components/SellerReview/sellerReview.js +143 -143
  37. package/src/components/SellerReviewItem/sellerReviewItem.js +60 -60
  38. package/src/components/SellerVerification/sellerVerification.js +198 -198
  39. package/src/components/SellerVerification/sellerVerification.module.css +47 -47
  40. package/src/components/SellerVerificationPage/sellerVerificationPage.js +43 -43
  41. package/src/components/SellerVerificationPage/sellerVerificationPage.module.css +21 -21
  42. package/src/components/SortBy/index.js +24 -24
  43. package/src/components/WebsiteSwitcher/websiteSwitcher.js +109 -109
  44. package/src/components/commons/Slider/index.js +13 -13
  45. package/src/components/commons/Tabs/index.js +64 -64
  46. package/src/index.js +6 -6
  47. package/src/intercept.js +113 -113
  48. package/src/moduleOverrideWebpackPlugin.js +70 -70
  49. package/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js +96 -96
  50. package/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js +74 -74
  51. package/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js +208 -208
  52. package/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js +45 -45
  53. package/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js +204 -204
  54. package/src/overwrites/peregrine/lib/talons/Region/useRegion.js +102 -102
  55. package/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js +56 -56
  56. package/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js +226 -226
  57. package/src/overwrites/peregrine/lib/util/deriveErrorMessage.js +34 -34
  58. package/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql +11 -11
  59. package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +112 -112
  60. package/src/overwrites/venia-ui/lib/components/Header/header.js +130 -130
  61. package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +105 -105
  62. package/src/overwrites/venia-ui/lib/components/Header/switcherItem.js +47 -47
  63. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -91
  64. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -123
  65. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -61
  66. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -50
  67. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -114
  68. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -71
  69. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -59
  70. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -34
  71. package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -1
  72. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -90
  73. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -12
  74. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -156
  75. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +30 -30
  76. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -89
  77. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +42 -42
  78. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -99
  79. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -28
  80. package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -11
  81. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -72
  82. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -30
  83. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -69
  84. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -7
  85. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -12
  86. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -52
  87. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -82
  88. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -87
  89. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -45
  90. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -43
  91. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -45
  92. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -110
  93. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -172
  94. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -62
  95. package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -1
  96. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -74
  97. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +49 -49
  98. package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -40
  99. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -48
  100. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -13
  101. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -49
  102. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -97
  103. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -24
  104. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -43
  105. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -13
  106. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -75
  107. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -6
  108. package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +75 -75
  109. package/src/overwrites/venia-ui/lib/targets/venia-ui-intercept.js +70 -70
  110. package/src/queries/getAvailableWebsitesConfigData.graphql +14 -14
  111. package/src/queries/index.js +30 -30
  112. package/src/talons/BecomeSeller/becomeSeller.gql.js +45 -45
  113. package/src/talons/BecomeSeller/useBecomeSeller.js +145 -145
  114. package/src/talons/BecomeSellerLink/useBecomeSellerLink.js +11 -11
  115. package/src/talons/BecomeSellerPage/useBecomeSellerPage.js +76 -76
  116. package/src/talons/Header/useBecomeSellerLink.js +13 -13
  117. package/src/talons/Header/useWebsiteSwitcher.js +218 -218
  118. package/src/talons/Seller/seller.gql.js +204 -139
  119. package/src/talons/Seller/useSeller.js +71 -66
  120. package/src/talons/SellerAccountPage/useSellerAccountPage.js +174 -174
  121. package/src/talons/SellerCountry/useSellerCountry.js +25 -25
  122. package/src/talons/WebsiteByIp/getWebsiteByIp.gql.js +13 -13
  123. package/src/talons/WebsiteByIp/useWebsiteByIp.js +34 -34
  124. package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +218 -218
  125. package/src/theme/vars.js +6 -6
  126. package/src/util/mapSeller.js +7 -7
@@ -1,50 +1,50 @@
1
- .root {
2
- composes: items-center from global;
3
- composes: justify-items-center from global;
4
- composes: justify-self-center from global;
5
- composes: max-w-site from global;
6
- composes: px-xs from global;
7
- composes: py-0 from global;
8
- composes: w-full from global;
9
-
10
- /* TODO @TW: review (B6) */
11
- /* composes: hidden from global; */
12
- display: none;
13
- }
14
-
15
- .root_open {
16
- composes: root;
17
-
18
- composes: z-dropdown from global;
19
-
20
- /* TODO @TW: review (B6) */
21
- /* composes: grid from global; */
22
- display: grid;
23
- }
24
-
25
- .form {
26
- composes: grid from global;
27
- composes: items-center from global;
28
- composes: justify-items-stretch from global;
29
- composes: w-full from global;
30
- }
31
-
32
- .container {
33
- composes: inline-flex from global;
34
- composes: items-center from global;
35
- composes: justify-center from global;
36
- composes: max-w-[24rem] from global;
37
- composes: relative from global;
38
- composes: w-full from global;
39
- }
40
-
41
- .search {
42
- composes: grid from global;
43
- composes: relative from global;
44
- }
45
-
46
- .autocomplete {
47
- composes: grid from global;
48
- /* composes: relative from global; */
49
- composes: z-menu from global;
1
+ .root {
2
+ composes: items-center from global;
3
+ composes: justify-items-center from global;
4
+ composes: justify-self-center from global;
5
+ composes: max-w-site from global;
6
+ composes: px-xs from global;
7
+ composes: py-0 from global;
8
+ composes: w-full from global;
9
+
10
+ /* TODO @TW: review (B6) */
11
+ /* composes: hidden from global; */
12
+ display: none;
13
+ }
14
+
15
+ .root_open {
16
+ composes: root;
17
+
18
+ composes: z-dropdown from global;
19
+
20
+ /* TODO @TW: review (B6) */
21
+ /* composes: grid from global; */
22
+ display: grid;
23
+ }
24
+
25
+ .form {
26
+ composes: grid from global;
27
+ composes: items-center from global;
28
+ composes: justify-items-stretch from global;
29
+ composes: w-full from global;
30
+ }
31
+
32
+ .container {
33
+ composes: inline-flex from global;
34
+ composes: items-center from global;
35
+ composes: justify-center from global;
36
+ composes: max-w-[24rem] from global;
37
+ composes: relative from global;
38
+ composes: w-full from global;
39
+ }
40
+
41
+ .search {
42
+ composes: grid from global;
43
+ composes: relative from global;
44
+ }
45
+
46
+ .autocomplete {
47
+ composes: grid from global;
48
+ /* composes: relative from global; */
49
+ composes: z-menu from global;
50
50
  }
@@ -1,40 +1,40 @@
1
- import React from 'react';
2
- import { func } from 'prop-types';
3
- import { useSearchField } from '@magento/peregrine/lib/talons/SearchBar';
4
- import TextInput from '@magento/venia-ui/lib/components/TextInput';
5
- import Trigger from '@magento/venia-ui/lib/components/Trigger';
6
- import { SearchNormal } from 'iconsax-react';
7
- import cn from 'classnames';
8
-
9
- const SearchField = props => {
10
- const { isSearchOpen, onChange, onFocus, addLabel } = props;
11
- const { inputRef, resetForm, value } = useSearchField({ isSearchOpen });
12
-
13
- const handleSearch = () => {
14
- console.log('search');
15
- }
16
- const searchButton =
17
- <Trigger action={handleSearch} addLabel={addLabel}>
18
- <SearchNormal size="18" color="#280135" variant="Outline" />
19
- </Trigger>
20
-
21
- return (
22
- <TextInput
23
- id="search_query"
24
- after={searchButton}
25
- field="search_query"
26
- data-cy="SearchField-textInput"
27
- onFocus={onFocus}
28
- onValueChange={onChange}
29
- forwardedRef={inputRef}
30
- classes={cn('search input')}
31
- />
32
- );
33
- };
34
-
35
- export default SearchField;
36
-
37
- SearchField.propTypes = {
38
- onChange: func,
39
- onFocus: func
40
- };
1
+ import React from 'react';
2
+ import { func } from 'prop-types';
3
+ import { useSearchField } from '@magento/peregrine/lib/talons/SearchBar';
4
+ import TextInput from '@magento/venia-ui/lib/components/TextInput';
5
+ import Trigger from '@magento/venia-ui/lib/components/Trigger';
6
+ import { SearchNormal } from 'iconsax-react';
7
+ import cn from 'classnames';
8
+
9
+ const SearchField = props => {
10
+ const { isSearchOpen, onChange, onFocus, addLabel } = props;
11
+ const { inputRef, resetForm, value } = useSearchField({ isSearchOpen });
12
+
13
+ const handleSearch = () => {
14
+ console.log('search');
15
+ }
16
+ const searchButton =
17
+ <Trigger action={handleSearch} addLabel={addLabel}>
18
+ <SearchNormal size="18" color="#280135" variant="Outline" />
19
+ </Trigger>
20
+
21
+ return (
22
+ <TextInput
23
+ id="search_query"
24
+ after={searchButton}
25
+ field="search_query"
26
+ data-cy="SearchField-textInput"
27
+ onFocus={onFocus}
28
+ onValueChange={onChange}
29
+ forwardedRef={inputRef}
30
+ classes={cn('search input')}
31
+ />
32
+ );
33
+ };
34
+
35
+ export default SearchField;
36
+
37
+ SearchField.propTypes = {
38
+ onChange: func,
39
+ onFocus: func
40
+ };
@@ -1,48 +1,48 @@
1
- import React from 'react';
2
- import { arrayOf, func, number, shape, string } from 'prop-types';
3
-
4
- import { useStyle } from '@magento/venia-ui/lib/classify';
5
- import SuggestedCategory from './suggestedCategory';
6
- import defaultClasses from './suggestedCategories.module.css';
7
-
8
- const SuggestedCategories = props => {
9
- const { categories, limit, onNavigate, value } = props;
10
- const classes = useStyle(defaultClasses, props.classes);
11
-
12
- const items = categories
13
- .slice(0, limit)
14
- .map(({ label, value: categoryId }) => (
15
- <li key={categoryId} className={classes.item}>
16
- <SuggestedCategory
17
- categoryId={categoryId}
18
- label={label}
19
- onNavigate={onNavigate}
20
- value={value}
21
- />
22
- </li>
23
- ));
24
-
25
- return <ul className={classes.root}>{items}</ul>;
26
- };
27
-
28
- export default SuggestedCategories;
29
-
30
- SuggestedCategories.defaultProps = {
31
- limit: 4
32
- };
33
-
34
- SuggestedCategories.propTypes = {
35
- categories: arrayOf(
36
- shape({
37
- label: string.isRequired,
38
- value: string.isRequired
39
- })
40
- ).isRequired,
41
- classes: shape({
42
- item: string,
43
- root: string
44
- }),
45
- limit: number.isRequired,
46
- onNavigate: func,
47
- value: string
48
- };
1
+ import React from 'react';
2
+ import { arrayOf, func, number, shape, string } from 'prop-types';
3
+
4
+ import { useStyle } from '@magento/venia-ui/lib/classify';
5
+ import SuggestedCategory from './suggestedCategory';
6
+ import defaultClasses from './suggestedCategories.module.css';
7
+
8
+ const SuggestedCategories = props => {
9
+ const { categories, limit, onNavigate, value } = props;
10
+ const classes = useStyle(defaultClasses, props.classes);
11
+
12
+ const items = categories
13
+ .slice(0, limit)
14
+ .map(({ label, value: categoryId }) => (
15
+ <li key={categoryId} className={classes.item}>
16
+ <SuggestedCategory
17
+ categoryId={categoryId}
18
+ label={label}
19
+ onNavigate={onNavigate}
20
+ value={value}
21
+ />
22
+ </li>
23
+ ));
24
+
25
+ return <ul className={classes.root}>{items}</ul>;
26
+ };
27
+
28
+ export default SuggestedCategories;
29
+
30
+ SuggestedCategories.defaultProps = {
31
+ limit: 4
32
+ };
33
+
34
+ SuggestedCategories.propTypes = {
35
+ categories: arrayOf(
36
+ shape({
37
+ label: string.isRequired,
38
+ value: string.isRequired
39
+ })
40
+ ).isRequired,
41
+ classes: shape({
42
+ item: string,
43
+ root: string
44
+ }),
45
+ limit: number.isRequired,
46
+ onNavigate: func,
47
+ value: string
48
+ };
@@ -1,13 +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
- }
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
+ }
@@ -1,49 +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
- };
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
+ };
@@ -1,97 +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;
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;
@@ -1,24 +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
- }
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
+ }