@jetshop/template-trend 5.10.0 → 5.12.0

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 (82) hide show
  1. package/.linaria-cache/packages/template-trend/src/components/ContentPage/ContentPage.linaria.css +5 -3
  2. package/.linaria-cache/packages/template-trend/src/components/ContentPage/SubPageNavigation.linaria.css +4 -0
  3. package/.linaria-cache/packages/template-trend/src/components/Layout/Header/ChannelSelector/ChannelSelector.linaria.css +1 -1
  4. package/.linaria-cache/packages/template-trend/src/components/StartPage/Content/StartPageCampaign.linaria.css +1 -1
  5. package/.linaria-cache/packages/template-trend/src/components/StartPage/Content/StartPageHero.linaria.css +1 -1
  6. package/.linaria-cache/packages/template-trend/src/components/StartPage/StartPage.linaria.css +0 -1
  7. package/.linaria-cache/packages/template-trend/src/components/ui/Button.linaria.css +3 -2
  8. package/.linaria-cache/packages/ui/Breadcrumbs/Breadcrumbs.linaria.css +1 -1
  9. package/.linaria-cache/packages/ui/DropdownMenu/DropdownMenu.linaria.css +1 -1
  10. package/.vscode/launch.json +11 -0
  11. package/README.md +118 -1944
  12. package/package.json +5 -5
  13. package/schema.graphql +5 -2
  14. package/src/components/Auth/ForgotPassword.js +3 -8
  15. package/src/components/Auth/README.md +5 -0
  16. package/src/components/Cart/CartButton.js +40 -44
  17. package/src/components/Cart/CartFlyout.js +18 -7
  18. package/src/components/Cart/CartItem.js +12 -15
  19. package/src/components/Cart/{addMultipleToCart.gql → queries/addMultipleToCart.gql} +1 -1
  20. package/src/components/Cart/{addToCart.gql → queries/addToCart.gql} +1 -1
  21. package/src/components/Cart/{CartFragment.gql → queries/cartFragment.gql} +2 -5
  22. package/src/components/Cart/{CartQuery.gql → queries/cartQuery.gql} +1 -1
  23. package/src/components/Cart/{decrementQuantity.gql → queries/decrementQuantity.gql} +1 -1
  24. package/src/components/Cart/{incrementQuantity.gql → queries/incrementQuantity.gql} +1 -1
  25. package/src/components/Cart/{removeFromCart.gql → queries/removeFromCart.gql} +1 -1
  26. package/src/components/CategoryPage/CategoryHeader.js +3 -3
  27. package/src/components/CategoryPage/CategoryPage.js +1 -0
  28. package/src/components/CategoryPage/ProductCard.js +4 -2
  29. package/src/components/CategoryPage/ProductGrid.js +8 -2
  30. package/src/components/CategoryPage/ProductGridWindow.js +22 -14
  31. package/src/components/CategoryPage/README.md +11 -0
  32. package/src/components/CategoryPage/StandardCategoryPage.js +2 -0
  33. package/src/components/CategoryPage/WindowedCategoryPage.js +7 -0
  34. package/src/components/ContentPage/ContentPage.js +69 -38
  35. package/src/components/ContentPage/ContentPageFragment.gql +29 -0
  36. package/src/components/ContentPage/SubPageNavigation.js +206 -0
  37. package/src/components/Layout/Footer/FooterLinks.js +6 -4
  38. package/src/components/Layout/Footer/PagesQuery.gql +9 -0
  39. package/src/components/Layout/Header/AutocompleteQuery.gql +1 -6
  40. package/src/components/Layout/Header/ChannelSelector/ChannelSelector.js +3 -0
  41. package/src/components/Layout/Header/ChannelSelector/ChannelSelectorModal.js +4 -3
  42. package/src/components/Layout/Header/ChannelSelector/Selector.js +2 -0
  43. package/src/components/Layout/Header/RecommendedChannel/RecommendedChannelSelector.js +2 -0
  44. package/src/components/LogOut.loadable.js +10 -0
  45. package/src/components/PreviewRoute.loadable.js +10 -0
  46. package/src/components/ProductList/AddToCart.js +8 -5
  47. package/src/components/ProductList/Favourite.js +2 -2
  48. package/src/components/ProductList/FavouriteCount.js +2 -2
  49. package/src/components/ProductList/Favourites.js +17 -12
  50. package/src/components/ProductList/Lister.js +44 -0
  51. package/src/components/ProductList/Product.js +5 -4
  52. package/src/components/ProductList/ProductLists.gql +8 -5
  53. package/src/components/ProductList/SelectVariant.js +6 -10
  54. package/src/components/ProductList/productListQueries.js +5 -0
  55. package/src/components/ProductPage/AddToCart/AddToCartForm.js +19 -18
  56. package/src/components/ProductPage/AddToCart/ProductToast.js +18 -7
  57. package/src/components/ProductPage/Images/ImageContainer.js +12 -1
  58. package/src/components/ProductPage/PackageProduct/PackageProduct.js +8 -6
  59. package/src/components/ProductPage/ProductInfo.js +1 -1
  60. package/src/components/ProductPage/ProductPage.js +3 -5
  61. package/src/components/ProductPage/ProductPageFragment.gql +1 -0
  62. package/src/components/ProductPage/StockStatus/WarehouseStock.js +15 -17
  63. package/src/components/ProductPage/VariantSelector.js +1 -1
  64. package/src/components/RouteQuery.gql +2 -2
  65. package/src/components/{StartPage → SearchPage}/CategoryList.js +6 -4
  66. package/src/components/SearchPage/EmptySearchResults.js +1 -1
  67. package/src/components/Shop.js +52 -76
  68. package/src/components/StartPage/Content/StartPageHero.js +12 -1
  69. package/src/components/StartPage/ContentItemFragment.gql +6 -1
  70. package/src/components/StartPage/StartPage.js +0 -13
  71. package/src/components/StartPage/StartPageProductGridFragment.gql +1 -0
  72. package/src/components/ui/Button.js +19 -1
  73. package/.linaria-cache/packages/ui/ChannelSelector/Region.linaria.css +0 -3
  74. package/src/components/StartPage/Campaign.js +0 -162
  75. package/src/components/StartPage/CampaignHeader.js +0 -101
  76. package/src/components/StartPage/ExtraDetails.js +0 -72
  77. package/src/components/StartPage/Readme.md +0 -88
  78. package/src/components/StartPage/campaign.json +0 -20
  79. package/src/components/StartPage/campaignHeader.json +0 -5
  80. package/src/components/StartPage/categoryList.json +0 -65
  81. package/src/components/StartPage/extraDetails.json +0 -6
  82. package/src/components/StartPage/title.json +0 -3
