mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-22 20:10:40 +03:00
Added avatar edit support
This commit is contained in:
parent
22028eeb3d
commit
0a09da789c
1 changed files with 11 additions and 4 deletions
|
@ -41,8 +41,10 @@
|
||||||
<p class="box-value">
|
<p class="box-value">
|
||||||
<%= member.about %>
|
<%= member.about %>
|
||||||
</p>
|
</p>
|
||||||
|
<% if (user && (user.id === member.id ||user.admin)) {%>
|
||||||
|
|
||||||
<a class="btn-outline-primary" id="edit">Change name of the user!</a>
|
<a class="btn-outline-primary" id="edit_n">Change name of the user!</a>
|
||||||
|
<a class="btn-outline-primary" id="edit_a">Change avatar of the user!</a>
|
||||||
|
|
||||||
<% if (user?.admin && !member.deleted) {%>
|
<% if (user?.admin && !member.deleted) {%>
|
||||||
<a class="btn-outline-primary" id="admin">Give admin permissions!</a>
|
<a class="btn-outline-primary" id="admin">Give admin permissions!</a>
|
||||||
|
@ -67,7 +69,7 @@
|
||||||
alert("User is deleted!");
|
alert("User is deleted!");
|
||||||
location.reload()
|
location.reload()
|
||||||
|
|
||||||
}else if (e.target.id == "edit") {
|
}else if (e.target.id == "edit_n") {
|
||||||
|
|
||||||
const name = prompt("Enter new username!");
|
const name = prompt("Enter new username!");
|
||||||
const res =await request(`/api/users/<%= member.id %>/edit`, "POST", { name });
|
const res =await request(`/api/users/<%= member.id %>/edit`, "POST", { name });
|
||||||
|
@ -76,10 +78,15 @@
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|
||||||
|
|
||||||
|
}else if (e.target.id == "edit_a") {
|
||||||
|
|
||||||
|
const avatar = prompt("Enter new avatar URL!");
|
||||||
|
const res =await request(`/api/users/<%= member.id %>/edit`, "POST", { avatar });
|
||||||
|
if (res.error) return;
|
||||||
|
alert(`User updated!`);
|
||||||
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue