Added delete-quiz

This commit is contained in:
Mawoka
2022-03-09 18:26:33 +01:00
parent 4f4b38d8b0
commit a69922b8ab
2 changed files with 37 additions and 0 deletions
+25
View File
@@ -42,6 +42,13 @@
const data = await res.json();
window.location.replace(`/admin?token=${data.game_id}&pin=${data.game_pin}&connect=1`);
};
const deleteQuiz = async (to_delete: string) => {
const res = await fetch(`/api/v1/quiz/delete/${to_delete}`, {
method: 'DELETE'
});
window.location.reload()
}
</script>
{#await getData()}
@@ -109,6 +116,12 @@
>
Edit
</th>
<th
scope="col"
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
>
Delete
</th>
<th
scope="col"
class="py-3 px-6 text-xs font-medium tracking-wider text-left text-gray-700 uppercase dark:text-gray-400"
@@ -153,6 +166,18 @@
>
<a href="/edit?quiz_id={quiz.id}">Edit</a>
</td>
<td
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
>
<button
on:click={() => {
deleteQuiz(quiz.id);
}}
class="border border-green-600"
>
Delete
</button>
</td>
<td
class="py-4 px-6 text-sm text-gray-500 whitespace-nowrap dark:text-gray-400"
>