blob: d45f09e62b131a79b997b027c3e583464e3d00d5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<script>
import { preventDefault } from 'svelte/legacy';
import Icon from "$comp/Icon.svelte";
import { fail, post } from "$lib/utils";
import { invalidate } from "$app/navigation";
let { item = $bindable() } = $props();
let cancel = () => (item = null);
let submit = async () => {
try {
await post("/api/items/delete", { item });
invalidate("app:items");
item = null;
} catch (e) {
fail("Failed to delete item");
}
};
</script>
<div
class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-20"
>
<div
class="relative top-1/3 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white space-y-5"
>
<h1 class="text-center text-2xl font-semibold">Delete item</h1>
<form onsubmit={preventDefault(submit)}>
<div class="w-full flex">
<button
type="button"
class="border-2 border-black rounded-xl font-semibold mx-auto py-3 w-40 hover:opacity-80 mx-auto"
onclick={cancel}
onkeydown={cancel}
>
<div class="my-auto">No</div>
</button>
<button
type="submit"
class="border-2 border-black rounded-xl font-semibold mx-auto py-3 w-40 hover:opacity-80 mx-auto bg-black text-white"
>
<div class="my-auto">Yes</div>
</button>
</div>
</form>
</div>
</div>
|