diff --git a/public/api/articles.json b/public/api/articles.json
index f5647c7..cb67fc9 100644
--- a/public/api/articles.json
+++ b/public/api/articles.json
@@ -1,6 +1,7 @@
{
"articles": [
{
+ "id": 0,
"title": "Test Article",
"desc":"This is a description",
"contents": "Hello World"
diff --git a/src/actions/index.js b/src/actions/index.js
index 66fda8e..afa02d8 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -1,6 +1,7 @@
import github from '../apis/github';
import api from '../apis/api';
+
export const getUser = (username) => async (dispatch, getState) => {
const response = await github.get(`/users/${username}`);
@@ -20,17 +21,16 @@ export const getRepos = (username) => async (dispatch, getState) => {
});
};
-export const getArticles = async (dispatch, getState) => {
- const state = getState();
-
- if (!state.articles || state.articles.length <= 0){
- const response = await api.get(`/articles`); // axios request for articles json file
-
+export const getArticles = () => async (dispatch, getState) => {
+ const { articles } = getState();
+
+ if (!articles.articles || articles.articles.length <= 0){
+ const response = await api.get(`/articles.json`); // axios request for articles json file
+
dispatch({
type: 'GET_ARTICLES',
- payload: response.data,
+ payload: response.data.articles,
});
- return response;
}
};
diff --git a/src/components/Article.js b/src/components/Article.js
index 3bd827a..13d9dc3 100644
--- a/src/components/Article.js
+++ b/src/components/Article.js
@@ -1,10 +1,12 @@
import React from 'react';
import './css/Articles.css';
-const Article = ({match}) => {
+const Article = ({article}) => {
return (
- "Article: " {match}
+
{article.title}
+
{article.desc}
+
{article.contents}
);
}
diff --git a/src/components/Articles.js b/src/components/Articles.js
index d220e56..a771c0e 100644
--- a/src/components/Articles.js
+++ b/src/components/Articles.js
@@ -3,7 +3,8 @@ import { connect } from 'react-redux';
import './css/Articles.css';
import Theater from './subcomponents/Theater';
import Article from './Article';
-import { getArticles} from '../actions/index';
+import Listing from './subcomponents/Listing';
+import { getArticles } from '../actions';
import { Route, Link } from 'react-router-dom';
@@ -15,24 +16,34 @@ class Articles extends React.Component {
componentDidMount() {
document.title = "Articles";
+ this.props.getArticles();
}
renderArticles() {
-
+
+
+ const render = this.props.articles.map((article) => {
+ console.log(article);
return (
-
- {this.props.getArticles()}
+
+
+ {article.desc}
+
);
+ });
+
+ return (
+
+ {render}
+
+ );
}
article(match) {
- return (
-
- {match.params.id}
-
- );
+ console.log(this.props.articles)
+ return
;
}
render() {
diff --git a/src/components/css/Listing.css b/src/components/css/Listing.css
new file mode 100644
index 0000000..c3059e8
--- /dev/null
+++ b/src/components/css/Listing.css
@@ -0,0 +1,45 @@
+.listings {
+ display:flex;
+ flex-direction: column;
+ width: 75vw;
+ margin-left: auto;
+ margin-right: auto;
+ padding-bottom: 5.5rem;
+
+}
+
+.listing {
+ border-top-style: solid;
+ border-top-color: #A4A4A1;
+ border-top-width:2px;
+ font-size: x-large;
+ display: flex;
+ flex-direction: column;
+ align-items: left;
+ margin-top: 10px;
+ color: #AA9AA0;
+}
+
+.listing .title {
+ color: #BF8D8C !important;
+ font-size: 28px;
+ margin-top: 10px;
+ font-weight:bold;
+ width:fit-content;
+ width:-moz-fit-content;
+ text-align:start;
+ padding:5px;
+ border-radius: 3px;
+}
+
+.listing .content {
+ display:flex;
+ flex-direction: row;
+ align-items:center;
+ font-size: x-large;
+}
+
+.listing .description {
+ flex-grow: 1;
+ padding:10px;
+}
\ No newline at end of file
diff --git a/src/components/subcomponents/Listing.js b/src/components/subcomponents/Listing.js
new file mode 100644
index 0000000..a9e7379
--- /dev/null
+++ b/src/components/subcomponents/Listing.js
@@ -0,0 +1,24 @@
+import React from 'react';
+import '../css/Listing.css';
+
+const Listing = (props) => {
+ /**
+ * Listing - A subcomponent for making lists of content, mostly to make a list of links.
+ *
+ *
+ * title - The title of the listing
+ * children - JSX that is necessary in the content of the component
+ */
+ return (
+
+ );
+};
+
+export default Listing;
\ No newline at end of file