mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-01 03:25:04 +03:00
53 lines
No EOL
1.6 KiB
Text
53 lines
No EOL
1.6 KiB
Text
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<%- include("extra/meta", {title: "Edit "+member.name+"!" }) %>
|
|
|
|
|
|
<body style="text-align: center;">
|
|
<link rel="stylesheet" href="/css/login.css" />
|
|
<link rel="stylesheet" href="/css/user.css" />
|
|
<style>
|
|
.see {
|
|
color: var(--reaction-hover)
|
|
}
|
|
</style>
|
|
<%- include("extra/navbar") %>
|
|
|
|
<h1 class="title">Edit <a class="see" href="/users/<%= member.id %>"><%= member.name %></a></h1>
|
|
|
|
<div class="content">
|
|
<form id="form" class="see">
|
|
<input type="text" name="name" placeholder="<%=member.name%>" class="input">
|
|
<input type="url" name="avatar" placeholder="<%=member.avatar%>" class="input">
|
|
<textarea class="input" name="about" rows="4" name="content" placeholder="<%=member.about%>"></textarea>
|
|
<% if (user.admin){ %>
|
|
Is Admin? <input id='admin' type='checkbox' value='true' name='admin' <%=member.admin ? "checked": ""%>>
|
|
<input id='adminHidden' type='hidden' value='false' name='admin'>
|
|
<% } %>
|
|
|
|
<button class="btn-primary" style="width:100%;">Update User!</button>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<script type="module">
|
|
const form = document.getElementById("form");
|
|
import request from "../../js/request.js";
|
|
form.addEventListener("submit", async e => {
|
|
e.preventDefault();
|
|
document.getElementById('adminHidden').disabled = document.getElementById("admin").checked;
|
|
|
|
const object = {};
|
|
new FormData(e.target).forEach((value, key) => object[key] = value);
|
|
|
|
const res = await request("/api/users/<%=member.id%>", "PATCH", object);
|
|
if (res) alert(`User is updated!`);
|
|
location.reload();
|
|
});
|
|
</script>
|
|
|
|
|
|
</body>
|
|
|
|
</html> |