diff --git a/package.json b/package.json index c6d9612..fd61de2 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,14 @@ "debug": "^2.2.0", "evil-icons": "^1.8.0", "express": "^4.13.4", + "prop-types": "^15.5.10", "react": "^15.1.0", "react-dom": "^15.1.0", "react-evil-icons": "^0.4.0", "react-redux": "^5.0.5", "redux": "^3.5.2", "sancus": "^1.0.3", + "universal-cookie": "^2.0.8", "webpack": "^3.3.0", "webpack-dev-middleware": "^1.6.1", "webpack-dev-server": "^2.5.1", diff --git a/src/actions/contact.js b/src/actions/contact.js new file mode 100644 index 0000000..31b2130 --- /dev/null +++ b/src/actions/contact.js @@ -0,0 +1,31 @@ +import * as types from './types'; + +export const addContact = (name, phone, email) => ({ + type: types.ADD_CONTACT, + name, + phone, + email +}); + +export const deleteContact = id => ({ + type: types.DELETE_CONTACT, + id +}); + +export const saveContact = (id, name, phone, email) => ({ + type: types.SAVE_CONTACT, + id, + name, + phone, + email +}); + +export const addFavourite = id => ({ + type: types.ADD_FAVOURITE, + id +}); + +export const deleteFavourite = id => ({ + type: types.DELETE_FAVOURITE, + id +}); diff --git a/src/actions/types.js b/src/actions/types.js new file mode 100644 index 0000000..5bc5647 --- /dev/null +++ b/src/actions/types.js @@ -0,0 +1,5 @@ +export const ADD_CONTACT = 'ADD_CONTACT'; +export const DELETE_CONTACT = 'DELETE_CONTACT'; +export const SAVE_CONTACT = 'SAVE_CONTACT'; +export const ADD_FAVOURITE = 'ADD_FAVOURITE'; +export const DELETE_FAVOURITE = 'DELETE_FAVOURITE'; diff --git a/src/app/app.jsx b/src/app/app.jsx index b1474ec..3add506 100644 --- a/src/app/app.jsx +++ b/src/app/app.jsx @@ -1,16 +1,40 @@ import React from 'react'; import './app.scss'; -import { Column, Row, Title, Button } from '../components'; +import { Column, Row, Title, ContactEdit, Modal, Button } from '../components'; +import { Contacts, Favourites } from '../containers'; -const onAddClick = (event) => { -}; +class App extends React.Component { + constructor(props) { + super(props); + this.state = { + editModalVisible: false + }; + } -const App = () => ( - - Contact Book - +const Button = ({ className, children, label, onClick }) => ( + ); Button.propTypes = { children: PropTypes.string, label: PropTypes.string, - onClick: PropTypes.func.isRequired + onClick: PropTypes.func.isRequired, + className: PropTypes.string.isRequired }; Button.defaultProps = { label: null, - children: null + children: null, + className: 'button' }; export default Button; diff --git a/src/components/controls/contact-edit.jsx b/src/components/controls/contact-edit.jsx new file mode 100644 index 0000000..1cbe786 --- /dev/null +++ b/src/components/controls/contact-edit.jsx @@ -0,0 +1,77 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import '../../app/app.scss'; +import { Column, Row } from '../grid'; +import { Button } from '../controls'; +import { ContactSaveButton, ContactDeleteButton } from '../../containers'; + +class ContactEdit extends React.Component { + constructor(props) { + super(props); + this.state = { + name: this.props.contact.name, + phone: this.props.contact.phone, + email: this.props.contact.email + }; + } + + render = () => ( + + + + { this.setState({ name: e.target.value }); }} + /> + + + { this.setState({ phone: e.target.value }); }} + /> + + + { this.setState({ email: e.target.value }); }} + /> + +