first commit
This commit is contained in:
5
lib/components/notifications/action_constants.js
Normal file
5
lib/components/notifications/action_constants.js
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
RECEIVE_NOTIFICATIONS: 'RECEIVE_NOTIFICATIONS',
|
||||
}
|
||||
12
lib/components/notifications/actions.js
Normal file
12
lib/components/notifications/actions.js
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const {RECEIVE_NOTIFICATIONS} = require('./action_constants')
|
||||
|
||||
module.exports = {
|
||||
receivedNotifications: notifications => {
|
||||
return {
|
||||
type: RECEIVE_NOTIFICATIONS,
|
||||
notifications,
|
||||
}
|
||||
}
|
||||
}
|
||||
20
lib/components/notifications/proxy.js
Normal file
20
lib/components/notifications/proxy.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict'
|
||||
|
||||
const {receivedNotifications} = require('./actions')
|
||||
|
||||
module.exports = {
|
||||
// urls that should be called for the remote actions
|
||||
urls: {
|
||||
fetch: 'https://layla.amazon.de/api/notifications',
|
||||
},
|
||||
// called after an remote http call to the notifications API has been successfully executed
|
||||
postHooks: {
|
||||
// called after the notifications have been fetched
|
||||
fetch:(store, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
store.dispatch(receivedNotifications(data))
|
||||
resolve(data)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
13
lib/components/notifications/reducer.js
Normal file
13
lib/components/notifications/reducer.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict'
|
||||
const {RECEIVE_NOTIFICATIONS} = require('./action_constants')
|
||||
|
||||
module.exports = (state = {}, action) => {
|
||||
switch (action.type) {
|
||||
case RECEIVE_NOTIFICATIONS:
|
||||
return Object.assign({}, state, {
|
||||
notifications: action.notifications
|
||||
})
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
7
lib/components/notifications/route.js
Normal file
7
lib/components/notifications/route.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
'/notifications': (store, params, cb) => {
|
||||
cb(store.getState().notifications.notifications.notifications)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user