diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index eee0d88..d3f894c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,11 +1,9 @@
-
+
-
-
-
+
@@ -17,14 +15,49 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -32,28 +65,64 @@
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -65,33 +134,35 @@
+
-
-
+
+
+ false
+
+ false
+ false
+ true
true
@@ -100,11 +171,12 @@
-
-
-
+
+
+
+
+
-
@@ -120,110 +192,39 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
@@ -237,185 +238,151 @@
-
-
-
-
-
+
+
+
-
- 1503592443999
+
+ 1503779144919
- 1503592443999
-
+ 1503779144919
+
+
-
- 1503593226366
+
+ 1503780272995
- 1503593226366
+ 1503780272996
-
- 1503594097224
+
+ 1503834001421
- 1503594097224
-
-
- 1503595131217
-
-
-
- 1503595131217
-
-
- 1503596679341
-
-
-
- 1503596679341
+ 1503834001421
-
- 1503597143069
-
-
-
- 1503597143069
-
-
+
-
+
-
+
-
+
+
-
-
-
-
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
-
+
-
-
-
+
+
+
+
+
-
+
-
+
-
-
+
-
-
-
-
-
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
-
+
+
+
-
+
-
-
+
+
@@ -425,104 +392,78 @@
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/components/Root.js b/src/components/Root.js
index bbf2596..3541efb 100644
--- a/src/components/Root.js
+++ b/src/components/Root.js
@@ -2,6 +2,7 @@ import React, { Component } from 'react'
import {Route} from 'react-router-dom'
import AdminPage from './routes/AdminPage'
import AuthPage from './routes/AuthPage'
+import PeoplePage from './routes/PeoplePage'
import ProtectedRoute from './common/ProtectedRoute'
class Root extends Component {
@@ -14,6 +15,7 @@ class Root extends Component {
)
}
diff --git a/src/components/people/AddUserForm.js b/src/components/people/AddUserForm.js
new file mode 100644
index 0000000..dd62157
--- /dev/null
+++ b/src/components/people/AddUserForm.js
@@ -0,0 +1,54 @@
+import React, { Component } from 'react'
+import {NavLink} from 'react-router-dom'
+import {reduxForm, Field} from 'redux-form'
+import emailValidator from 'email-validator'
+import ErrorField from '../common/ErrorField'
+
+class AddUserForm extends Component {
+ static propTypes = {
+
+ };
+
+ render() {
+ const {handleSubmit} = this.props
+ return (
+
+ )
+ }
+}
+
+const validate = ({email}) => {
+ const errors = {}
+
+ if (!email) errors.email = 'email is required'
+ else if (!emailValidator.validate(email)) errors.email = 'invalid email'
+
+ /*тут бы еще хотелось проверять, есть ли уже такой e-mail, но я вот не знаю как лучше подрубить стор?
+ как то так?
+ export default connect(state => ({..}))(reduxForm({
+ form: 'addPeople',
+ validate
+ })(AddUserForm))
+ *
+ * */
+
+
+ return errors
+}
+
+
+export default reduxForm({
+ form: 'addPeople',
+ validate
+})(AddUserForm)
\ No newline at end of file
diff --git a/src/components/routes/PeoplePage.js b/src/components/routes/PeoplePage.js
new file mode 100644
index 0000000..5f1e238
--- /dev/null
+++ b/src/components/routes/PeoplePage.js
@@ -0,0 +1,36 @@
+import React, { Component } from 'react'
+import {Route, NavLink} from 'react-router-dom'
+import {connect} from 'react-redux'
+import AddUserForm from '../people/AddUserForm'
+import {addUser, moduleName} from '../../ducks/people'
+import Loader from '../common/Loader'
+
+class PeoplePage extends Component {
+ static propTypes = {};
+
+ render() {
+ const {loading,user} = this.props
+ console.log(user)
+ return (
+
+
People Page
+ {user ?
Добавлен пользователь {user.firstname}
: ''}
+
add User
+
}/>
+ {loading && }
+
+ )
+ }
+
+ handleAdd = (values) => this.props.addUser(values)
+
+}
+
+export default connect(state => {
+ const people = state[moduleName]
+
+ return {
+ user: people.user.get(people.user.size - 1)
+ /*loading: state[moduleName].loading*/
+ }
+}, {addUser})(PeoplePage)
\ No newline at end of file
diff --git a/src/ducks/people.js b/src/ducks/people.js
new file mode 100644
index 0000000..d6d5e84
--- /dev/null
+++ b/src/ducks/people.js
@@ -0,0 +1,35 @@
+import {Record, List} from 'immutable'
+import {appName} from '../config'
+
+const ReducerRecord = Record({
+ user: new List(),
+ error: null,
+ loading: false
+})
+
+export const moduleName = 'people'
+
+export const ADD_USER_SUCCESS = `${appName}/${moduleName}/ADD_USER_SUCCESS`
+
+export default function reducer(state = new ReducerRecord(), action) {
+ const {type, payload} = action
+
+ switch (type) {
+ case ADD_USER_SUCCESS:
+ return state.set('user', state.user.push(payload))
+
+ default:
+ return state
+ }
+}
+
+export function addUser(values) {
+
+ return (dispatch) => {
+ console.log('There')
+ dispatch({
+ type: ADD_USER_SUCCESS,
+ payload: values
+ })
+ }
+}
diff --git a/src/redux/reducer.js b/src/redux/reducer.js
index 34143fe..cc6e0aa 100644
--- a/src/redux/reducer.js
+++ b/src/redux/reducer.js
@@ -2,8 +2,10 @@ import {combineReducers} from 'redux'
import {routerReducer as router} from 'react-router-redux'
import {reducer as form} from 'redux-form'
import authReducer, {moduleName as authModule} from '../ducks/auth'
+import peopleReducer, {moduleName as peopleModule} from '../ducks/people'
export default combineReducers({
router, form,
- [authModule]: authReducer
+ [authModule]: authReducer,
+ [peopleModule]: peopleReducer
})
\ No newline at end of file