@@ -3,12 +3,13 @@ import { styled } from 'linaria/react';
3
3
  import React from 'react';
4
4
  import UIMaxWidth from '../Layout/MaxWidth';
5
5
  import { ContentRenderer } from '@jetshop/ui/ContentRenderer';
6
-
7
- const Header = styled('h1')`
8
- font-size: 1.6875rem;
9
- font-weight: 600;
10
- margin: 1rem 0 3rem;
11
- `;
6
+ import {
7
+ MobileNavigation,
8
+ DesktopNavigation,
9
+ shouldDisplayNavigation
10
+ } from './SubPageNavigation';
11
+ import { css } from 'linaria';
12
+ import Breadcrumbs from '@jetshop/ui/Breadcrumbs';
12
13
 
13
14
  const Content = styled('div')`
14
15
  padding-bottom: 1rem;
@@ -18,8 +19,35 @@ const Content = styled('div')`
18
19
  }
19
20
  `;
20
21
 
21
- const MaxWidth = styled(UIMaxWidth)`
22
+ const container = css`
23
+ display: flex;
24
+ flex-direction: row;
25
+ `;
26
+
27
+ const sidebar = css`
28
+ max-width: 288px;
29
+ flex: 1 1 auto;
30
+ border-right: 1px solid #dedede;
31
+ margin-right: 2rem;
32
+ padding: 2rem 0;
33
+
34
+ @media (max-width: 799px) {
35
+ display: none;
36
+ }
37
+ `;
38
+
39
+ const content = css`
22
40
  max-width: 60rem;
41
+ flex: 1 1 auto;
42
+ padding: 2rem 0;
43
+
44
+ h1 {
45
+ margin-bottom: 1rem;
46
+ }
47
+ `;
48
+
49
+ const body = css`
50
+ margin-top: 1rem;
23
51
  `;
