Merge basic MVP front-end #16

Merged
JMR-dev merged 5 commits from jr-add-tags-to-images into main 2022-03-23 23:55:34 +00:00
2 changed files with 15 additions and 3 deletions
Showing only changes of commit 98444f9c50 - Show all commits
+14 -2
View File
@@ -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(
<>
<h2>Select Tags for Images</h2>
@@ -24,7 +35,7 @@ export const SelectTags = () => {
return(
<>
<input type="checkbox" name="imagetags" value={tagname.id} id= "imagetags" onChange={
(e) => {tagname.forEach(setTagSelections(e.target.value)) }
(e) => {changefunction(e) }
} />
<label for="imagetags">{tagname.image_tag_name}</label>
</>
@@ -35,7 +46,8 @@ export const SelectTags = () => {
}
< button onClick = {
() => {
addTagsToImages(tag_selections, {id})
const submitOBJ = {image_tags:tag_selections}
addTagsToImages( submitOBJ, id)
}
}
+1 -1
View File
@@ -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:{