+ {imageData.map((image) =>{
+ return (
+ //
{tagdata.map((tag)=> tag.image_tag_name )}
+ <>
+
+

+
+ >
+ )
+ }
+ )}
+
+ >
+ )
}
\ No newline at end of file
diff --git a/src/tags/SelectTags.js b/src/tags/SelectTags.js
index e3aeb8f..b062d12 100644
--- a/src/tags/SelectTags.js
+++ b/src/tags/SelectTags.js
@@ -1,10 +1,12 @@
import react, {useState, useEffect, useRef} from "react"
import { useHistory, useParams } from "react-router-dom"
-import { getTags } from "./TagManager"
+import { getTags, addTagsToImages } from "./TagManager"
export const SelectTags = () => {
const [tags, setTags] = useState([])
- const [tagselections, setTagSelections] = useState([])
+ const [tag_selections, setTagSelections] = useState( new Array(tags.length).fill(0))
+ let { id } = useParams();
+ const tagscopy = [...tags]
useEffect(
() => {
@@ -18,11 +20,11 @@ export const SelectTags = () => {
- {tags.map((tagname) => {
+ {tagscopy.map((tagname) => {
return(
<>
- { }
+ {tagname.forEach(setTagSelections(e.target.value)) }
} />
>
@@ -31,7 +33,14 @@ export const SelectTags = () => {
)
}
- {/* */}
+ < button onClick = {
+ () => {
+ addTagsToImages(tag_selections, {id})
+ }
+ }
+
+
+ >Submit
>
diff --git a/src/tags/TagManager.js b/src/tags/TagManager.js
index de29bdb..193f76a 100644
--- a/src/tags/TagManager.js
+++ b/src/tags/TagManager.js
@@ -21,4 +21,16 @@ export const createTags = (tag) => {
)
.then(response => response.json())
+ }
+
+ export const addTagsToImages = (id, tag_selections) => {
+ return fetch(`http://localhost:8000/images/${id}`, {
+ method: "PUT",
+ headers:{
+ "Authorization": `Token ${localStorage.getItem("sf_token")}`,
+ "Content-Type": "Application/json"
+ },
+ body:JSON.stringify(tag_selections)
+ }
+ )
}
\ No newline at end of file