Commit 65ded2ee by hfpp2012 yinsigan

完成saga

1 parent 18613311
...@@ -3,3 +3,8 @@ import * as types from '../constants/ActionTypes' ...@@ -3,3 +3,8 @@ import * as types from '../constants/ActionTypes'
export const getHeader = () => ({ export const getHeader = () => ({
type: types.HEADER_FETCH_REQUESTED type: types.HEADER_FETCH_REQUESTED
}) })
export const addRepo = (repo) => ({
type: types.ADD_REPO,
repo
})
...@@ -49,7 +49,7 @@ class Header extends React.Component { ...@@ -49,7 +49,7 @@ class Header extends React.Component {
return ( return (
<div className="text-left top-header"> <div className="text-left top-header">
<ModalRepoForm handleNewRepo={ this.addRepo } /> <ModalRepoForm handleNewRepo={ actions.addRepo } />
<div className='col-md-10'> <div className='col-md-10'>
{ result } { result }
</div> </div>
......
...@@ -7,3 +7,4 @@ export const DELETE_ELEMENT = 'DELETE_ELEMENT' ...@@ -7,3 +7,4 @@ export const DELETE_ELEMENT = 'DELETE_ELEMENT'
export const HEADER_FETCH_REQUESTED = 'HEADER_FETCH_REQUESTED' export const HEADER_FETCH_REQUESTED = 'HEADER_FETCH_REQUESTED'
export const HEADER_FETCH_SUCCEEDED = 'HEADER_FETCH_SUCCEEDED' export const HEADER_FETCH_SUCCEEDED = 'HEADER_FETCH_SUCCEEDED'
export const HEADER_FETCH_FAILED = 'HEADER_FETCH_FAILED' export const HEADER_FETCH_FAILED = 'HEADER_FETCH_FAILED'
export const ADD_REPO = 'ADD_REPO'
import { HEADER_FETCH_REQUESTED, HEADER_FETCH_SUCCEEDED, HEADER_FETCH_FAILED } from '../constants/ActionTypes' import { HEADER_FETCH_REQUESTED, HEADER_FETCH_SUCCEEDED, HEADER_FETCH_FAILED, ADD_REPO } from '../constants/ActionTypes'
const header = (state = {}, action) => { const header = (state = {}, action) => {
switch (action.type) { switch (action.type) {
...@@ -18,6 +18,15 @@ const header = (state = {}, action) => { ...@@ -18,6 +18,15 @@ const header = (state = {}, action) => {
error_message: action.message, error_message: action.message,
headers: [] headers: []
} }
case ADD_REPO:
return {
isFetching: false,
error_message: null,
headers: [
...state.headers,
action.repo
]
}
default: default:
return state return state
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!