Skip to content

Commit 855a452

Browse files
committed
section 12 13 added
1 parent 00cc8a9 commit 855a452

File tree

360 files changed

+90166
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

360 files changed

+90166
-405
lines changed

Section-03-ES6 for React JS/ES6-Starter App/app/app.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

Section-04 -React.js Fundamentals with ES6 & Web pack/ES6 Webpack React Router/lessons/07-more-nesting/modules/NavLink.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

Section-05-React Apps Using ES5&ES6/ES6-YouTube App/src/components/search_bar.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

Section-05-React Apps Using ES5&ES6/ES6-YouTube App/src/components/video_detail.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

Section-05-React Apps Using ES5&ES6/ES6-YouTube App/src/components/video_list.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

Section-05-React Apps Using ES5&ES6/ES6-YouTube App/src/components/video_list_item.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

Section-06.1-React Flux & ES6 Apps/React Flux Starter App/webpack.config.js

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import axios from 'axios';
2+
3+
export const FETCH_POSTS = 'FETCH_POSTS';
4+
export const CREATE_POST = 'CREATE_POST';
5+
export const FETCH_POST = 'FETCH_POST';
6+
export const DELETE_POST = 'DELETE_POST';
7+
8+
const ROOT_URL = 'http://reduxblog.herokuapp.com/';
9+
const API_KEY = 'jjkgjg76757qasx77868sx';
10+
11+
export function fetchPosts(){
12+
const request = axios.get(`${ROOT_URL}/posts${API_KEY}`);
13+
return {
14+
type: FETCH_POSTS,
15+
payload : request
16+
};
17+
}
18+
export function createPosts(props){
19+
const request = axios.post(`${ROOT_URL}/posts${API_KEY}` , props);
20+
return {
21+
type: CREATE_POST,
22+
payload : request
23+
};
24+
}
25+
export function fetchPost(id){
26+
const request = axios.get(`${ROOT_URL}/posts${id}${API_KEY}`);
27+
return {
28+
type: FETCH_POST,
29+
payload : request
30+
};
31+
}
32+
export function deletePost(id){
33+
const request = axios.delete(`${ROOT_URL}/posts${id}${API_KEY}`);
34+
return {
35+
type: DELETE_POST,
36+
payload : request
37+
};
38+
}

Section-08-React Redux/Sarter App Redux ES6/components/Counter.js

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import React, { Component, PropTypes } from 'react';
2+
import { reduxForm } from 'redux-form';
3+
import { createPost } from '../actions/index';
4+
import { Link } from 'react-router';
5+
6+
class PostsNew extends Component {
7+
8+
static contextTypes = {
9+
router: PropTypes.object
10+
};
11+
12+
onSubmit(props) {
13+
this.props.createPost(props)
14+
.then(() => {
15+
// blog post has been created, navigate the user to the index
16+
// We navigate by calling this.context.router.push with the
17+
// new path to navigate to.
18+
this.context.router.push('/');
19+
});
20+
}
21+
22+
render() {
23+
const { fields: { title, categories, content }, handleSubmit } = this.props;
24+
25+
return (
26+
<form onSubmit={handleSubmit(this.onSubmit.bind(this))}>
27+
<h3>Create A New Post</h3>
28+
29+
<div className={`form-group ${title.touched && title.invalid ? 'has-danger' : ''}`}>
30+
<label>Title</label>
31+
<input type="text" className="form-control" {...title} />
32+
<div className="text-help">
33+
{title.touched ? title.error : ''}
34+
</div>
35+
</div>
36+
37+
<div className={`form-group ${categories.touched && categories.invalid ? 'has-danger' : ''}`}>
38+
<label>Categories</label>
39+
<input type="text" className="form-control" {...categories} />
40+
<div className="text-help">
41+
{categories.touched ? categories.error : ''}
42+
</div>
43+
</div>
44+
45+
<div className={`form-group ${content.touched && content.invalid ? 'has-danger' : ''}`}>
46+
<label>Content</label>
47+
<textarea className="form-control" {...content} />
48+
<div className="text-help">
49+
{content.touched ? content.error : ''}
50+
</div>
51+
</div>
52+
53+
<button type="submit" className="btn btn-primary">Submit</button>
54+
<Link to="/" className="btn btn-danger">Cancel</Link>
55+
</form>
56+
);
57+
}
58+
}
59+
60+
function validate(values) {
61+
const errors = {};
62+
if (!values.title) {
63+
errors.title = 'Enter a username';
64+
}
65+
if (!values.categories) {
66+
errors.categories = 'Enter categories';
67+
}
68+
if(!values.content) {
69+
errors.content = 'Enter some content';
70+
}
71+
72+
return errors;
73+
}
74+
75+
// connect: first argument is mapStateToProps, 2nd is mapDispatchToProps
76+
// reduxForm: 1st is form config, 2nd is mapStateToProps, 3rd is mapDispatchToProps
77+
export default reduxForm({
78+
form: 'PostsNewForm',
79+
fields: ['title', 'categories', 'content'],
80+
validate
81+
}, null, { createPost })(PostsNew);

0 commit comments

Comments
 (0)