@eeacms/volto-clms-theme 1.1.25 → 1.1.26

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/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [1.1.26](https://github.com/eea/volto-clms-theme/compare/1.1.25...1.1.26) - 13 July 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - add a popover referencing the cart icon when new items are added to the cart [ionlizarazu - [`79a4ede`](https://github.com/eea/volto-clms-theme/commit/79a4ede01bce272c1cd97a1944720c2498819247)]
12
+ - remove toast when an element is added to the cart [ionlizarazu - [`7b43119`](https://github.com/eea/volto-clms-theme/commit/7b43119ae68397c5057247662ca88e11260df51c)]
13
+ - return statement for useEffect in CLMSDownloadCartView [ionlizarazu - [`4e9c523`](https://github.com/eea/volto-clms-theme/commit/4e9c523e15e62c0b914b8d02e2d8fc7440e77db3)]
14
+ - add aproximation to new cart item popup [ionlizarazu - [`a322db3`](https://github.com/eea/volto-clms-theme/commit/a322db3fe1d146e841630280f5df4054948f2049)]
7
15
  ### [1.1.25](https://github.com/eea/volto-clms-theme/compare/1.1.24...1.1.25) - 12 July 2023
8
16
 
9
17
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.1.25",
3
+ "version": "1.1.26",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -44,6 +44,7 @@ const CLMSDownloadCartView = (props) => {
44
44
  useEffect(() => {
45
45
  dispatch(getProjections());
46
46
  dispatch(getFormatConversionTable());
47
+ return () => {};
47
48
  }, [dispatch]);
48
49
 
49
50
  useEffect(() => {
@@ -57,9 +58,7 @@ const CLMSDownloadCartView = (props) => {
57
58
  );
58
59
 
59
60
  // returned function will be called on component unmount
60
- return () => {
61
- dispatch(getExtraBreadcrumbItems([]));
62
- };
61
+ return () => {};
63
62
  // eslint-disable-next-line react-hooks/exhaustive-deps
64
63
  }, [props.location.pathname]);
65
64
 
@@ -86,6 +85,7 @@ const CLMSDownloadCartView = (props) => {
86
85
  if (localsessionNutsIDList.length > 0) {
87
86
  dispatch(getNutsNames(localsessionNutsIDList));
88
87
  }
88
+ return () => {};
89
89
  // eslint-disable-next-line react-hooks/exhaustive-deps
90
90
  }, [cart, dispatch]);
91
91
 
@@ -1,7 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { defineMessages, useIntl } from 'react-intl';
3
3
  import { useSelector } from 'react-redux';
4
- import { toast } from 'react-toastify';
5
4
  import {
6
5
  Button,
7
6
  Checkbox,
@@ -10,7 +9,7 @@ import {
10
9
  Segment,
11
10
  } from 'semantic-ui-react';
12
11
 
13
- import { Icon, Toast } from '@plone/volto/components';
12
+ import { Icon } from '@plone/volto/components';
14
13
  import clearSVG from '@plone/volto/icons/clear.svg';
15
14
  import paginationLeftSVG from '@plone/volto/icons/left-key.svg';
16
15
  import paginationRightSVG from '@plone/volto/icons/right-key.svg';
@@ -211,15 +210,7 @@ function CclDownloadTable(props) {
211
210
  file: item.file,
212
211
  unique_id: item.unique_id,
213
212
  }));
214
- await addCartItem(selectedCartItems).then(() => {
215
- toast.success(
216
- <Toast
217
- success
218
- title={intl.formatMessage(messages.success)}
219
- content={intl.formatMessage(messages.added_to_cart)}
220
- />,
221
- );
222
- });
213
+ await addCartItem(selectedCartItems);
223
214
  };
224
215
 
225
216
  const clearSelection = () => {
@@ -6,9 +6,12 @@
6
6
  */
7
7
 
8
8
  import { FormattedMessage, injectIntl } from 'react-intl';
9
- import { Logo, Navigation, SearchWidget } from '@plone/volto/components';
10
- import React, { Component, useEffect } from 'react';
9
+ import { Logo, Navigation, SearchWidget, Icon } from '@plone/volto/components';
10
+ import React, { Component, useEffect, useRef, useState } from 'react';
11
11
  import { connect, useDispatch, useSelector } from 'react-redux';
12
+ import { Popup, Segment, Divider, Message } from 'semantic-ui-react';
13
+ import CclButton from '@eeacms/volto-clms-theme/components/CclButton/CclButton';
14
+ import clearSVG from '@plone/volto/icons/clear.svg';
12
15
 
13
16
  import { BodyClass } from '@plone/volto/helpers';
14
17
  // IMPORT isnt nedded until translations are created
@@ -24,23 +27,87 @@ import { getUser } from '@plone/volto/actions';
24
27
  import jwtDecode from 'jwt-decode';
25
28
 
26
29
  const CartIconCounter = (props) => {
27
- const cart = useSelector((state) => state.cart_items.items);
30
+ const cartState = useSelector((state) => state.cart_items);
31
+ const cartState_ref = useRef(cartState);
32
+ const cart_icon_ref = React.useRef();
28
33
  const intl = useSelector((state) => state.intl);
29
34
  const user_id = useSelector((state) => state.users.user.id);
35
+ const [showPopup, setshowPopup] = useState(false);
36
+ const [cartDiff, setCartDiff] = useState(0);
30
37
  const dispatch = useDispatch();
31
38
  useEffect(() => {
32
39
  dispatch(getCartItems(user_id));
33
40
  // eslint-disable-next-line react-hooks/exhaustive-deps
34
41
  }, [user_id]);
42
+ useEffect(() => {
43
+ if (
44
+ cartState_ref.current.set.loading &&
45
+ cartState.set.loaded &&
46
+ cartState.items.length >= cartState_ref.current.items.length
47
+ ) {
48
+ setCartDiff(cartState.items.length - cartState_ref.current.items.length);
49
+ window.scrollTo({
50
+ top: 0,
51
+ left: 0,
52
+ behavior: 'smooth',
53
+ });
54
+ !showPopup && setTimeout(() => setshowPopup(true), 900);
55
+ setTimeout(() => setshowPopup(false), 11000);
56
+ }
57
+ cartState_ref.current = cartState;
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ }, [cartState]);
35
60
  return (
36
- cart && (
37
- <Link to={`/${intl.locale}/cart`} className="header-login-link">
38
- <FontAwesomeIcon
39
- icon={['fas', 'shopping-cart']}
40
- style={{ marginRight: '0.25rem', maxWidth: '1.5rem' }}
41
- />
42
- <strong>{cart?.length}</strong>
43
- </Link>
61
+ cartState.items && (
62
+ <>
63
+ <Popup
64
+ context={cart_icon_ref}
65
+ open={showPopup}
66
+ position="bottom center"
67
+ >
68
+ <Segment
69
+ attached="top"
70
+ style={{ padding: 0, display: 'flex', justifyContent: 'flex-end' }}
71
+ >
72
+ <Icon
73
+ onClick={() => setshowPopup(false)}
74
+ name={clearSVG}
75
+ size={20}
76
+ style={{ cursor: 'pointer' }}
77
+ />
78
+ </Segment>
79
+ <Divider horizontal style={{ margin: 0 }}>
80
+ My cart
81
+ </Divider>
82
+ {cartDiff > 0 ? (
83
+ <Message positive>
84
+ You added <strong>{cartDiff} new items</strong> to the cart
85
+ </Message>
86
+ ) : (
87
+ <Message warning>
88
+ The items you tried to add were already added
89
+ </Message>
90
+ )}
91
+ <CclButton
92
+ mode="filled"
93
+ to={`/${intl.locale}/cart`}
94
+ style={{ width: '100%' }}
95
+ >
96
+ Go to cart
97
+ </CclButton>
98
+ </Popup>
99
+ <Link
100
+ to={`/${intl.locale}/cart`}
101
+ className="header-login-link"
102
+ ref={cart_icon_ref}
103
+ >
104
+ <FontAwesomeIcon
105
+ icon={['fas', 'shopping-cart']}
106
+ style={{ marginRight: '0.25rem', maxWidth: '1.5rem' }}
107
+ />
108
+ <strong>{cartState?.items?.length}</strong>
109
+ </Link>
110
+ </>
44
111
  )
45
112
  );
46
113
  };
@@ -263,7 +330,7 @@ class Header extends Component {
263
330
  <li className="header-vertical-line">
264
331
  <div>|</div>
265
332
  </li>
266
- {(this.props.user.id && (
333
+ {(this.props.user.id && this.state.mobileMenuOpen && (
267
334
  <>
268
335
  <li className="header-dropdown">
269
336
  <HeaderDropdown user={this.props.user} />