Articles
@@ -21,18 +26,18 @@ function Articles(props) {
>
{article.title}{' '}
- {props.tags && props.tags.filter(t => t.articleId === article.id).map(tag => (
-
- ))
- }
+ {props.tags && props.tags.filter(t => t.articleId === article.id).map(tag => (
+
+ ))
+ }
))}
diff --git a/src/components/index.js b/src/components/index.js
index d85688d..6602ecc 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -3,6 +3,7 @@ export { default as About } from './about'
export { default as Articles } from './articles'
export { default as Article } from './article'
export { default as UpdateArticle } from './update-article'
+export { default as Tags } from './tags'
export { default as Tasks } from './tasks'
export { default as UpdateTask } from './update-task'
export { default as Profile } from './profile'
diff --git a/src/components/tags.js b/src/components/tags.js
new file mode 100644
index 0000000..f6b9ada
--- /dev/null
+++ b/src/components/tags.js
@@ -0,0 +1,35 @@
+import React from 'react'
+
+class Tags extends React.Component {
+ constructor(props) {
+ super(props)
+ //props.state.tags = tags
+ }
+
+ render() {
+ return (
+
+
+ {this.props.tags && this.props.tags.filter(t => t.articleId === this.props.selectedArticleId).map(tag => (
+
+
+
+
+ ))}
+
+
+ )}
+}
+export default Tags
diff --git a/src/controllers/tags.js b/src/controllers/tags.js
index a1933a9..3a414ae 100644
--- a/src/controllers/tags.js
+++ b/src/controllers/tags.js
@@ -4,9 +4,9 @@ const API = process.env.REACT_APP_API || 'http://localhost:1337'
export async function addTag(e) {
e.preventDefault()
if (this.state.newTag === '') {
- return alert('No, i will not add an empty tag.')
+ return alert("Refusing to add an empty tag.")
}
- const tag = { name: this.state.newTag }
+ const tag = { name: this.state.newTag, articleId: this.state.selectedArticleId }
try {
const { data, error } = await axios.post(API + '/api/tags', tag)
if (error) {
@@ -27,7 +27,7 @@ export async function addTag(e) {
export function selectTag(selectedTagId) {
this.setState({ selectedTagId })
- this.navigate('tag')
+ this.navigate('articles')
}
export async function removeTag(id) {