akf-forum/views/create_category.ejs
2022-09-17 00:51:52 +03:00

41 lines
No EOL
1.1 KiB
Text

<!DOCTYPE html>
<html lang="en">
<%- include("extra/meta", {title: "Create Category!" }) %>
<body>
<link rel="stylesheet" href="/css/create_thread.css" />
<%- include("extra/navbar") %>
<form>
<h2 class="title" style="align-self: baseline;">Name:</h2>
<input name="name" class="input" required maxlength="25"></input>
<h2 class="title" style="align-self: baseline;">Description:</h2>
<textarea rows="4" cols="50" name="desp" maxlength="256" class="input" required></textarea>
<button class="btn-primary" style="width:100%" type="submit">Create Category!</button>
</form>
<script type="module">
import request from "../../js/request.js";
document.addEventListener("submit", async e => {
e.preventDefault();
const data = new FormData(e.target);
const response = await request("/api/categories/", "POST", {
name: data.get("name"),
desp: data.get("desp")
});
if (response)
window.location.href = "/categories/" + response.id;
});
</script>
<%- include("extra/footer") %>
</body>
</html>