mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-23 04:10:40 +03:00
53 lines
No EOL
1.7 KiB
Text
53 lines
No EOL
1.7 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);
|
|
console.log(object)
|
|
const res = await request("/api/users/<%=member.id%>", "PATCH", object);
|
|
if (res) alert(`User is updated!`);
|
|
location.reload();
|
|
});
|
|
</script>
|
|
|
|
|
|
</body>
|
|
|
|
</html> |