I have no idea what i'm doing :(
This commit is contained in:
parent
fbbec03557
commit
fabf06b8a6
4 changed files with 10 additions and 6 deletions
|
@ -5,7 +5,7 @@ export const fetchPosts = () => async (dispatch) => {
|
||||||
dispatch({ type: 'FETCH_POSTS', payload: response.data })
|
dispatch({ type: 'FETCH_POSTS', payload: response.data })
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchPost = () => async (dispatch) => {
|
export const fetchPost = (id) => async (dispatch) => {
|
||||||
const response = await sudoscientist.get('/blog');
|
const response = await sudoscientist.get('/blog/' + id);
|
||||||
dispatch({ type: 'FETCH_POSTS', payload: response.data })
|
dispatch({ type: 'FETCH_POST', payload: response.data })
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,10 +6,12 @@ import PostList from './PostList';
|
||||||
class NavBar extends Component {
|
class NavBar extends Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="ui three item menu">
|
<div className="ui five item menu">
|
||||||
<Link to="/" className="active item">Home</Link>
|
<img src="https://avatars1.githubusercontent.com/u/2782304" style={{width:"50px",height:"50px"}}/>
|
||||||
|
<Link to="/" className="item">Home</Link>
|
||||||
<Link to="/users/" className="item">Users</Link>
|
<Link to="/users/" className="item">Users</Link>
|
||||||
<Link to="/posts/" className="item">Posts</Link>
|
<Link to="/posts/" className="item">Posts</Link>
|
||||||
|
<Link to="/about/" className="item">About</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactMarkdown from 'react-markdown';
|
import ReactMarkdown from 'react-markdown';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { fetchPosts } from '../actions';
|
import { fetchPost } from '../actions';
|
||||||
|
|
||||||
class Post extends React.Component {
|
class Post extends React.Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
|
@ -2,6 +2,8 @@ export default (state = [], action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'FETCH_POSTS':
|
case 'FETCH_POSTS':
|
||||||
return action.payload;
|
return action.payload;
|
||||||
|
case 'FETCH_POST':
|
||||||
|
return action.payload;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue