Skip to content

Commit

Permalink
added currency display for users admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
singharaj-usai committed Oct 13, 2024
1 parent 7ea6e7b commit fbe9d8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 38 deletions.
48 changes: 11 additions & 37 deletions client/js/admin/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,53 +31,27 @@ function displayUsers(users) {
<div class="col-md-6 col-lg-4 mb-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">${escapeHtml(
user.username
)}</h3>
<h3 class="panel-title">${escapeHtml(user.username)}</h3>
</div>
<div class="panel-body">
<div class="user-info">
<p><i class="fa fa-envelope"></i> ${escapeHtml(
user.email
)}</p>
<p><i class="fa fa-calendar"></i> ${new Date(
user.signupDate
).toLocaleString()}</p>
<p><i class="fa fa-envelope"></i> ${escapeHtml(user.email)}</p>
<p><i class="fa fa-calendar"></i> ${new Date(user.signupDate).toLocaleString()}</p>
<p><i class="fa fa-money"></i> Currency: ${user.currency}</p>
<p>
<span class="label label-${
user.isBanned ? 'danger' : 'success'
}">
<i class="fa fa-${
user.isBanned ? 'ban' : 'check'
}"></i> ${
user.isBanned ? 'Banned' : 'Active'
}
<span class="label label-${user.isBanned ? 'danger' : 'success'}">
<i class="fa fa-${user.isBanned ? 'ban' : 'check'}"></i> ${user.isBanned ? 'Banned' : 'Active'}
</span>
<span class="label label-${
user.isAdmin ? 'primary' : 'default'
}">
<i class="fa fa-${
user.isAdmin ? 'shield' : 'user'
}"></i> ${user.isAdmin ? 'Admin' : 'User'}
<span class="label label-${user.isAdmin ? 'primary' : 'default'}">
<i class="fa fa-${user.isAdmin ? 'shield' : 'user'}"></i> ${user.isAdmin ? 'Admin' : 'User'}
</span>
</p>
</div>
<div class="user-actions mt-3">
<button class="btn btn-sm btn-${
user.isBanned ? 'success' : 'warning'
} ban-user" data-user-id="${
user._id
}" data-is-banned="${user.isBanned}">
<i class="fa fa-${
user.isBanned ? 'unlock' : 'ban'
}"></i> ${
user.isBanned ? 'Unban User' : 'Ban User'
}
<button class="btn btn-sm btn-${user.isBanned ? 'success' : 'warning'} ban-user" data-user-id="${user._id}" data-is-banned="${user.isBanned}">
<i class="fa fa-${user.isBanned ? 'unlock' : 'ban'}"></i> ${user.isBanned ? 'Unban User' : 'Ban User'}
</button>
${
user.isAdmin
? user._id !== currentAdminId
? `<button class="btn btn-sm btn-danger demote-admin" data-user-id="${user._id}"><i class="fa fa-level-down"></i> Demote from Admin</button>`
${user.isAdmin ? user._id !== currentAdminId ? `<button class="btn btn-sm btn-danger demote-admin" data-user-id="${user._id}"><i class="fa fa-level-down"></i> Demote from Admin</button>`
: '<button class="btn btn-sm btn-success" disabled><i class="fa fa-user-circle"></i> Current Admin</button>'
: `<button class="btn btn-sm btn-info promote-admin" data-user-id="${user._id}"><i class="fa fa-level-up"></i> Promote to Admin</button>`
}
Expand Down
2 changes: 1 addition & 1 deletion server/functions/api/routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ router.post('/reset-forum-post-count', authenticateToken, async (req, res) => {
// Get all users
router.get('/users', authenticateToken, async (req, res) => {
try {
const users = await User.find({}, '-password');
const users = await User.find({}, '-password').select('username email signupDate isBanned isAdmin currency');
res.json(users);
} catch (error) {
console.error('Error fetching users:', error);
Expand Down

0 comments on commit fbe9d8b

Please sign in to comment.