diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1e71037..deb515b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,11 +3,12 @@
-
+
+
@@ -15,14 +16,17 @@
+
+
+
-
+
-
-
+
+
@@ -30,33 +34,79 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -64,11 +114,11 @@
-
-
+
+
-
-
+
+
@@ -77,8 +127,8 @@
-
-
+
+
@@ -107,7 +157,6 @@
@@ -137,10 +190,12 @@
-
-
+
+
+
+
+
-
@@ -156,27 +211,27 @@
-
+
-
+
-
+
-
+
-
+
@@ -186,11 +241,11 @@
-
+
-
+
@@ -204,11 +259,11 @@
-
+
-
+
@@ -222,11 +277,11 @@
-
+
-
+
@@ -238,6 +293,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -248,6 +369,8 @@
+
+
@@ -267,17 +390,23 @@
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
@@ -305,6 +434,12 @@
+ project
+
+
+
+
+
@@ -327,6 +462,14 @@
false
+
+
+
+
+
+
+
+
@@ -339,6 +482,8 @@
1508430913430
+
+
1508432208309
@@ -379,28 +524,31 @@
-
+
-
-
+
+
-
-
+
+
+
+
-
-
+
+
+
+
-
+
-
+
-
-
+
@@ -421,31 +569,116 @@
-
+
+
+
+ file://$PROJECT_DIR$/src/components/auth/SignUp.js
+ 1
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -457,141 +690,175 @@
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
diff --git a/src/components/App.js b/src/components/App.js
index f70a4ed..2a71a2b 100644
--- a/src/components/App.js
+++ b/src/components/App.js
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
-import {Route} from 'react-router-dom'
+import {Route, NavLink} from 'react-router-dom'
import ProtectedRoute from './common/ProtectedRoute'
import AdminPage from './routes/Admin'
import AuthPage from './routes/Auth'
@@ -13,6 +13,8 @@ class App extends Component {
return (
Hello world
+
Admin
+
Auth
diff --git a/src/components/people/addHuman.js b/src/components/people/addHuman.js
new file mode 100644
index 0000000..282202e
--- /dev/null
+++ b/src/components/people/addHuman.js
@@ -0,0 +1,39 @@
+import React, {Component} from 'react';
+import {reduxForm, Field} from 'redux-form'
+import emailValidator from 'email-validator'
+import ErrorField from '../common/ErrorField'
+
+class AddHuman extends Component {
+ render() {
+ return (
+
+ );
+ }
+}
+
+const validate = ({ firstName, lastName, email }) => {
+ const errors = {}
+
+ if (!email) errors.email = 'email is a required field'
+ if (!firstName) errors.firstName = 'first name is a required field'
+ if (!lastName) errors.lastName = 'last name is a required field'
+
+ if (email && !emailValidator.validate(email)) errors.email = 'invalid email'
+
+ return errors
+}
+
+export default reduxForm({
+ form: 'people',
+ validate
+})(AddHuman)
diff --git a/src/components/routes/Admin.js b/src/components/routes/Admin.js
index 952248e..dd3cc31 100644
--- a/src/components/routes/Admin.js
+++ b/src/components/routes/Admin.js
@@ -1,4 +1,8 @@
import React, { Component } from 'react'
+import {Route, NavLink} from 'react-router-dom'
+import AddHuman from '../people/addHuman'
+import {connect} from 'react-redux'
+import {addHuman} from '../../ducks/people'
class Admin extends Component {
static propTypes = {
@@ -9,9 +13,13 @@ class Admin extends Component {
return (
Admin Page
+
add people
+
}/>
)
}
+
+ handleAddHuman = ({firstName, lastName, email}) => this.props.addHuman(firstName, lastName, email)
}
-export default Admin
\ No newline at end of file
+export default connect(null, { addHuman })(Admin)
\ No newline at end of file
diff --git a/src/config.js b/src/config.js
index 2782a0b..ec4b5a2 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,12 +1,12 @@
import firebase from 'firebase'
-export const appName = 'advreact-1610'
+export const appName = 'advreact-4303b'
firebase.initializeApp({
- apiKey: "AIzaSyB31xpTtp4Jln_hb2kAbE4PGf6Mi8EgLyA",
+ apiKey: "AIzaSyBfoQIRlS5EJWZTOHXgcP9xFy2m-wWRYfI",
authDomain: `${appName}.firebaseapp.com`,
databaseURL: `https://${appName}.firebaseio.com`,
projectId: appName,
storageBucket: "",
- messagingSenderId: "397157634637"
+ messagingSenderId: "665447136184"
})
\ No newline at end of file
diff --git a/src/ducks/people.js b/src/ducks/people.js
new file mode 100644
index 0000000..84aa55b
--- /dev/null
+++ b/src/ducks/people.js
@@ -0,0 +1,61 @@
+import {appName} from '../config'
+import {Record, Map} from 'immutable'
+import {reset} from 'redux-form'
+
+/**
+ * Constants
+ * */
+export const moduleName = 'people'
+const prefix = `${appName}/${moduleName}`
+
+export const ADD_PEOPLE_START = `${prefix}/ADD_PEOPLE_START`
+export const ADD_PEOPLE_SUCCESS = `${prefix}/ADD_PEOPLE_SUCCESS`
+
+/**
+ * Reducer
+ * */
+export const ReducerRecord = Record({
+ entities: new Map(),
+ loading: false,
+ error: null
+})
+
+export default function reducer(state = new ReducerRecord(), action) {
+ const {type, payload} = action
+
+ switch (type) {
+ case ADD_PEOPLE_START:
+ return state.set('loading', true)
+
+ case ADD_PEOPLE_SUCCESS:
+ return state
+ .update('entities', entities => entities.merge(payload))
+ .set('loading', false)
+
+ default:
+ return state
+ }
+}
+
+/**
+ * Selectors
+ * */
+
+/**
+ * Action Creators
+ * */
+export function addHuman(firstName, lastName, email) {
+ const id = +new Date();
+ return (dispatch) => {
+ dispatch({
+ type: ADD_PEOPLE_START
+ })
+
+ dispatch({
+ type: ADD_PEOPLE_SUCCESS,
+ payload: { [id]: {firstName, lastName, email} }
+ })
+
+ dispatch(reset(moduleName))
+ }
+}
\ No newline at end of file
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