-
Notifications
You must be signed in to change notification settings - Fork 7
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
Showing
24 changed files
with
256 additions
and
175 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
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
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
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 |
---|---|---|
@@ -1,14 +1,20 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Route, Redirect } from 'react-router-dom'; | ||
|
||
function PrivateRoute({ component: Component, ...rest }) { | ||
return ( | ||
<Route {...rest} render={props => ( | ||
localStorage.getItem('token') | ||
? <Component {...props} /> | ||
: <Redirect to={{ pathname: '/signin', state: { from: props.location } }} /> | ||
)} /> | ||
<Route | ||
{...rest} | ||
render={props => | ||
localStorage.getItem('token') ? <Component {...props} /> : <Redirect to={{ pathname: '/signin' }} /> | ||
} | ||
/> | ||
); | ||
} | ||
|
||
PrivateRoute.propTypes = { | ||
component: PropTypes.any, | ||
}; | ||
|
||
export default PrivateRoute; |
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
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
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
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
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 |
---|---|---|
@@ -1,17 +1,30 @@ | ||
import { GET_POSTS_REQUEST, GET_POSTS_FAILURE, GET_POSTS_SUCCESS, POST_POSTS_REQUEST, POST_POSTS_SUCCESS, POST_POSTS_FAILURE, HANDLE_MODAL_SHOW, HANDLE_MODAL_CANCEL, ON_CHANGE_TITLE, ON_CHANGE_TEXT, ON_CHANGE_ADD_PHOTO, ON_CHANGE_DEL_PHOTO } from './constants'; | ||
import { | ||
GET_POSTS_REQUEST, | ||
GET_POSTS_FAILURE, | ||
GET_POSTS_SUCCESS, | ||
POST_POSTS_REQUEST, | ||
POST_POSTS_SUCCESS, | ||
POST_POSTS_FAILURE, | ||
HANDLE_MODAL_SHOW, | ||
HANDLE_MODAL_CANCEL, | ||
ON_CHANGE_TITLE, | ||
ON_CHANGE_TEXT, | ||
ON_CHANGE_ADD_PHOTO, | ||
ON_CHANGE_DEL_PHOTO, | ||
} from './constants'; | ||
|
||
export const getPostsAction = (payload) => ({ type: GET_POSTS_REQUEST, payload }); | ||
export const getPostsSuccess = (payload) => ({ type: GET_POSTS_SUCCESS, payload }); | ||
export const getPostsFailure = (payload) => ({ type: GET_POSTS_FAILURE, payload }); | ||
export const getPostsAction = payload => ({ type: GET_POSTS_REQUEST, payload }); | ||
export const getPostsSuccess = payload => ({ type: GET_POSTS_SUCCESS, payload }); | ||
export const getPostsFailure = payload => ({ type: GET_POSTS_FAILURE, payload }); | ||
|
||
export const postPostsAction = (payload) => ({ type: POST_POSTS_REQUEST, payload }); | ||
export const postPostsSuccess = (payload) => ({ type: POST_POSTS_SUCCESS, payload }); | ||
export const postPostsFailure = (payload) => ({ type: POST_POSTS_FAILURE, payload }); | ||
export const postPostsAction = payload => ({ type: POST_POSTS_REQUEST, payload }); | ||
export const postPostsSuccess = payload => ({ type: POST_POSTS_SUCCESS, payload }); | ||
export const postPostsFailure = payload => ({ type: POST_POSTS_FAILURE, payload }); | ||
|
||
export const handleModalShowAction = (payload) => ({ type: HANDLE_MODAL_SHOW, payload }); | ||
export const handleModalCancelAction = (payload) => ({ type: HANDLE_MODAL_CANCEL, payload }); | ||
export const handleModalShowAction = payload => ({ type: HANDLE_MODAL_SHOW, payload }); | ||
export const handleModalCancelAction = payload => ({ type: HANDLE_MODAL_CANCEL, payload }); | ||
|
||
export const onChangeTitleAction = (payload) => ({ type: ON_CHANGE_TITLE, payload }); | ||
export const onChangeTextAction = (payload) => ({ type: ON_CHANGE_TEXT, payload }); | ||
export const onChangeAddPhotoAction = (payload) => ({ type: ON_CHANGE_ADD_PHOTO, payload }); | ||
export const onChangeDelPhotoAction = (payload) => ({ type: ON_CHANGE_DEL_PHOTO, payload }); | ||
export const onChangeTitleAction = payload => ({ type: ON_CHANGE_TITLE, payload }); | ||
export const onChangeTextAction = payload => ({ type: ON_CHANGE_TEXT, payload }); | ||
export const onChangeAddPhotoAction = payload => ({ type: ON_CHANGE_ADD_PHOTO, payload }); | ||
export const onChangeDelPhotoAction = payload => ({ type: ON_CHANGE_DEL_PHOTO, payload }); |
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
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
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
Oops, something went wrong.