diff --git a/src/tags/SelectTags.js b/src/tags/SelectTags.js
index b062d12..c6673a0 100644
--- a/src/tags/SelectTags.js
+++ b/src/tags/SelectTags.js
@@ -14,6 +14,17 @@ export const SelectTags = () => {
},[]
)
+ const changefunction = (e) => {
+ const checkboxID = e.target.value
+ let tagselectioncopy = [...tag_selections]
+ if (tagselectioncopy.find((id) => id === checkboxID)) {
+ tagselectioncopy = tagselectioncopy.filter((id) => id !== checkboxID)
+ setTagSelections(tagselectioncopy)
+ } else {tagselectioncopy.push(checkboxID)
+ setTagSelections(tagselectioncopy)
+ }
+ }
+
return(
<>
Select Tags for Images
@@ -24,7 +35,7 @@ export const SelectTags = () => {
return(
<>
{tagname.forEach(setTagSelections(e.target.value)) }
+ (e) => {changefunction(e) }
} />
>
@@ -35,7 +46,8 @@ export const SelectTags = () => {
}
< button onClick = {
() => {
- addTagsToImages(tag_selections, {id})
+ const submitOBJ = {image_tags:tag_selections}
+ addTagsToImages( submitOBJ, id)
}
}
diff --git a/src/tags/TagManager.js b/src/tags/TagManager.js
index 193f76a..b743760 100644
--- a/src/tags/TagManager.js
+++ b/src/tags/TagManager.js
@@ -23,7 +23,7 @@ export const createTags = (tag) => {
.then(response => response.json())
}
- export const addTagsToImages = (id, tag_selections) => {
+ export const addTagsToImages = (tag_selections,id) => {
return fetch(`http://localhost:8000/images/${id}`, {
method: "PUT",
headers:{