From e091f67a07b47b7459aa8c7ea1ddbcbed257d108 Mon Sep 17 00:00:00 2001 From: SaadYousaf Date: Sat, 23 Oct 2021 16:36:09 +0500 Subject: [PATCH] refactor: cleanup code. --- src/actions/index.js | 5 ----- src/components/NewPost.js | 1 + src/config.js | 1 - src/reducers/Posts.js | 3 --- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index 0966ca2..e319cb0 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -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 @@ -48,7 +47,3 @@ export function deletePost(postId) { err => dispatch({ type: 'DELETE_POST_FAILED', payload: err }) ); } - -export function updatedPostsViewed() { - return {type: UPDATED_POSTS_VIEWED} -} \ No newline at end of file diff --git a/src/components/NewPost.js b/src/components/NewPost.js index cf00356..b1db25c 100644 --- a/src/components/NewPost.js +++ b/src/components/NewPost.js @@ -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}) => { diff --git a/src/config.js b/src/config.js index c6ac07a..a9ee2b4 100644 --- a/src/config.js +++ b/src/config.js @@ -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}`, } diff --git a/src/reducers/Posts.js b/src/reducers/Posts.js index 7d0f53d..540baa2 100644 --- a/src/reducers/Posts.js +++ b/src/reducers/Posts.js @@ -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) @@ -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;