Rename action to redux convention

pull/975/head
Jared Scheib 2017-03-09 13:59:10 -08:00
parent 5350093d25
commit bda2521d7c
3 changed files with 6 additions and 6 deletions

View File

@ -2,7 +2,7 @@ import reducer from 'src/admin/reducers/admin'
import {
addUser,
confirmUserCreated,
createUserSuccess,
editUser,
loadRoles,
deleteRole,
@ -69,7 +69,7 @@ describe('Admin.Reducers', () => {
}
state = {users: [u2, addedUser]}
const actual = reducer(state, confirmUserCreated(addedUser, u1))
const actual = reducer(state, createUserSuccess(addedUser, u1))
const expected = {
users: [u2, u1],
}

View File

@ -29,8 +29,8 @@ export const addUser = () => ({
type: 'ADD_USER',
})
export const confirmUserCreated = (user, createdUser) => ({
type: 'CONFIRM_USER_CREATED',
export const createUserSuccess = (user, createdUser) => ({
type: 'CREATE_USER_SUCCESS',
payload: {
user,
createdUser,
@ -109,7 +109,7 @@ export const createUserAsync = (url, user) => async (dispatch) => {
try {
const {data} = await createUserAJAX(url, user)
dispatch(publishNotification('success', 'User created successfully'))
dispatch(confirmUserCreated(user, data))
dispatch(createUserSuccess(user, data))
} catch (error) {
// undo optimistic update
dispatch(publishNotification('error', `Failed to create user: ${error.data.message}`))

View File

@ -37,7 +37,7 @@ export default function admin(state = initialState, action) {
}
}
case 'CONFIRM_USER_CREATED': {
case 'CREATE_USER_SUCCESS': {
const {user, createdUser} = action.payload
const newState = {
users: state.users.map(u => u.links.self === user.links.self ? {...createdUser} : u),