24
52
 
25
53
  const components = {
@@ -34,44 +62,47 @@ const components = {
34
62
  }
35
63
  };
36
64
 
37
- function ContentPage(props) {
38
- const { page } = props;
65
+ function ContentPage({ page, result }) {
39
66
  return (
40
- <>
41
- <Header>
42
- <MaxWidth>
67
+ <UIMaxWidth className={container}>
68
+ {page && shouldDisplayNavigation(page) && (
69
+ <aside className={sidebar}>
70
+ <DesktopNavigation page={page} />
71
+ </aside>
72
+ )}
73
+ <article className={content}>
74
+ <Breadcrumbs
75
+ parents={result.data?.route?.parents || []}
76
+ breadcrumbs={result.data?.route?.breadcrumbs || []}
77
+ />
78
+ <h1>
43
79
  {page ? page.name : <LoadingLine heightPx={27} widthRem={15} />}
44
- </MaxWidth>
45
- </Header>
46
- <MaxWidth>
47
- {page ? (
48
- <>
49
- {page.data ? (
80
+ </h1>
81
+ <MobileNavigation page={page} />
82
+ <div className={body}>
83
+ {page ? (
84
+ page.data ? (
50
85
  <ContentRenderer
51
86
  items={page.data.items}
52
87
  components={components}
53
88
  />
54
89
  ) : (
55
- <Content
56
- dangerouslySetInnerHTML={{
57
- __html: page.content
58
- }}
59
- />
60
- )}
61
- </>
62
- ) : (
63
- <LoadingLine
64
- heightPx={14}
65
- widthRem={30}
66
- randomizeWidthBy={10}
67
- count={10}
68
- style={{
69
- marginBottom: '12px'
70
- }}
71
- />
72
- )}
73
- </MaxWidth>
74
- </>
90
+ <Content dangerouslySetInnerHTML={{ __html: page.content }} />
91
+ )
92
+ ) : (
93
+ <LoadingLine
94
+ heightPx={14}
95
+ widthRem={30}
96
+ randomizeWidthBy={10}
97
+ count={10}
98
+ style={{
99
+ marginBottom: '12px'
100
+ }}
101
+ />
102
+ )}
103
+ </div>
104
+ </article>
105
+ </UIMaxWidth>
75
106
  );
76
107
  }
77
108
 
@@ -1,4 +1,8 @@
1
1
  fragment ContentPage on Page {
2
+ primaryRoute {
3
+ id
4
+ path
5
+ }
2
6
  name
3
7
  id
4
8
  content
@@ -20,4 +24,29 @@ fragment ContentPage on Page {
20
24
  }
21
25
  }
22
26
  }
27
+
28
+ parent {
29
+ id
30
+ name
31
+ primaryRoute {
32
+ id
33
+ path
34
+ }
35
+ subPages(includeHidden: false) {
36
+ ...SubPage
37
+ }
38
+ }
39
+
40
+ subPages(includeHidden: false) {
41
+ ...SubPage
42
+ }
43
+ }
44
+
45
+ fragment SubPage on Page {
46
+ id
47
+ name
48
+ primaryRoute {
49
+ id
50
+ path
51
+ }
23
52
  }
