mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-23 04:10:40 +03:00
72 lines
2.5 KiB
Text
72 lines
2.5 KiB
Text
|
<% if(user?.admin || user?.id === member.id){ %>
|
||
|
<details>
|
||
|
<summary class="btn-outline-primary">User Menu:</summary>
|
||
|
|
||
|
<% if (!member.discordID && discord && user?.id === member.id) { %>
|
||
|
<a href="<%=discord%>" class="btn-outline-primary">DC auth</a>
|
||
|
<% } else if(member.discordID && user?.id === member.id) { %>
|
||
|
<a class="btn-outline-primary" id="un_discord">Unauth DC!</a>
|
||
|
<% } %>
|
||
|
<a href="/users/<%=member.id%>/avatar" class="btn-outline-primary">Upload avatar</a>
|
||
|
<a class="btn-outline-primary" id="toogle">Edit user!</a>
|
||
|
<script type="module">
|
||
|
import request from "/js/request.js";
|
||
|
|
||
|
const form = document.getElementById("form");
|
||
|
|
||
|
document.addEventListener("click", async e => {
|
||
|
if (e.target.id == "delete") {
|
||
|
const response = await request("/api/users/<%= member.id %>", "DELETE");
|
||
|
if (response.state !== "DELETED") return
|
||
|
alert("User is deleted!");
|
||
|
location.reload()
|
||
|
} else if (e.target.id == "undelete") {
|
||
|
const response = await request("/api/users/<%= member.id %>/", "PATCH", {
|
||
|
deleted: false
|
||
|
});
|
||
|
if (response.state == "DELETED") return;
|
||
|
alert("User is undeleted successfully!");
|
||
|
location.reload()
|
||
|
} else if (e.target.id == "un_discord") {
|
||
|
const response = await fetch("/auth/discord/", {
|
||
|
method: "DELETE"
|
||
|
});
|
||
|
alert(await response.text());
|
||
|
location.reload()
|
||
|
} else if (e.target.id.startsWith("last_")) {
|
||
|
let hideLastSeen = e.target.id.replace("last_", "") == "hide" ? true : false;
|
||
|
const response = await request("/api/users/<%= member.id %>/", "PATCH", {
|
||
|
hideLastSeen
|
||
|
});
|
||
|
alert(`Last seen is ${!hideLastSeen?"un":""}hided!`);
|
||
|
location.reload()
|
||
|
|
||
|
} else if (e.target.id == "toogle")
|
||
|
document.getElementById('user-edit').classList.toggle('no-active')
|
||
|
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
<% if (member.hideLastSeen) {%>
|
||
|
<a id="last_unhide" class="btn-primary">Unhide last seen! </a>
|
||
|
<% } else { %>
|
||
|
<a id="last_hide" class="btn-outline-primary">Hide last seen! </a>
|
||
|
<% } %>
|
||
|
|
||
|
<% if (member.deleted) {%>
|
||
|
<h1>This user has been deleted!</h1>
|
||
|
<a id="undelete" class="btn-primary">Undelete user! </a>
|
||
|
<% } else if (user?.admin){ %>
|
||
|
<a id="delete" class="btn-outline-primary">Delete user! </a>
|
||
|
<% } %>
|
||
|
<% if (user?.admin) {%>
|
||
|
<h2>IP adresses of the user:</h2>
|
||
|
<select>
|
||
|
<% for(const ip of member.ips) { %>
|
||
|
<option><%= ip %></option>
|
||
|
<% } %>
|
||
|
</select>
|
||
|
|
||
|
<% } %>
|
||
|
</details>
|
||
|
<% } %>
|