mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-29 22:20:41 +03:00
51 lines
1.6 KiB
Text
51 lines
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" />
|
||
|
|
||
|
<%- include("extra/navbar") %>
|
||
|
|
||
|
<h1 class="title">Edit <a href="/users/<%= member.id %>"><%= member.name %></a></h1>
|
||
|
|
||
|
<div class="content">
|
||
|
<form id="form">
|
||
|
<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>
|