@@ -0,0 +1,206 @@
1
+ import {
2
+ DropdownMenu,
3
+ DropdownMenuButton,
4
+ DropdownMenuItem,
5
+ DropdownMenuItems
6
+ } from '@jetshop/ui/DropdownMenu';
7
+ import React from 'react';
8
+ import { Link } from 'react-router-dom';
9
+ import { ReactComponent as Carot } from '@jetshop/ui/svg/Carrot.svg';
10
+ import { css, cx } from 'linaria';
11
+ import { theme } from '../Theme';
12
+ import { useHistory, useLocation } from 'react-router';
13
+
14
+ const menu = css`
15
+ width: 100%;
16
+
17
+ @media (min-width: 50em) {
18
+ display: none;
19
+ }
20
+
21
+ [data-flight-dropdown-button] {
22
+ width: 100%;
23
+ display: flex;
24
+ flex-direction: row;
25
+ justify-content: space-between;
26
+ align-items: center;
27
+
28
+ padding: 0.75em;
29
+ border: 1px solid #dedede;
30
+ width: 100%;
31
+ text-align: left;
32
+ background: ${theme.colors.white};
33
+ border-radius: 3px;
34
+ outline: none;
35
+
36
+ :focus {
37
+ color: ${theme.colors.blue};
38
+ }
39
+
40
+ &[aria-expanded='true'] {
41
+ border-radius: 3px 3px 0 0;
42
+ border-bottom: 0;
43
+ color: ${theme.colors.blue};
44
+
45
+ .carot {
46
+ transform: rotate(180deg);
47
+ }
48
+ }
49
+ }
50
+
51
+ [data-flight-dropdown-items] {
52
+ position: absolute;
53
+ top: 100%;
54
+ left: 0;
55
+ background: white;
56
+ display: block;
57
+ z-index: 2;
58
+ outline: none;
59
+ width: 100%;
60
+ border: 1px solid #dedede;
61
+ border-top: 0;
62
+ }
63
+
64
+ [data-flight-dropdown-item] {
65
+ line-height: 1.5;
66
+ border: none;
67
+ cursor: pointer;
68
+ white-space: normal;
69
+ padding: 0.5em 1em;
70
+ :hover {
71
+ color: blue;
72
+ }
73
+ }
74
+
75
+ [data-flight-dropdown-item] a {
76
+ text-decoration: none;
77
+ color: #000;
78
+ }
79
+
80
+ [data-flight-dropdown-item]:focus {
81
+ font-weight: bold;
82
+ background: #f2f2f2;
83
+ outline: none;
84
+ position: relative;
85
+ }
86
+
87
+ [data-flight-dropdown-item]:focus:before {
88
+ content: '';
89
+ position: absolute;
90
+ top: 0;
91
+ bottom: 0;
92
+ left: 0;
93
+ width: 2px;
94
+ background-color: #2f80ed;
95
+ }
96
+ `;
97
+
98
+ const links = css`
99
+ display: flex;
100
+ flex-direction: column;
101
+ `;
102
+
103
+ const link = css`
104
+ color: #000;
105
+ text-decoration: none;
106
+ margin-bottom: 1rem;
107
+ line-height: 1.5;
108
+ `;
109
+
110
+ const activeLink = css`
111
+ font-weight: bold;
112
+ color: #2f80ed;
113
+ `;
114
+
115
+ function getNavigationItemFromPage(page, level) {
116
+ return {
117
+ id: page.id,
118
+ name: page.name,
119
+ url: page.primaryRoute?.path,
120
+ level
121
+ };
122
+ }
123
+
124
+ function Item({ name, url, level }) {
125
+ return (
126
+ <div style={{ marginLeft: `${(level - 1) * 12}px` }}>
127
+ <Link to={url}>{name}</Link>
128
+ </div>
129
+ );
130
+ }
131
+
132
+ function getNavigationItems(page) {
133
+ const parent = page.parent ? getNavigationItemFromPage(page.parent, 1) : null;
134
+ const siblings = page.parent
135
+ ? page.parent.subPages.map(subPage => getNavigationItemFromPage(subPage, 2))
136
+ : [];
137
+ const subPages = page.subPages
138
+ ? page.subPages.map(subPage =>
139
+ getNavigationItemFromPage(subPage, parent ? 3 : 2)
140
+ )
141
+ : [];
142
+ const currentPage = getNavigationItemFromPage(page, parent ? 2 : 1);
143
+
144
+ if (!parent && !subPages?.length) return [];
145
+
146
+ const items = [];
147
+
148
+ if (parent) items.push(parent);
149
+ if (siblings.length) {
150
+ siblings.forEach(page => {
151
+ items.push(page);
152
+ if (page.id === currentPage.id) {
153
+ items.push(...subPages);
154
+ }
155
+ });
156
+ } else {
157
+ items.push(currentPage, ...subPages);
158
+ }
159
+
160
+ return items;
161
+ }
162
+
163
+ export function shouldDisplayNavigation(page) {
164
+ return Boolean(page.parent || page.subPages?.length);
165
+ }
166
+
167
+ export function DesktopNavigation({ page }) {
168
+ const location = useLocation();
169
+ const items = getNavigationItems(page);
170
+
171
+ return (
172
+ <div className={links}>
173
+ {items.map(item => (
174
+ <Link
175
+ key={item.id}
176
+ to={item.url}
177
+ className={cx(link, location.pathname === item.url && activeLink)}
178
+ style={{ marginLeft: `${(item.level - 1) * 12}px` }}
179
+ >
180
+ {item.name}
181
+ </Link>
182
+ ))}
183
+ </div>
184
+ );
185
+ }
186
+
187
+ export function MobileNavigation({ page }) {
188
+ const { push } = useHistory();
189
+ const items = page ? getNavigationItems(page) : [];
190
+
191
+ return (
192
+ <DropdownMenu className={menu}>
193
+ <DropdownMenuButton>
194
+ <span>{page?.name}</span>
195
+ <Carot className="carot" />
196
+ </DropdownMenuButton>
197
+ <DropdownMenuItems>
198
+ {items.map(item => (
199
+ <DropdownMenuItem key={item.id} onSelect={() => push(item.url)}>
200
+ <Item {...item} />
201
+ </DropdownMenuItem>
202
+ ))}
203
+ </DropdownMenuItems>
204
+ </DropdownMenu>
205
+ );
206
+ }
@@ -7,9 +7,8 @@ import { useQuery } from '@apollo/react-hooks';
7
7
 
