akf-forum/views/create_category.ejs

38 lines
1 KiB
Text
Raw Normal View History

2022-09-09 20:47:28 +03:00
<!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>
2022-09-17 00:27:38 +03:00
<input name="name" class="input" required maxlength="25" ></input>
2022-09-09 20:47:28 +03:00
<h2 class="title" style="align-self: baseline;">Description:</h2>
2022-09-17 00:27:38 +03:00
<textarea rows="4" cols="50" name="desp" maxlength="256" class="input" required></textarea>
2022-09-09 20:47:28 +03:00
<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);
2022-09-17 00:27:38 +03:00
2022-09-09 20:47:28 +03:00
const response = await request("/api/categories/", "POST", {
name: data.get("name"),
desp: data.get("desp")
});
if (response)
window.location.href = "/categories/" + response.id;
});
</script>
</body>