-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from andela/ft-users-should-coment-on-articles…
…-164047029 #164047029 User can comment on articles
- Loading branch information
Showing
48 changed files
with
1,562 additions
and
308 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.App-header { | ||
background-color: #F6FAF9; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: black; } | ||
.App-header label { | ||
color: black; } |
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import axios from 'axios'; | ||
import axiosHeader from '../axios_config'; | ||
import { | ||
FETCH_COMMENTS, COMMENT_ON_ARTICLE, COMMENT_ON_COMMENT, EDIT_COMMENT, | ||
} from './action_types'; | ||
|
||
export const fetchArticleComments = slug => async (dispatch) => { | ||
await axios | ||
.get( | ||
`${ | ||
process.env.REACT_APP_BASE_URL | ||
}/articles/${slug}/comments/`, | ||
axiosHeader, | ||
) | ||
.then((result) => { | ||
dispatch({ | ||
type: FETCH_COMMENTS, | ||
payload: result.data, | ||
}); | ||
}) | ||
.catch(() => {}); | ||
}; | ||
|
||
export const CommentOnArticle = (slug, comment) => async (dispatch) => { | ||
await axios | ||
.post( | ||
`${ | ||
process.env.REACT_APP_BASE_URL | ||
}/articles/${slug}/comments/`, | ||
{ comment }, | ||
axiosHeader, | ||
) | ||
.then((result) => { | ||
dispatch({ | ||
type: COMMENT_ON_ARTICLE, | ||
payload: result.data, | ||
}); | ||
dispatch(fetchArticleComments(slug)); | ||
}) | ||
.catch(() => { | ||
alert('Server Error'); // eslint-disable-line no-alert | ||
}); | ||
}; | ||
|
||
export const CommentOnComment = (slug, commentId, comment) => async (dispatch) => { | ||
await axios | ||
.post( | ||
`${ | ||
process.env.REACT_APP_BASE_URL | ||
}/articles/${slug}/comments/${commentId}/subcomment`, | ||
{ comment }, | ||
axiosHeader, | ||
) | ||
.then((result) => { | ||
dispatch({ | ||
type: COMMENT_ON_COMMENT, | ||
payload: result.data, | ||
}); | ||
dispatch(fetchArticleComments(slug)); | ||
}) | ||
.catch(() => { | ||
alert('Server Error'); // eslint-disable-line no-alert | ||
}); | ||
}; | ||
|
||
export const editComment = (slug, commentId, comment) => async (dispatch) => { | ||
await axios | ||
.put( | ||
`${ | ||
process.env.REACT_APP_BASE_URL | ||
}/articles/${slug}/comments/${commentId}`, | ||
{ comment }, | ||
axiosHeader, | ||
) | ||
.then((result) => { | ||
dispatch({ | ||
type: EDIT_COMMENT, | ||
payload: result.data, | ||
}); | ||
dispatch(fetchArticleComments(slug)); | ||
}) | ||
.catch(() => { | ||
alert('Server Error'); // eslint-disable-line no-alert | ||
}); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { LOCAL_STORAGE } from './action_types'; | ||
|
||
export const userDefault = { | ||
username: '', | ||
email: '', | ||
token: '', | ||
}; | ||
|
||
export const fetchLocalStorage = () => (dispatch) => { | ||
let userDetails = { user: userDefault }; | ||
if (localStorage.getItem('user')) { | ||
userDetails = JSON.parse(localStorage.getItem('user')); | ||
} | ||
|
||
dispatch({ | ||
type: LOCAL_STORAGE, payload: userDetails.user, | ||
}); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.side-bar { | ||
position: sticky; | ||
top: 4rem; | ||
z-index: 1000; | ||
height: calc(100vh - 4rem); | ||
background-color: #f7f7f7; } | ||
|
||
.draw-line-horizontal { | ||
border-bottom: 1px solid; } | ||
|
||
.draw-line-vertical { | ||
border-right: 1px solid; | ||
top: 50px; | ||
font-size: small; | ||
text-align: left; } | ||
|
||
.draw-line-vertical:hover { | ||
color: #17907C; } | ||
|
||
.container-height { | ||
padding-top: 150px; } | ||
|
||
.article-container { | ||
background: #FFFFFF; | ||
border: 1px solid #efefef; | ||
min-width: 80%; | ||
border-radius: 5px; | ||
padding: 50px; | ||
margin-bottom: 30px; | ||
text-align: justify; } | ||
|
||
.image-wrapper img { | ||
width: 100% !important; } | ||
|
||
.view-font { | ||
font-size: 16px !important; } | ||
|
||
.demo-editor { | ||
font-size: 16px !important; } |
Oops, something went wrong.