2022-09-01 14:02:47 +03:00
|
|
|
<!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" />
|
2022-09-01 15:19:12 +03:00
|
|
|
<style>
|
|
|
|
.see {
|
|
|
|
color: var(--reaction-hover)
|
|
|
|
}
|
|
|
|
</style>
|
2022-09-01 14:02:47 +03:00
|
|
|
<%- include("extra/navbar") %>
|
|
|
|
|
2022-09-01 15:19:12 +03:00
|
|
|
<h1 class="title">Edit <a class="see" href="/users/<%= member.id %>"><%= member.name %></a></h1>
|
2022-09-01 14:02:47 +03:00
|
|
|
|
|
|
|
<div class="content">
|
2022-09-01 15:19:12 +03:00
|
|
|
<form id="form" class="see">
|
2022-09-01 14:02:47 +03:00
|
|
|
<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>
|