diff --git a/src/api/editSubmission.js b/src/api/editSubmission.js new file mode 100644 index 0000000..6e87dc8 --- /dev/null +++ b/src/api/editSubmission.js @@ -0,0 +1,25 @@ +import KeyCloakService from '../services/KeyCloakService'; +import { API } from '../utils/globals'; + +const editSubmission = ( + submisssion, + tags, + description +) => { + // tags = tags.map((tag) => tag.name).join(','); + tags = tags.replaceAll(',', '%2C'); + fetch(`${API}/edit-submission/${submisssion}/${tags}/${description}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', + Authorization: `Bearer ${KeyCloakService.getToken()}`, + } + }) + .then((resp) => resp.text()) + .then((data) => { + console.log(data); + }); +}; + +export default editSubmission; +// http://localhost:3000/api/edit-submission/4/1%2C2/abc \ No newline at end of file diff --git a/src/components/generic/Table/Table.js b/src/components/generic/Table/Table.js index 31b7c01..2413bc0 100644 --- a/src/components/generic/Table/Table.js +++ b/src/components/generic/Table/Table.js @@ -9,6 +9,7 @@ import theme from '../../../utils/theme'; import DeletePopUp from './components/DeletePopUp/DeletePopUp'; import MobileTable from './components/MobileTable/MobileTable'; import Media from 'react-media'; +import editSubmission from '../../../api/editSubmission'; const Table = ({ items, @@ -48,7 +49,7 @@ const Table = ({ item={item} setDeletePopUp={setDeletePopUp} deletePopUp={deletePopUp} - deleteItem={deleteItem} + deleteItem={() => editSubmission(7355, '1,2,3', 'ssiema siema')} /> { const n = (pageNr - 1) * (ELEMENTS_PER_PAGE * 2); let elements = entries.slice(n, n + ELEMENTS_PER_PAGE * 2); + console.log(elements); return (