<%# Main class navigation page %>
<%# ARGUMENTS: populated teachingClasses %>

<%- include("../../partials/header") -%>
<%- include("../../partials/navigationPrivate") -%>

<div class="container mt-5 mb-1">
  <div class="mb-2">
    <%- include("../../partials/flashes") -%>
  </div>
  <h1 class="text-center display-3">Your Classes</h1>
</div>
<% if (teachingClasses && teachingClasses.length != 0) { %>
<% console.log(teachingClasses) %>
<% console.log(classes) %>
<div class="jumbotron container">
  <% teachingClasses.forEach((classI, classIndex) => { %>
  <a class="btn w-100 btn-primary" href="/class/manage/<%= classI.classCode %>"><%= classI.name %></a><br>
  <% }) %>
</div>
<h4 style="text-align: center;">You can also <a href="/class/create">create</a> another class.</h4>
<br>
<% } else { %>
<div class="container">
  <h4 style="text-align: center;">You're not teaching any classes. If you'd like, you can <a href="/class/create">create</a> a class.</h4>
</div>
<% } %>

<% if (classes && classes.length != 0) { %>
<div class="jumbotron container">
  <% classes.forEach((classI, classIndex) => { %>
  <form method="post" action="/class/leave">
    <h4 style="float: left"><%= classI.name %></h4>
    <input type="text" style="display: none" name="classId" value="<%= classI._id %>">
    <input type="text" style="display: none" name="className" value="<%= classI.name %>">
    <input type="submit" style="float: right; margin-top: -5px;" class="btn btn-danger" value="Leave this class">
    <br>
  </form>
  <% }); %>
</div>
<h4 style="text-align: center;">Or you can <a href="/class/join">join</a> another class.</h4>
<br>
<% } else { %>
<div class="container">
  <h4 style="text-align: center;">You haven't joined any classes. If you'd like, you can <a href="/class/join">join</a> a class.</h4>
</div>
<% } %>

<%- include("../../partials/footer") -%>
