Personal Dashboard

Notes.jsx 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import React from 'react'
  2. import { connect } from 'react-redux'
  3. import { Card, Placeholder, Icon, DeleteButton } from '../../Shared/Components'
  4. import { Menu, MenuDivider, MenuItem, EditableText, Intent, Button, Alert } from '@blueprintjs/core'
  5. import * as actions from '../../Store/Actions/notes'
  6. import NoteList from './NoteList'
  7. import Note from './Note'
  8. import './Notes.scss'
  9. const NotesTemplate = ({ notes, selected, select, update, add, remove }) =>
  10. <div className="Notes">
  11. <Card className="List">
  12. <NoteList notes={notes} add={add} select={select} />
  13. </Card>
  14. <Card className="content">
  15. { selected ?
  16. <Note note={selected} update={update} remove={remove} /> :
  17. <Placeholder iconName="clipboard" title="No note selected"
  18. description="Choose one in the list on the left"/> }
  19. </Card>
  20. </div>
  21. const Notes = connect(
  22. state => ({ notes: state.note.notes, selected: state.note.selectedNote }),
  23. dispatch => ({
  24. add: () => dispatch(actions.ADD_NOTE()),
  25. select: note => dispatch(actions.SELECT_NOTE(note)),
  26. remove: note => {
  27. dispatch(actions.REMOVE_NOTE(note))
  28. dispatch(actions.UNSELECT_NOTE())
  29. },
  30. update: note => {
  31. dispatch(actions.UPDATE_NOTE(note))
  32. dispatch(actions.UPDATE_SELECTED_NOTE(note))
  33. }
  34. })
  35. )(NotesTemplate)
  36. export default Notes