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