Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring: Cleaning up code. #10

Merged
merged 1 commit into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const FETCH_POSTS = projectConfig.FETCH_POSTS;
const CREATE_POST = projectConfig.CREATE_POST;
const FETCH_POST = projectConfig.FETCH_POST;
const DELETE_POST = projectConfig.DELETE_POST;
const UPDATED_POSTS_VIEWED = projectConfig.UPDATED_POSTS_VIEWED

const ROOT_URL = projectConfig.ROOT_URL
const API_KEY = projectConfig.API_KEY
Expand Down Expand Up @@ -48,7 +47,3 @@ export function deletePost(postId) {
err => dispatch({ type: 'DELETE_POST_FAILED', payload: err })
);
}

export function updatedPostsViewed() {
return {type: UPDATED_POSTS_VIEWED}
}
1 change: 1 addition & 0 deletions src/components/NewPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function NewPost(props) {
}} onSubmit={({title, category, content}) => {
props.createPost({title: title, category: category, content: content})
.then(res => history.push('/'))
.catch(error => console.log('Error creating Posts'))
// todo: add catch block and update state
}} >
{({ values, handleChange, handleBlur, handleSubmit}) => {
Expand Down
1 change: 0 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const projectConfig = {
FETCH_POST : 'FETCH_POST',
CREATE_POST : 'CREATE_POSTS',
DELETE_POST : 'DELETE_POST',
UPDATED_POSTS_VIEWED: 'UPDATED_POSTS_VIEWED',
ROOT_URL : 'http://reduxblog.herokuapp.com/api',
API_KEY : `?key=${random_API_KEY}`,
}
3 changes: 0 additions & 3 deletions src/reducers/Posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const FETCH_POSTS = projectConfig.FETCH_POSTS
const FETCH_POST = projectConfig.FETCH_POST
const DELETE_POST = projectConfig.DELETE_POST
const CREATE_POST = projectConfig.CREATE_POST
const UPDATED_POSTS_VIEWED = projectConfig.UPDATED_POSTS_VIEWED

export default function(state = INITIAL_STATE, action) {
console.log('action', action)
Expand All @@ -18,8 +17,6 @@ export default function(state = INITIAL_STATE, action) {
return { ...state, postsUpdated: true}
case CREATE_POST:
return {...state, allPosts: [...state.allPosts, action.payload.data], postsUpdated: true}
case UPDATED_POSTS_VIEWED:
return {...state, postsUpdated: false}

default:
return state;
Expand Down