diff --git a/packages/cypress/src/fixtures/seed/users.json b/packages/cypress/src/fixtures/seed/users.json index bf4666e5b5..c8e8347b79 100644 --- a/packages/cypress/src/fixtures/seed/users.json +++ b/packages/cypress/src/fixtures/seed/users.json @@ -53,7 +53,8 @@ "_modified": "2019-08-15T00:00:00.000Z", "_authID": "oydwApNvguWQoBOpFVOzQ2yJEOF2", "_created": "2019-08-15T00:00:00.000Z", - "displayName": "event_reader" + "displayName": "event_reader", + "userRoles": ["beta-tester"] }, "howto_creator": { "_deleted": false, @@ -203,4 +204,4 @@ "isExpert": null, "collectedPlasticTypes": null } -} \ No newline at end of file +} diff --git a/src/pages/common/Header/Header.tsx b/src/pages/common/Header/Header.tsx index cef7809ebc..0b996f1e92 100644 --- a/src/pages/common/Header/Header.tsx +++ b/src/pages/common/Header/Header.tsx @@ -15,6 +15,7 @@ import { observer, inject } from 'mobx-react' import { MobileMenuStore } from 'src/stores/MobileMenu/mobilemenu.store' import { UserStore } from 'src/stores/User/user.store' import { isModuleSupported, MODULE } from 'src/modules' +import { AuthWrapper } from 'src/components/Auth/AuthWrapper' interface IProps { } @@ -98,7 +99,15 @@ export class Header extends Component { } render() { + const menu = this.injected.mobileMenuStore + const user = this.injected.userStore.user const areThereNotifications = Boolean( + user?.notifications?.length && + !( + user?.notifications?.filter(notification => !notification.read) + .length === 0 + ), + ) return ( <> @@ -115,15 +124,29 @@ export class Header extends Component { - {user ? - menu.toggleMobileNotifications()} isMobileMenuActive={menu.showMobileNotifications} - areThereNotifications={areThereNotifications} /> - : ""} + {user ? ( + + + menu.toggleMobileNotifications()} + isMobileMenuActive={menu.showMobileNotifications} + areThereNotifications={areThereNotifications} + /> + + + ) : ( + '' + )} - + {isModuleSupported(MODULE.USER) ? ( - + <> + + + + + ) : null} diff --git a/src/pages/common/Header/Menu/Notifications/NotificationsDesktop.tsx b/src/pages/common/Header/Menu/Notifications/NotificationsDesktop.tsx index ac304e4620..be75812a8a 100644 --- a/src/pages/common/Header/Menu/Notifications/NotificationsDesktop.tsx +++ b/src/pages/common/Header/Menu/Notifications/NotificationsDesktop.tsx @@ -6,13 +6,11 @@ import { NotificationsModal } from './NotificationsModal' import NotificationsIcon from './NotificationsIcon' import Foco from 'react-foco' - interface IState { showNotificationsModal: boolean } -interface IProps { -} +interface IProps {} interface IInjectedProps extends IProps { userStore: UserStore @@ -32,7 +30,9 @@ export default class NotificationsDesktop extends Component { } toggleNotificationsModal() { - this.setState({ showNotificationsModal: !this.state.showNotificationsModal }) + this.setState({ + showNotificationsModal: !this.state.showNotificationsModal, + }) } render() { @@ -51,8 +51,11 @@ export default class NotificationsDesktop extends Component { <> {user ? (
- this.toggleNotificationsModal()} isMobileMenuActive={false} - areThereNotifications={areThereNotifications} /> + this.toggleNotificationsModal()} + isMobileMenuActive={false} + areThereNotifications={areThereNotifications} + /> {showNotificationsModal && ( this.toggleNotificationsModal()}> @@ -61,8 +64,9 @@ export default class NotificationsDesktop extends Component { )}
- ) : "" - } + ) : ( + '' + )} ) }