8
8
  function FooterLinks() {
9
9
  const { data } = useQuery(pagesQuery);
10
- const { data: storeTitleData, loading: storeTitleLoading } = useQuery(
11
- StoreTitleQuery
12
- );
10
+ const { data: storeTitleData, loading: storeTitleLoading } =
11
+ useQuery(StoreTitleQuery);
13
12
 
14
13
  const pages = data?.pages;
15
14
  const storeTitle = storeTitleData?.startPage?.head.title;
@@ -20,7 +19,10 @@ function FooterLinks() {
20
19
  <ul>
21
20
  {pages.map(page => (
22
21
  <li key={page.id}>
23
- <ContentPageLink page={page}>{page.name}</ContentPageLink>
22
+ <ContentPageLink page={page}>
23
+ {page.subPages?.length ? '+ ' : null}
24
+ {page.name}
25
+ </ContentPageLink>
24
26
  </li>
25
27
  ))}
26
28
  </ul>
@@ -6,5 +6,14 @@ query PagesQuery {
6
6
  id
7
7
  path
8
8
  }
9
+
10
+ subPages {
11
+ id
12
+ name
13
+ primaryRoute {
14
+ id
15
+ path
16
+ }
17
+ }
9
18
  }
10
19
  }
@@ -8,12 +8,7 @@ query AutocompleteQuery($term: String!) {
8
8
  id
9
9
  slug
10
10
  path
11
- parents {
12
- id
13
- object {
14
- breadcrumbText
15
- }
16
- }
11
+ breadcrumbs
17
12
  }
18
13
  }
19
14
  }
@@ -13,6 +13,7 @@ const Flyout = styled('div')`
13
13
 
14
14
  const CountryFlag = styled('img')`
15
15
  height: 12px;
16
+ width: 12px;
16
17
  margin-right: 5px;
17
18
  `;
18
19
 
@@ -32,6 +33,8 @@ export default class HeaderChannelSelector extends Component {
32
33
  <CountryFlag
33
34
  src={`https://countryflags.jetshop.io/${selectedChannel.country.code}/flat/32.png`}
34
35
  alt="Country Flag"
36
+ width="16"
37
+ height="12"
35
38
  />
36
39
  {selectedChannel.country.name}
37
40
  </button>
@@ -26,9 +26,8 @@ const modalStyles = css`
26
26
  `;
27
27
 
