akf-forum/views/user.ejs
Akif9748 258578e790 Undelete user
Co-authored-by: Zeynep <zeynepkotan50@gmail.com>
2022-08-26 21:04:30 +03:00

103 lines
No EOL
2.3 KiB
Text

<!DOCTYPE html>
<html lang="en">
<%- include("extra/meta", {title: member.name }) %>
<body style="text-align: center;">
<%- include("extra/navbar") %>
<ul>
<li>
<h1 style="color: #4d18e6;">Avatar:</h1>
<img style="width:256px;height:256px;" src=<%=member.avatar %> alt=<%= member.name %>>
</li>
<li>
<h2 style="color: #606060;">Name: <%= member.name %>
</h2>
</li>
<li>
<h2 style="color: #606060;">Created at:
<%= new Date(member.time).toLocaleString() %>
</h2>
</li>
<li>
<h2 style="color: #606060;">Is admin? <%= member.admin ? "Yes" : "No" %>
</h2>
</li>
<li>
<h2 style="color: #606060;"> Message: <%= counts.message %>
</h2>
</li>
<li>
<h2 style="color: #606060;"> Thread: <%= counts.thread %>
</h2>
</li>
</ul>
<% if (user?.admin && !member.deleted) {%>
<form id="admin">
<button class="big" type="submit">Give admin permissions!</button>
</form>
<form id="delete">
<button class="big" type="submit">Delete user!</button>
</form>
<script type="module">
import request from "../../js/request.js";
document.addEventListener("submit", async e => {
e.preventDefault();
if (e.target.id == "admin") {
const response = await request("/api/users/<%= member.id %>/admin");
if (response.admin)
return alert("Making admin of " + response.name + " is success!");
}
const response = await request("/api/users/<%= member.id %>/delete");
if (!response.deleted) return
alert("User is deleted!");
location.reload()
});
</script>
<% }; %>
<% if (member.deleted) {%>
<h1>This user has been deleted!</h1>
<form id="undelete">
<button class="big" type="submit">Undelete user!</button>
</form>
<script type="module">
import request from "../../js/request.js";
document.addEventListener("submit", async e => {
const response = await request("/api/users/<%= member.id %>/undelete");
if (response.deleted) return;
alert("User is undeleted successfully!");
location.reload()
});
</script>
<% }; %>
</body>
</html>