t00-multiuser/server/templates/home.ejs
2024-07-15 23:31:50 +01:00

54 lines
No EOL
2 KiB
Text

<%- include("base/header", { title: "Home", userId: user.Id }) %>
<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 disabled" href="/account/username">Change Username</a>
<a class="btn btn-primary btn-lg me-2 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 me-2" href="/party/join">Join Party</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><%= party.PartyRef %></td>
<td class="text-end text-nowrap">
<% 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">Set Current</a>
<% } %>
<% if (party.CreatedByUserId === user.Id) { %>
<a class="btn btn-sm btn-danger disabled" title="You may not leave a party if you created it." onclick="alert('You may not leave a party if you created it.')">Leave</a>
<% } else { %>
<a href="/party/leave?id=<%= party.Id %>" class="btn btn-sm btn-danger" 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") %>