-
Notifications
You must be signed in to change notification settings - Fork 23
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
38 changed files
with
1,162 additions
and
203 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
37 changes: 37 additions & 0 deletions
37
src/common/AutoComplete/__tests__/__snapshots__/index.test.jsx.snap
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,37 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DateTimeSelect matches snapshot 1`] = ` | ||
<div | ||
className="MuiFormControl-root-2" | ||
onClick={[Function]} | ||
onKeyPress={[Function]} | ||
> | ||
<label | ||
className="MuiFormLabel-root-13 MuiFormLabel-filled-17 MuiInputLabel-root-6 MuiInputLabel-formControl-7 MuiInputLabel-animated-10 MuiInputLabel-shrink-9" | ||
data-shrink={true} | ||
> | ||
Date | ||
</label> | ||
<div | ||
className="MuiInputBase-root-33 MuiInput-root-20 MuiInput-underline-24 MuiInputBase-formControl-34 MuiInput-formControl-21" | ||
onClick={[Function]} | ||
> | ||
<input | ||
aria-invalid={false} | ||
className="MuiInputBase-input-43 MuiInput-input-28" | ||
disabled={false} | ||
mask={null} | ||
name="createdAt" | ||
onBlur={[Function]} | ||
onChange={[Function]} | ||
onFocus={[Function]} | ||
pipe={null} | ||
readOnly={true} | ||
required={false} | ||
type="text" | ||
value="January 1st 12:00 a.m." | ||
/> | ||
</div> | ||
</div> | ||
`; |
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,23 @@ | ||
import React from 'react' | ||
import renderer from 'react-test-renderer' | ||
import DateTimeSelect from '../' | ||
|
||
describe('DateTimeSelect', () => { | ||
const mochOnChange = jest.fn() | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('matches snapshot', () => { | ||
const component = renderer.create(( | ||
<DateTimeSelect | ||
label="Date" | ||
name="createdAt" | ||
value={new Date('1/1/2018')} | ||
onChange={mochOnChange} | ||
/> | ||
)) | ||
expect(component.toJSON()).toMatchSnapshot() | ||
}) | ||
}) |
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,31 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import Select from 'react-select' | ||
|
||
const AutoComplete = ({ | ||
label, | ||
name, | ||
value, | ||
options, | ||
onChange | ||
}) => ( | ||
<Select | ||
placeholder={label} | ||
name={name} | ||
value={value} | ||
options={options} | ||
inputProps={{ 'aria-label': label, required: true }} | ||
onChange={newValue => onChange(name, newValue.label)} | ||
isClearable={true} | ||
/> | ||
) | ||
|
||
AutoComplete.propTypes = { | ||
label: PropTypes.string.isRequired, | ||
name: PropTypes.string.isRequired, | ||
value: PropTypes.object.isRequired, | ||
options: PropTypes.array.isRequired, | ||
onChange: PropTypes.func.isRequired | ||
} | ||
|
||
export default AutoComplete |
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
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,176 @@ | ||
/* eslint no-console: 0 */ | ||
import React from 'react' | ||
import { compose } from 'recompose' | ||
import { connect } from 'react-redux' | ||
import PropTypes from 'prop-types' | ||
import { withStyles } from '@material-ui/core/styles' | ||
import Drawer from '@material-ui/core/Drawer' | ||
import List from '@material-ui/core/List' | ||
import ListSubheader from '@material-ui/core/ListSubheader' | ||
import ListItem from '@material-ui/core/ListItem' | ||
import ListItemIcon from '@material-ui/core/ListItemIcon' | ||
import ListItemText from '@material-ui/core/ListItemText' | ||
import Typography from '@material-ui/core/Typography' | ||
import Tooltip from '@material-ui/core/Tooltip' | ||
import DashboardIcon from '@material-ui/icons/Dashboard' | ||
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction' | ||
import IconButton from '@material-ui/core/IconButton' | ||
import AddIcon from '@material-ui/icons/Add' | ||
import EditIcon from '@material-ui/icons/Edit' | ||
import Divider from '@material-ui/core/Divider' | ||
import { NavLink } from 'react-router-dom' | ||
import grey from '@material-ui/core/colors/grey' | ||
import { sortedAccountsGroupedByInstitution } from '../../store/accounts/selectors' | ||
import { selectAccount } from '../../store/settings/actions' | ||
|
||
const styles = theme => ({ | ||
toolbar: theme.mixins.toolbar, | ||
drawerPaper: { | ||
maxWidth: 200 | ||
}, | ||
menuTitle: { | ||
margin: '20px' | ||
}, | ||
button: { | ||
fontSize: 10, | ||
padding: 5, | ||
minHeight: 22, | ||
marginLeft: 10, | ||
width: 50 | ||
}, | ||
leftIcon: { | ||
marginRight: theme.spacing.unit | ||
}, | ||
iconSmall: { | ||
fontSize: 12 | ||
}, | ||
noAccounts: { | ||
background: grey[100], | ||
margin: '0 20px 20px 25px', | ||
padding: theme.spacing.unit | ||
}, | ||
institution: { | ||
padding: '4px 24px' | ||
}, | ||
account: { | ||
padding: '4px 24px 4px 40px' | ||
}, | ||
smallButton: { | ||
padding: 4, | ||
marginRight: 5 | ||
}, | ||
smallIcon: { | ||
fontSize: 18 | ||
} | ||
}) | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
groupedAccounts: sortedAccountsGroupedByInstitution(state), | ||
selectedAccountId: state.settings.selectedAccountId | ||
} | ||
} | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
return { | ||
handleSelectAccount: (accountId) => { dispatch(selectAccount(accountId)) } | ||
} | ||
} | ||
|
||
const LeftDrawer = ({ | ||
classes, | ||
groupedAccounts, | ||
selectedAccountId, | ||
handleSelectAccount | ||
}) => ( | ||
<Drawer | ||
elevation={3} | ||
variant="permanent" | ||
classes={{ | ||
paper: classes.drawerPaper | ||
}} | ||
> | ||
<div className={classes.toolbar} /> | ||
<List> | ||
<ListItem button key="Dashboard"> | ||
<ListItemIcon><DashboardIcon /></ListItemIcon> | ||
<ListItemText primary="Dashboard" /> | ||
</ListItem> | ||
</List> | ||
<Divider /> | ||
<List | ||
component="nav" | ||
dense={true} | ||
subheader={ | ||
<ListSubheader component="div"> | ||
Accounts | ||
<ListItemSecondaryAction> | ||
<Tooltip id="tooltip-icon" title="New account"> | ||
<IconButton | ||
aria-label="New account" | ||
className={classes.smallButton} | ||
component={NavLink} | ||
to="/accounts" | ||
> | ||
<AddIcon /> | ||
</IconButton> | ||
</Tooltip> | ||
</ListItemSecondaryAction> | ||
</ListSubheader> | ||
} | ||
> | ||
{groupedAccounts.length === 0 && | ||
<Typography variant="caption" className={classes.noAccounts}> | ||
You don't have any accounts yet | ||
</Typography> | ||
} | ||
<List dense={true}> | ||
{Object.keys(groupedAccounts).map(institution => ( | ||
<div key={institution}> | ||
<ListItem className={classes.institution}> | ||
<ListItemIcon><DashboardIcon /></ListItemIcon> | ||
<ListItemText primary={institution} /> | ||
</ListItem> | ||
<List dense={true}> | ||
{groupedAccounts[institution].map(account => ( | ||
<ListItem | ||
className={classes.account} | ||
button | ||
key={account.id} | ||
selected={account.id === selectedAccountId} | ||
onClick={() => handleSelectAccount(account.id)} | ||
> | ||
<ListItemText primary={account.name} secondary="$100.00" /> | ||
<ListItemSecondaryAction> | ||
<Tooltip id="tooltip-icon" title="Edit account"> | ||
<IconButton aria-label="Edit account" className={classes.smallButton}> | ||
<EditIcon className={classes.smallIcon} /> | ||
</IconButton> | ||
</Tooltip> | ||
</ListItemSecondaryAction> | ||
</ListItem> | ||
))} | ||
</List> | ||
</div> | ||
))} | ||
</List> | ||
</List> | ||
</Drawer> | ||
) | ||
|
||
LeftDrawer.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
groupedAccounts: PropTypes.object.isRequired, | ||
selectedAccountId: PropTypes.string, | ||
handleSelectAccount: PropTypes.func.isRequired | ||
} | ||
|
||
LeftDrawer.defaultProps = { | ||
selectedAccountId: null | ||
} | ||
|
||
|
||
export default compose( | ||
connect(mapStateToProps, mapDispatchToProps), | ||
withStyles(styles) | ||
)(LeftDrawer) |
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.