-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
335 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { useEffect } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { List } from 'immutable'; | ||
import { SHARED_ITEMS_ID } from '../config/selectors'; | ||
import ItemsHeader from './main/ItemsHeader'; | ||
import Items from './main/Items'; | ||
import { getSharedItems } from '../actions/item'; | ||
|
||
const SharedItems = ({ activity, sharedItems, dispatchGetSharedItems }) => { | ||
const { t } = useTranslation(); | ||
|
||
useEffect(() => { | ||
if (!activity) { | ||
// update dirty items | ||
if (sharedItems.some(({ dirty }) => dirty)) { | ||
dispatchGetSharedItems(); | ||
} | ||
} | ||
}, [activity, sharedItems, dispatchGetSharedItems]); | ||
|
||
return ( | ||
<> | ||
<ItemsHeader navigationRootText={t('Shared')} /> | ||
<Items | ||
id={SHARED_ITEMS_ID} | ||
title={t('Items Shared With Me')} | ||
items={sharedItems} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
const mapStateToProps = ({ item }) => ({ | ||
activity: Boolean(Object.values(item.get('activity').toJS()).flat().length), | ||
sharedItems: item.get('shared'), | ||
}); | ||
|
||
const mapDispatchToProps = { | ||
dispatchGetSharedItems: getSharedItems, | ||
}; | ||
|
||
SharedItems.propTypes = { | ||
activity: PropTypes.bool.isRequired, | ||
dispatchGetSharedItems: PropTypes.func.isRequired, | ||
sharedItems: PropTypes.instanceOf(List).isRequired, | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(SharedItems); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,82 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import PropTypes from 'prop-types'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { AppBar, Toolbar, Typography, IconButton } from '@material-ui/core'; | ||
import MenuIcon from '@material-ui/icons/Menu'; | ||
import MenuOpenIcon from '@material-ui/icons/MenuOpen'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import { AppBar, Toolbar, Typography } from '@material-ui/core'; | ||
import { AccountCircle } from '@material-ui/icons'; | ||
import { ReactComponent as GraaspLogo } from '../../resources/graasp-logo.svg'; | ||
import { APP_NAME } from '../../config/constants'; | ||
import { APP_NAME, HEADER_HEIGHT } from '../../config/constants'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
header: { | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
zIndex: theme.zIndex.drawer + 1, | ||
}, | ||
headerLeft: { | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
}, | ||
logo: { | ||
height: '48px', | ||
marginRight: theme.spacing(2), | ||
height: '40px', | ||
margin: theme.spacing(0, 2), | ||
}, | ||
link: { | ||
textDecoration: 'none', | ||
color: 'inherit', | ||
display: 'flex', | ||
alignItems: 'center', | ||
}, | ||
appBarBlank: { | ||
height: HEADER_HEIGHT, | ||
}, | ||
})); | ||
|
||
const Header = () => { | ||
const Header = ({ isMenuOpen, toggleMenu }) => { | ||
const classes = useStyles(); | ||
|
||
const renderMenuIcon = () => { | ||
if (isMenuOpen) { | ||
return ( | ||
<IconButton onClick={() => toggleMenu(false)} color="inherit"> | ||
<MenuOpenIcon /> | ||
</IconButton> | ||
); | ||
} | ||
return ( | ||
<IconButton onClick={() => toggleMenu(true)} color="inherit"> | ||
<MenuIcon /> | ||
</IconButton> | ||
); | ||
}; | ||
|
||
return ( | ||
<header> | ||
<AppBar position="static"> | ||
<Toolbar className={classes.header}> | ||
<AppBar position="fixed"> | ||
<Toolbar className={classes.header}> | ||
<div className={classes.headerLeft}> | ||
{renderMenuIcon()} | ||
<Link to="/items" className={classes.link}> | ||
<div className={classes.headerLeft}> | ||
<GraaspLogo className={classes.logo} /> | ||
<Typography variant="h6" color="inherit"> | ||
{APP_NAME} | ||
</Typography> | ||
</div> | ||
<GraaspLogo className={classes.logo} /> | ||
<Typography variant="h6" color="inherit"> | ||
{APP_NAME} | ||
</Typography> | ||
</Link> | ||
<IconButton color="inherit"> | ||
<AccountCircle /> | ||
</IconButton> | ||
</Toolbar> | ||
</AppBar> | ||
</header> | ||
</div> | ||
<IconButton color="inherit"> | ||
<AccountCircle /> | ||
</IconButton> | ||
</Toolbar> | ||
</AppBar> | ||
); | ||
}; | ||
|
||
Header.propTypes = { | ||
toggleMenu: PropTypes.func.isRequired, | ||
isMenuOpen: PropTypes.bool.isRequired, | ||
}; | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.