feat: added basic edit form

This commit is contained in:
Elias Renman
2025-03-24 16:15:13 +01:00
parent cc9b3554e6
commit 085be0d51f
2 changed files with 16 additions and 2 deletions

View File

@@ -33,7 +33,7 @@
};
</script>
<form method="POST" on:submit={handleSubmit}>
<form method="POST" on:submit={handleSubmit} id="form">
<div class="flex mt-4 p-4 bg-gray-800 rounded-lg shadow-lg gap-4 flex-col">
<div class="flex flex-row gap-2 justify-center items-center">
<p>{window.location.origin}/</p>

View File

@@ -10,6 +10,17 @@
$mutation.mutate(row.url);
}
}
function editItem() {
const form = document.getElementById("form") as HTMLFormElement;
form.reset();
for (const [key, value] of Object.entries(row)) {
const item = form.elements.namedItem(key) as HTMLInputElement;
if (!item) continue;
if (key === "ttl") continue;
item.value = value as string;
}
}
</script>
<tr class="border-t border-gray-700 hover:bg-gray-700 transition">
@@ -25,7 +36,10 @@
>{row.ttl ? new Date(row.ttl).toLocaleTimeString() : "Never"}</td
>
<td class="p-3 flex gap-3">
<button class="text-blue-600 hover:text-blue-500 cursor-pointer transition">
<button
onclick={editItem}
class="text-blue-600 hover:text-blue-500 cursor-pointer transition"
>
<Edit size={18} />
</button>
<button