2023-05-09 13:28:45 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
<%- include("extra/meta", {title: member.name }) %>
|
|
|
|
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<%- include("extra/navbar") %>
|
2023-05-24 15:40:09 +03:00
|
|
|
<link rel="stylesheet" href="/libs/simplemde/simplemde.min.css">
|
|
|
|
<script src="/libs/simplemde/simplemde.min.js"></script>
|
|
|
|
|
2023-05-09 13:28:45 +03:00
|
|
|
<h1 class="title" style="text-align:center;">
|
|
|
|
Edit <a href="/users/<%= member.id %>"><%= member.name %></a>
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
<form id="form" style="box-shadow:none">
|
|
|
|
<input type="text" name="name" placeholder="<%=member.name%>" class="input">
|
|
|
|
|
2023-05-24 15:40:09 +03:00
|
|
|
<textarea id="textarea" class="input" name="about" rows="4" cols="60" name="content" placeholder="<%=member.about%>"></textarea>
|
2023-05-09 13:28:45 +03:00
|
|
|
<% 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>
|
2023-05-24 15:40:09 +03:00
|
|
|
<script src="/js/editor.js"></script>
|
2023-05-09 13:28:45 +03:00
|
|
|
|
|
|
|
<script type="module">
|
|
|
|
import request from "/js/request.js";
|
2023-05-24 15:40:09 +03:00
|
|
|
const simplemde = editor("user-edit-<%=member.id%>");
|
2023-05-09 13:28:45 +03:00
|
|
|
|
|
|
|
document.getElementById("form").addEventListener("submit", async e => {
|
|
|
|
e.preventDefault();
|
|
|
|
document.getElementById('adminHidden').disabled = document.getElementById("admin").checked;
|
|
|
|
|
2023-05-24 15:40:09 +03:00
|
|
|
const formdata=new FormData(e.target)
|
|
|
|
|
|
|
|
const res = await request("/api/users/<%=member.id%>", "PATCH", {
|
|
|
|
name: formdata.get("name"),
|
|
|
|
about: simplemde.value(),
|
|
|
|
admin: formdata.get("admin")
|
|
|
|
});
|
|
|
|
simplemde.clearAutosavedValue();
|
2023-05-09 13:28:45 +03:00
|
|
|
|
|
|
|
if (res) alert(`User is updated!`);
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
</script>
|
2023-05-24 15:40:09 +03:00
|
|
|
<%- include("extra/footer") %>
|
2023-05-09 13:28:45 +03:00
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|