@@ -36,9 +36,9 @@ class PostForm extends Component {
const validate = values => {
const errors = required(values,
- 'attributes.title',
- 'relationships.category.data.id',
- 'attributes.body'
+ 'title',
+ 'category.id',
+ 'body'
);
return errors;
};
diff --git a/client/src/components/Posts/PostList.js b/client/src/components/Posts/PostList.js
index 1c49560..722886a 100644
--- a/client/src/components/Posts/PostList.js
+++ b/client/src/components/Posts/PostList.js
@@ -13,8 +13,8 @@ export class PostList extends Component {
}
getCategoryForPost(post) {
- const categoryId = get(post, 'relationships.category.data.id');
- return this.props.categoriesById[categoryId] || { attributes: {} };
+ const categoryId = String(get(post, 'category.id'));
+ return this.props.categoriesById[categoryId] || {};
}
fetchPage = (url) => (e) => {
@@ -24,10 +24,10 @@ export class PostList extends Component {
onFilter = (filter) => {
this.props.fetchPosts(filter);
- }
+ };
render() {
- const { posts, categoriesById, categories } = this.props;
+ const { posts, categories } = this.props;
const { prev, next } = posts.links;
return (
@@ -38,8 +38,8 @@ export class PostList extends Component {
{posts.data.map(post =>
- {post.attributes.title}
- ({this.getCategoryForPost(post).attributes.name})
+ {post.title}
+ ({this.getCategoryForPost(post).name})
)}
diff --git a/client/src/components/Posts/PostListFilter.js b/client/src/components/Posts/PostListFilter.js
index 7ce2b66..86188c5 100644
--- a/client/src/components/Posts/PostListFilter.js
+++ b/client/src/components/Posts/PostListFilter.js
@@ -9,9 +9,13 @@ class PostListFilter extends Component {
const categoriesOptions = categories.map(category => ({
id: category.id,
- name: category.attributes.name,
+ name: category.name,
}));
- categoriesOptions.unshift({ id: "", name: 'All categories'})
+
+ categoriesOptions.unshift({
+ id: '',
+ name: 'All categories'
+ });
return (