Skip to content
Snippets Groups Projects
Commit ac8f5f86 authored by CarimPopa's avatar CarimPopa
Browse files

Delete pokemon trainer button has been added

parent dfc55d55
No related branches found
No related tags found
No related merge requests found
......@@ -45,8 +45,6 @@ public class TrainerRoute {
public Trainer updateTrainer(@PathParam("id") String id, Trainer toUpdate) {
if (id == null || !id.equals(toUpdate.id))
throw new BadRequestException("Id mismatch.");
System.out.println("Incoming ID: " + id);
System.out.println("Updating Trainer: " + toUpdate);
return TrainerDao.INSTANCE.update(toUpdate);
}
......
......@@ -84,6 +84,7 @@ function pokemonTrainerToRow(pokemonTrainer) {
<th scope="row">${pokemonTrainer.id}</th>
<td>${pokemonTrainer.name}</td>
<td>${pokemonTrainer.lastUpDate}</td>
<td><button id="deleteButton" type="button" onclick="deleteRow('${pokemonTrainer?.id?.trim()}')">Delete</button></td>
</tr>
`
......@@ -109,4 +110,17 @@ function createTrainerTable() {
</table>
`
toggleUpdateButton();
}
function deleteRow(rowID) {
let row = document.getElementById(`${rowID}_row`);
row.parentNode.removeChild(row)
fetch(`/pokemon/api/trainers/${rowID}`, {
method: "DELETE"
})
.then(res => res.json())
.then(res => console.log(res))
toggleUpdateButton();
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment