-
Notifications
You must be signed in to change notification settings - Fork 0
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
30 changed files
with
473 additions
and
13,631 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 |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import { | ||
SOCIAL_LOGIN_INITIATED, | ||
SOCIAL_LOGIN_SUCCESS, | ||
GET_ALL_ARTICLES_SUCCESS, | ||
} from './types'; | ||
|
||
export const socialLoginInitiated = () => ({ | ||
type: SOCIAL_LOGIN_INITIATED, | ||
}); | ||
|
||
|
||
export const socialLoginSuccess = () => ({ | ||
type: SOCIAL_LOGIN_SUCCESS, | ||
}); | ||
|
||
export const getAllArticles = (payload) => ({ | ||
type: GET_ALL_ARTICLES_SUCCESS, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import axiosInstance from '../config/axiosInstance'; | ||
import { getAllArticles } from './actionCreators'; | ||
|
||
export const fetchArticles = () => dispatch => { | ||
axiosInstance | ||
.get('/api/article/') | ||
.then((response) => { | ||
dispatch(getAllArticles(response.data.article)); | ||
}); | ||
}; | ||
|
||
export default fetchArticles; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,43 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { bindActionCreators } from 'redux'; | ||
import PropTypes from 'prop-types'; | ||
import fetchArticles from '../../actions/articleActions'; | ||
import ArticlesList from './ArticlesList'; | ||
|
||
export class Articles extends Component { | ||
componentDidMount() { | ||
const { fetchArticles } = this.props; | ||
fetchArticles(); | ||
} | ||
|
||
render() { | ||
const { articlesPayload } = this.props; | ||
const articles = articlesPayload; | ||
return ( | ||
<div> | ||
{Object.keys(articles).length > 0 | ||
&& <ArticlesList articles={articles.results} /> | ||
} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToProps = (state) => ({ | ||
articlesPayload: state.article.articlesPayload, | ||
}); | ||
|
||
const matchDispatchToProps = (dispatch) => bindActionCreators({ | ||
fetchArticles, | ||
}, dispatch); | ||
|
||
Articles.propTypes = { | ||
fetchArticles: PropTypes.func.isRequired, | ||
articlesPayload: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default connect( | ||
mapStateToProps, | ||
matchDispatchToProps, | ||
)(Articles); |
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,17 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import SingleArticle from './SingleArticle'; | ||
|
||
const ArticlesList = ({ articles }) => ( | ||
<div> | ||
{articles.map(article => ( | ||
<SingleArticle key={article.id} article={article} /> | ||
))} | ||
</div> | ||
); | ||
|
||
ArticlesList.propTypes = { | ||
articles: PropTypes.array.isRequired, | ||
}; | ||
|
||
export default ArticlesList; |
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,64 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import articleImg from '../../assets/images/articleImg.jpeg'; | ||
import user from '../../assets/images/user.png'; | ||
|
||
function articleCreated(articleDate) { | ||
const dateTime = new Date(articleDate); | ||
const dateOnly = dateTime.toDateString(); | ||
return dateOnly; | ||
} | ||
|
||
const SingleArticle = ({ article }) => ( | ||
<div className="row article"> | ||
<div className="col-12"> | ||
<div className="row entire-article"> | ||
<div className="col-sm-1"> | ||
<img src={user} className="img-thumbnail author-thumbnail" alt="" /> | ||
</div> | ||
<div className="col-sm-11 article-essentials"> | ||
<div className="row"> | ||
<div className="col-sm-5 author-name"> | ||
authorname | ||
</div> | ||
</div> | ||
<div className="row"> | ||
<div className="col-md-3 article-time"> | ||
{articleCreated(article.createdAt)} | ||
| 3 Min | ||
</div> | ||
<div className="col-sm-8"> | ||
<i className="fas fa-tags" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="card"> | ||
<div className="row no-gutters"> | ||
<div className="col-auto"> | ||
<img src={articleImg} alt="an article" className="article-img" /> | ||
</div> | ||
<div className="col-9"> | ||
<div className="card-block px-2"> | ||
<h5 className="card-title">{article.title}</h5> | ||
<p className="card-text article-description">{article.description}</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="card-footer w-100 text-muted"> | ||
<i className="far fa-thumbs-down icon" /> | ||
<i className="far fa-thumbs-up icon" /> | ||
<i className="far fa-star icon" /> | ||
<i className="far fa-bookmark icon" /> | ||
<i className="fas fa-share-alt icon" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
SingleArticle.propTypes = { | ||
article: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default SingleArticle; |
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,31 @@ | ||
import React from 'react'; | ||
import Articles from '../Articles/Articles'; | ||
|
||
const Dashboard = () => ( | ||
<div> | ||
<div className="dashboard-section"> | ||
<div className="inner-dash"> | ||
<div className="container"> | ||
<div className="row"> | ||
<div className="col-12 dash-intro lp-text text-center"> | ||
<p> | ||
<span className="reading">Reading</span> | ||
| | ||
<span className="writing">Writing.</span> | ||
<span className="intro-text">You are home</span> | ||
</p> | ||
<button className="btn btn-success dash-btn" type="button"> | ||
{ "Let's Write" } | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="container-fluid article-list dash"> | ||
<Articles /> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default Dashboard; |
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.