t00-multiuser/server/views/home/home.ejs
2024-09-28 10:32:33 +01:00

59 lines
No EOL
2.3 KiB
Text

<%- include("../base/header", { title: "Home", userId: session.userId }) %>
<div class="row">
<div class="col text-center pb-5 lg-sm-0">
<h1>Welcome back <%= user.Username %>!</h1>
<h3>What would you like to do?</h3>
<div class="mt-3 text-nowrap">
<div>
<a class="btn btn-primary btn-lg me-2" href="/account/changeusername">Change Username</a>
<a class="btn btn-primary btn-lg disabled" href="/account/password">Change Password</a>
</div>
<div class="mt-3">
<a class="btn btn-primary btn-lg me-2" href="/party/create">Create Party</a>
<a class="btn btn-primary btn-lg" href="/party/join">Join Party</a>
</div>
<% if (user.UserLevel === UserLevel.Admin) { %>
<div class="mt-3">
<a class="btn btn-primary btn-lg" href="/admin">Admin Dashboard</a>
</div>
<% } %>
</div>
</div>
<div class="col">
<h3>Your Parties</h3>
<% if (parties.length > 0) { %>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Code</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<% for (const party of parties) { %>
<tr>
<td><%= party.Name %></td>
<td class="align-middle"><%= party.PartyRef %></td>
<td class="text-end text-nowrap align-middle">
<% if (activeUserParty && activeUserParty.PartyId === party.Id) { %>
<a href="/party/deactivate" class="btn btn-sm btn-success me-2">Deactivate</a>
<% } else { %>
<a href="/party/setactive?id=<%= party.Id %>" class="btn btn-sm btn-success me-2">&nbsp;Activate&nbsp;</a>
<% } %>
<% if (party.CreatedByUserId === user.Id) { %>
<a href="/party/delete?id=<%= party.Id %>" class="btn btn-sm btn-danger" onclick="return confirm(`Are you sure you want to delete '<%= party.Name %>'?\nThis will remove all users in this party from it.\nThis action cannot be undone.`)">Delete</a>
<% } else { %>
<a href="/party/leave?id=<%= party.Id %>" class="btn btn-sm btn-danger" style="width:4.275rem" onclick="return confirm(`Are you sure you want to leave '<%= party.Name %>'?`)">Leave</a>
<% } %>
</td>
</tr>
<% } %>
</tbody>
</table>
<% } else { %>
<div class="alert alert-primary" role="alert">You are not in any parties.</div>
<% } %>
</div>
</div>
<%- include("../base/footer") %>