From 98444f9c50148c30de4e5ef129b2774cf55c6f74 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Wed, 23 Mar 2022 12:23:18 -0500 Subject: [PATCH] transferring work to personal computer --- src/tags/SelectTags.js | 16 ++++++++++++++-- src/tags/TagManager.js | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) 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:{