28
28
  const ChannelSelectorModal = props => {
29
- const { selectedChannel, channels, updateChannel } = useContext(
30
- ChannelContext
31
- );
29
+ const { selectedChannel, channels, updateChannel } =
30
+ useContext(ChannelContext);
32
31
 
33
32
  return (
34
33
  <ModalTrigger
@@ -49,6 +48,8 @@ const ChannelSelectorModal = props => {
49
48
  src={`https://countryflags.jetshop.io/${selectedChannel.country.code}/flat/32.png`}
50
49
  alt="Country Flag"
51
50
  style={{ height: '12px', marginRight: '6px' }}
51
+ width="16"
52
+ height="12"
52
53
  />
53
54
  <span>{selectedChannel.country.name}</span>
54
55
  </Button>
@@ -139,6 +139,8 @@ const Selector = ({
139
139
  <CountryFlag
140
140
  src={`https://countryflags.jetshop.io/${code}/flat/32.png`}
141
141
  alt="Country Flag"
142
+ width="16"
143
+ height="12"
142
144
  />
143
145
  {name} ({channel.name})
144
146
  </Country>
@@ -153,6 +153,8 @@ const Selector = ({
153
153
  <CountryFlag
154
154
  src={`https://countryflags.jetshop.io/${code}/flat/32.png`}
155
155
  alt="Country Flag"
156
+ width="16"
157
+ height="12"
156
158
  />
157
159
  {name} ({channel.name})
158
160
  </Country>
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import loadable from '@loadable/component';
3
+ import LoadingPage from './LoadingPage';
4
+
5
+ export default loadable(
6
+ () => import('@jetshop/core/components/AuthContext/LogOut'),
7
+ {
8
+ fallback: <LoadingPage />
9
+ }
10
+ );
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import loadable from '@loadable/component';
3
+ import LoadingPage from './LoadingPage';
4
+
5
+ export default loadable(
6
+ () => import('@jetshop/core/components/DynamicRoute/PreviewRoute'),
7
+ {
8
+ fallback: <LoadingPage />
9
+ }
10
+ );
@@ -1,13 +1,16 @@
1
+ import React, { useContext } from 'react';
2
+ import { css } from 'linaria';
1
3
  import { useMutation } from '@apollo/react-hooks';
4
+
5
+ import t from '@jetshop/intl';
2
6
  import { CartIdContext } from '@jetshop/core/components/Cart/CartIdContext';
3
7
  import { addToCartSuccess } from '@jetshop/core/components/Mutation/AddToCart/addToCartUtils';
4
- import t from '@jetshop/intl';
5
- import React, { useContext } from 'react';
6
- import { css } from 'linaria';
7
- import { addToCart } from '../Cart/addToCart.gql';
8
- import ProductToastWrapper from '../ProductPage/AddToCart/ProductToast';
9
8
  import { useNotification } from '@jetshop/core/components/Notifications';
10
9
 
10
+ import ProductToastWrapper from '../ProductPage/AddToCart/ProductToast';
11
+
12
+ import { addToCart } from '../Cart/queries/addToCart.gql';
13
+
11
14
  const addButton = css`
12
15
  background: white;
13
16
  border: 0.75px solid #bfbdbd;
@@ -14,13 +14,13 @@ const favourite = css`
14
14
  }
15
15
  `;
16
16
 
17
- export function Favourite({ product, variant, ...rest }) {
17
+ export function Favourite({ product, variant, listId, ...rest }) {
18
18
  const articleNumber = product.articleNumber;
19
19
 
20
20
  const selectedVariation = product.variant || variant;
21
21
  const variantArticleNumber = selectedVariation?.articleNumber;
22
22
 
23
- const { toggle, inList } = useProductList();
23
+ const { toggle, inList } = useProductList(listId);
24
24
 
25
25
  function toggleWithoutBubble(e) {
26
26
  e.preventDefault();
@@ -5,8 +5,8 @@ import { Link } from 'react-router-dom';
5
5
  import { ReactComponent as HeartSVG } from '../../svg/Heart.svg';
6
6
  import Badge from '../ui/Badge';
7
7
 
8
- export function FavouriteCount({ className }) {
9
- const { count } = useProductList();
8
+ export function FavouriteCount({ className, listId }) {
9
+ const { count } = useProductList(listId);
10
10
 
11
11
  return (
12
12
  <Link to="/favourites" className={className}>
@@ -1,22 +1,27 @@
1
+ import React from 'react';
2
+ import { css, cx } from 'linaria';
3
+
1
4
  import {
2
5
  useProductList,
3
6
  useProductListItems
4
7
  } from '@jetshop/core/hooks/ProductList';
5
8
  import { useAddMultipleToCart } from '@jetshop/core/hooks/useAddMultipleToCart';
6
9
  import t from '@jetshop/intl';
7
- import React from 'react';
8
- import { css, cx } from 'linaria';
9
- import { ReactComponent as Cart } from '../../svg/Cart.svg';
10
- import addMultipleToCartMutation from '../Cart/addMultipleToCart.gql';
11
- import cartQuery from '../Cart/CartQuery.gql';
10
+ import { useNotification } from '@jetshop/core/components/Notifications';
11
+
12
+ import { ReactComponent as CartIcon } from '../../svg/Cart.svg';
12
13
  import MaxWidth from '../Layout/MaxWidth';
13
14
  import { theme } from '../Theme';
14
15
  import Button from '../ui/Button';
15
16
  import { Product } from './Product';
16
- import { useNotification } from '@jetshop/core/components/Notifications';
17
+
18
+ import addMultipleToCartMutation from '../Cart/queries/addMultipleToCart.gql';
19
+ import cartQuery from '../Cart/queries/cartQuery.gql';
17
20
 
18
21
  export function Favourites() {
19
- const { products, loading } = useProductListItems();
22
+ const listId = null;
23
+
24
+ const { products, loading } = useProductListItems(listId);
20
25
  const [trigger] = useNotification();
21
26
 
22
27
  const validItems = getItemsForAddToCart(products);
@@ -32,7 +37,7 @@ export function Favourites() {
32
37
  onCompleted: () => {
33
38
  trigger(
34
39
  <AddAllSuccessToast>
35
- <Cart />
40
+ <CartIcon />
36
41
  {t(
37
42
  '{productCount, plural, =1 {# product added to the cart.} other {# products added to the cart.}}',
38
43
  { productCount: validItemCount }
@@ -73,7 +78,7 @@ export function Favourites() {
73
78
  key={product.variant?.articleNumber || product.articleNumber}
74
79
  data-valid={product.validation.status}
75
80
  >
76
- <Product product={product} />
81
+ <Product listId={listId} product={product} />
77
82
  </li>
78
83
  );
79
84
  })}
@@ -96,7 +101,7 @@ export function Favourites() {
96
101
  )
97
102
  : t('No valid items to add to cart')}
98
103
  </Button>
99
- <ClearList>{t('Clear list')}</ClearList>
104
+ <ClearList listId={listId}>{t('Clear list')}</ClearList>
100
105
  </div>
101
106
  </MaxWidth>
102
107
  );
@@ -106,8 +111,8 @@ function AddAllSuccessToast({ children }) {
106
111
  return <div className={addAllToastStyles}>{children}</div>;
107
112
  }
108
113
 
109
- function ClearList({ children }) {
110
- const { clear } = useProductList();
114
+ function ClearList({ children, listId }) {
115
+ const { clear } = useProductList(listId);
111
116
  return (
112
117
  <Button secondary onClick={clear}>
113
118
  {children}
@@ -0,0 +1,44 @@
1
+ /*
2
+ * TODO This is temporary, delete before merging
3
+ *
4
+ */
5
+ import React from 'react';
6
+ import { useContext } from 'react';
7
+ import { ProductListContext } from '@jetshop/core/hooks/ProductList/ProductListContext';
8
+ import { Link } from 'react-router-dom';
9
+ import useAuth from '@jetshop/core/components/AuthContext/useAuth';
10
+
11
+ export default function Lister() {
12
+ const { state, createList, deleteList } = useContext(ProductListContext);
13
+ const { loggedIn } = useAuth();
14
+ return (
15
+ <>
16
+ <h2>Product lists</h2>
17
+ {loggedIn ? (
18
+ <button onClick={() => createList('BOOM')}>
19
+ Create a list a new list called BOOM
20
+ </button>
21
+ ) : (
22
+ <></>
23
+ )}
24
+
25
+ <br />
26
+
27
+ <ul>
28
+ {Array.from(state.lists.entries()).map(([listId, obj]) => (
29
+ <li key={listId} style={{ padding: '0.5em' }}>
30
+ <Link to={`/favourites/${listId || ''}`}>
31
+ {listId === null ? 'Default list' : obj.name}
32
+ </Link>
33
+ {listId === null ? (
34
+ <></>
35
+ ) : (
36
+ <button onClick={() => deleteList(listId)}>DELETE</button>
37
+ )}
38
+ </li>
39
+ ))}
40
+ </ul>
41
+ <hr />
42
+ </>
43
+ );
44
+ }