-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Your Name
committed
May 10, 2017
0 parents
commit 1893151
Showing
16 changed files
with
7,269 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "projectmanager", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"jquery": "^3.2.1", | ||
"react": "^15.5.4", | ||
"react-dom": "^15.5.4" | ||
}, | ||
"devDependencies": { | ||
"react-scripts": "0.9.5" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
|
||
<title>Project Manager</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
|
||
</body> | ||
</html> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import React, { Component } from 'react'; | ||
import uuid from 'uuid'; | ||
import $ from 'jquery'; | ||
import Projects from './components/Projects'; | ||
import AddProject from './components/AddProject'; | ||
import Todos from './components/Todos'; | ||
import './App.css'; | ||
|
||
class App extends Component { | ||
constructor(){ | ||
super(); | ||
this.state = { | ||
projects: [], | ||
todos:[] | ||
} | ||
} | ||
|
||
getTodos(){ | ||
$.ajax({ | ||
url: 'https://jsonplaceholder.typicode.com/todos', | ||
dataType:'json', | ||
cache: false, | ||
success: function(data){ | ||
this.setState({todos: data}, function(){ | ||
console.log(this.state); | ||
}); | ||
}.bind(this), | ||
error: function(xhr, status, err){ | ||
console.log(err); | ||
} | ||
}); | ||
} | ||
|
||
getProjects(){ | ||
this.setState({projects: [ | ||
{ | ||
id:uuid.v4(), | ||
title: 'Business Website', | ||
category: 'Web Deisgn' | ||
}, | ||
{ | ||
id:uuid.v4(), | ||
title: 'Social App', | ||
category: 'Mobile Development' | ||
}, | ||
{ | ||
id:uuid.v4(), | ||
title: 'Ecommerce Shopping Cart', | ||
category: 'Web Development' | ||
} | ||
]}); | ||
} | ||
|
||
componentWillMount(){ | ||
this.getProjects(); | ||
this.getTodos(); | ||
} | ||
|
||
componentDidMount(){ | ||
this.getTodos(); | ||
} | ||
|
||
handleAddProject(project){ | ||
let projects = this.state.projects; | ||
projects.push(project); | ||
this.setState({projects:projects}); | ||
} | ||
|
||
handleDeleteProject(id){ | ||
let projects = this.state.projects; | ||
let index = projects.findIndex(x => x.id === id); | ||
projects.splice(index, 1); | ||
this.setState({projects:projects}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="App"> | ||
<AddProject addProject={this.handleAddProject.bind(this)} /> | ||
<Projects projects={this.state.projects} onDelete={this.handleDeleteProject.bind(this)} /> | ||
<hr /> | ||
<Todos todos={this.state.todos} /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<App />, div); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { Component } from 'react'; | ||
import uuid from 'uuid'; | ||
|
||
class AddProject extends Component { | ||
constructor(){ | ||
super(); | ||
this.state - { | ||
newProject: {} | ||
} | ||
} | ||
|
||
static defaultProps = { | ||
categories: ['Web Design', 'Web Development', 'Mobile Development'] | ||
} | ||
|
||
handelSubmit(e){ | ||
if(this.refs.title.value === ''){ | ||
alert('Title is required'); | ||
} else { | ||
this.setState({newProject:{ | ||
id: uuid.v4(), | ||
title: this.refs.title.value, | ||
category: this.refs.category.value | ||
}}, function(){ | ||
// console.log(this.state); | ||
this.props.addProject(this.state.newProject); | ||
}); | ||
} | ||
e.preventDefault(); | ||
} | ||
|
||
render() { | ||
let categoryOptions = this.props.categories.map(category =>{ | ||
return <option key={category} value={category}>{category}</option> | ||
}); | ||
return ( | ||
<div> | ||
<h3>Add Project</h3> | ||
<form onSubmit={this.handelSubmit.bind(this)}> | ||
<div> | ||
<label>Tile</label><br /> | ||
<input type='text' ref='title' /> | ||
</div> | ||
<div> | ||
<label>Category</label><br /> | ||
<select ref='category'> | ||
{categoryOptions} | ||
</select> | ||
</div> | ||
<br /> | ||
<input type='submit' value='Submit'/> | ||
</form> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
AddProject.propTypes = { | ||
categories: React.PropTypes.array, | ||
AddProject: React.PropTypes.func | ||
} | ||
|
||
export default AddProject; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { Component } from 'react'; | ||
|
||
|
||
class ProjectItem extends Component { | ||
|
||
deleteProject(id){ | ||
this.props.onDelete(id); | ||
} | ||
|
||
render() { | ||
return ( | ||
<li className="Project"> | ||
<strong>{this.props.project.title}</strong>: {this.props.project.category} <a href="#" onClick={this.deleteProject.bind(this, this.props.project.id)}>X</a> | ||
</li> | ||
); | ||
} | ||
} | ||
|
||
ProjectItem.propTypes = { | ||
project: React.PropTypes.object, | ||
onDelete: React.PropTypes.func | ||
} | ||
|
||
export default ProjectItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { Component } from 'react'; | ||
import ProjectItem from './ProjectItem'; | ||
|
||
class Projects extends Component { | ||
|
||
deleteProject(id){ | ||
this.props.onDelete(id); | ||
} | ||
|
||
render() { | ||
let projectItems; | ||
if(this.props.projects){ | ||
projectItems = this.props.projects.map(project => { | ||
// console.log(project); | ||
return( | ||
<ProjectItem onDelete={this.deleteProject.bind(this)} key={project.title} project={project} /> | ||
); | ||
}); | ||
} | ||
return ( | ||
<div className="Projects"> | ||
<h3>Latest Projects</h3> | ||
{projectItems} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Projects.propTypes = { | ||
projects: React.PropTypes.array, | ||
onDelete: React.PropTypes.func | ||
} | ||
|
||
export default Projects; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { Component } from 'react'; | ||
|
||
class TodoItem extends Component { | ||
render() { | ||
return ( | ||
<li className="Todo"> | ||
<strong>{this.props.todo.title}</strong> | ||
</li> | ||
); | ||
} | ||
} | ||
|
||
TodoItem.propTypes = { | ||
todo: React.PropTypes.object | ||
} | ||
|
||
export default TodoItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { Component } from 'react'; | ||
import TodoItem from './TodoItem'; | ||
|
||
class Todos extends Component { | ||
render() { | ||
let todoItems; | ||
if(this.props.todos){ | ||
todoItems = this.props.todos.map(todo => { | ||
//console.log(project); | ||
return ( | ||
<TodoItem key={todo.title} todo={todo} /> | ||
); | ||
}); | ||
} | ||
return ( | ||
<div className="Todos"> | ||
<h3>Todo List</h3> | ||
{todoItems} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Todos.propTypes = { | ||
todos: React.PropTypes.array | ||
} | ||
|
||
export default Todos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
font-family: sans-serif; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
|
||
ReactDOM.render( | ||
<App />, | ||
document.getElementById('root') | ||
); |
Oops, something went wrong.