File tree Expand file tree Collapse file tree 2 files changed +23
-16
lines changed Expand file tree Collapse file tree 2 files changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import {Redirect} from 'react-router-dom'
99class Dashboard extends Component {
1010
1111 render ( ) {
12- const { projects, auth} = this . props ;
12+ const { projects, auth, notifications } = this . props ;
1313 if ( ! auth . uid ) {
1414 return < Redirect to = "/signin" />
1515 }
@@ -22,7 +22,7 @@ class Dashboard extends Component {
2222 < ProjectList projects = { projects } />
2323 </ div >
2424 < div className = "col s12 m5 offset-m1" >
25- < Notifications />
25+ < Notifications notifications = { notifications } />
2626 </ div >
2727 </ div >
2828 </ div >
@@ -35,13 +35,15 @@ const mapStateToProps = (state) => {
3535 console . log ( state )
3636 return {
3737 projects : state . fireStore . ordered . projects ,
38- auth : state . firebase . auth
38+ auth : state . firebase . auth ,
39+ notifications : state . fireStore . ordered . notifications
3940 }
4041}
4142
4243export default compose (
4344 connect ( mapStateToProps ) ,
4445 firestoreConnect ( [
45- { collection : 'projects' }
46+ { collection : 'projects' } ,
47+ { collection : 'notifications' , limit :3 , orderBy : [ 'time' , 'desc' ] }
4648 ] )
4749) ( Dashboard )
Original file line number Diff line number Diff line change 11import React from 'react'
2+ import moment from 'moment'
23
34const Notifications = ( props ) => {
45
6+ const { notifications} = props ;
7+ console . log ( notifications )
8+
59 return (
610 < div className = "section" >
711 < div className = "card z-depth-0" >
@@ -10,18 +14,19 @@ const Notifications = (props) =>{
1014 Notifications
1115 </ span >
1216 < ul className = "notifications" >
13- < li >
14- Notification
15- </ li >
16- < li >
17- Notification
18- </ li >
19- < li >
20- Notification
21- </ li >
22- < li >
23- Notification
24- </ li >
17+ { notifications && notifications . map ( item => {
18+ return (
19+ < li key = { item . id } >
20+ < span className = "pink-text" > { item . user } </ span >
21+ < span className = "pink-text" >
22+ { item . content }
23+ </ span >
24+ < div className = "grey-text note-date" >
25+ { moment ( item . time . toDate ( ) ) . fromNow ( ) }
26+ </ div >
27+ </ li >
28+ )
29+ } ) }
2530 </ ul >
2631 </ div >
2732 </ div >
You can’t perform that action at this time.
0 commit comments