2019-08-31 04:07:25 +05:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import { Icon, Menu } from 'semantic-ui-react';
|
|
|
|
|
|
|
|
import Paths from '../../constants/Paths';
|
|
|
|
import NotificationsPopup from './NotificationsPopup';
|
2019-10-18 08:06:34 +05:00
|
|
|
import UserPopup from '../UserPopup';
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
import styles from './Header.module.css';
|
|
|
|
|
|
|
|
const Header = React.memo(
|
|
|
|
({
|
|
|
|
user,
|
|
|
|
notifications,
|
|
|
|
isEditable,
|
2019-10-18 08:06:34 +05:00
|
|
|
onUsers,
|
|
|
|
onNotificationDelete,
|
2019-08-31 04:07:25 +05:00
|
|
|
onUserUpdate,
|
|
|
|
onUserAvatarUpload,
|
2019-10-18 08:06:34 +05:00
|
|
|
onUserEmailUpdate,
|
|
|
|
onUserEmailUpdateMessageDismiss,
|
|
|
|
onUserPasswordUpdate,
|
|
|
|
onUserPasswordUpdateMessageDismiss,
|
2019-08-31 04:07:25 +05:00
|
|
|
onLogout,
|
2019-10-16 22:48:24 +05:00
|
|
|
}) => (
|
|
|
|
<div className={styles.wrapper}>
|
|
|
|
<Link to={Paths.ROOT} className={styles.logo}>
|
|
|
|
Planka
|
|
|
|
</Link>
|
|
|
|
<Menu inverted size="large" className={styles.menu}>
|
|
|
|
<Menu.Menu position="right">
|
2019-08-31 04:07:25 +05:00
|
|
|
{isEditable && (
|
|
|
|
<Menu.Item className={styles.item} onClick={onUsers}>
|
2019-10-16 22:48:24 +05:00
|
|
|
<Icon fitted name="users" />
|
2019-08-31 04:07:25 +05:00
|
|
|
</Menu.Item>
|
|
|
|
)}
|
2019-10-16 22:48:24 +05:00
|
|
|
<NotificationsPopup items={notifications} onDelete={onNotificationDelete}>
|
|
|
|
<Menu.Item className={styles.item}>
|
|
|
|
<Icon fitted name="bell" />
|
|
|
|
{notifications.length > 0 && (
|
|
|
|
<span className={styles.notification}>{notifications.length}</span>
|
|
|
|
)}
|
|
|
|
</Menu.Item>
|
|
|
|
</NotificationsPopup>
|
|
|
|
<UserPopup
|
2019-10-18 08:06:34 +05:00
|
|
|
email={user.email}
|
2019-10-16 22:48:24 +05:00
|
|
|
name={user.name}
|
|
|
|
avatar={user.avatar}
|
|
|
|
isAvatarUploading={user.isAvatarUploading}
|
2019-10-18 08:06:34 +05:00
|
|
|
emailUpdateForm={user.emailUpdateForm}
|
|
|
|
passwordUpdateForm={user.passwordUpdateForm}
|
2019-10-16 22:48:24 +05:00
|
|
|
onUpdate={onUserUpdate}
|
|
|
|
onAvatarUpload={onUserAvatarUpload}
|
2019-10-18 08:06:34 +05:00
|
|
|
onEmailUpdate={onUserEmailUpdate}
|
|
|
|
onEmailUpdateMessageDismiss={onUserEmailUpdateMessageDismiss}
|
|
|
|
onPasswordUpdate={onUserPasswordUpdate}
|
|
|
|
onPasswordUpdateMessageDismiss={onUserPasswordUpdateMessageDismiss}
|
2019-10-16 22:48:24 +05:00
|
|
|
onLogout={onLogout}
|
|
|
|
>
|
|
|
|
<Menu.Item className={styles.item}>{user.name}</Menu.Item>
|
|
|
|
</UserPopup>
|
|
|
|
</Menu.Menu>
|
|
|
|
</Menu>
|
|
|
|
</div>
|
|
|
|
),
|
2019-08-31 04:07:25 +05:00
|
|
|
);
|
|
|
|
|
|
|
|
Header.propTypes = {
|
|
|
|
/* eslint-disable react/forbid-prop-types */
|
|
|
|
user: PropTypes.object.isRequired,
|
|
|
|
notifications: PropTypes.array.isRequired,
|
|
|
|
/* eslint-enable react/forbid-prop-types */
|
|
|
|
isEditable: PropTypes.bool.isRequired,
|
2019-10-18 08:06:34 +05:00
|
|
|
onUsers: PropTypes.func.isRequired,
|
|
|
|
onNotificationDelete: PropTypes.func.isRequired,
|
2019-08-31 04:07:25 +05:00
|
|
|
onUserUpdate: PropTypes.func.isRequired,
|
|
|
|
onUserAvatarUpload: PropTypes.func.isRequired,
|
2019-10-18 08:06:34 +05:00
|
|
|
onUserEmailUpdate: PropTypes.func.isRequired,
|
|
|
|
onUserEmailUpdateMessageDismiss: PropTypes.func.isRequired,
|
|
|
|
onUserPasswordUpdate: PropTypes.func.isRequired,
|
|
|
|
onUserPasswordUpdateMessageDismiss: PropTypes.func.isRequired,
|
2019-08-31 04:07:25 +05:00
|
|
|
onLogout: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Header;
|