Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
berwin committed Nov 1, 2015
1 parent 42c2dff commit 754645d
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 25 deletions.
7 changes: 6 additions & 1 deletion src/app/index/actions/category.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import * as types from '../constants/CategoryTypes';

// export add
export function addCategory(name) {
return {
type: types.ADD_CATEGORY,
name
}
}
File renamed without changes.
7 changes: 0 additions & 7 deletions src/app/index/components/category/category.jsx

This file was deleted.

17 changes: 17 additions & 0 deletions src/app/index/components/category/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as actions from '../../actions/category.js';

export default class Category extends Component {
render () {
console.log('category-index.jsx', this.props)
return (<div>menu</div>);
}
}

let mapStateToProps = state => state;

let mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);

export default connect(mapStateToProps, mapDispatchToProps)(Category);
17 changes: 4 additions & 13 deletions src/app/index/components/index.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import React, { Component } from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as actions from '../actions'
import Category from './category/index.jsx';
import List from './list/index.jsx';

export default class Index extends Component {
render () {
console.log(this.props)
return (
<div>
<h1>Todo-List</h1>
<div className="box">
<div>menu</div>
<div>list</div>
<Category />
<List />
</div>
</div>
);
}
}


let mapStateToProps = state => state;

let mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);

export default connect(mapStateToProps, mapDispatchToProps)(Index);
19 changes: 19 additions & 0 deletions src/app/index/components/list/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as actions from '../../actions/list.js';

export default class List extends Component {
render () {
console.log('list-index.jsx', this.props)
return (
<div>list</div>
);
}
}

let mapStateToProps = state => state;

let mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);

export default connect(mapStateToProps, mapDispatchToProps)(List);
3 changes: 0 additions & 3 deletions src/app/index/containers/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Router, Route, Link } from 'react-router';
import * as actions from '../actions';
import Index from '../components/index.jsx';

export default class View extends Component {
Expand Down
28 changes: 28 additions & 0 deletions src/app/index/reducers/category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ADD_CATEGORY } from '../constants/CategoryTypes';


/**
* 创建分类
*
*
*/
let createCategory = name => {
let time = Date.now();

return {
id: Math.random().toString(36).split('.').join(''),
addTime: time,
updateTime: time,
name
}
}

export default (state = [], action) => {
switch (action.type) {
case ADD_CATEGORY:
return [createCategory(action.name)]

default:
return state
}
}
3 changes: 2 additions & 1 deletion src/app/index/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { combineReducers } from 'redux';
import category from './category';
import list from './list';

export default combineReducers({list});
export default combineReducers({category, list});

0 comments on commit 754645d

Please sign in to comment.