{% extends "base.html" %}

{% block title %}Shout.dev: Projects: {{ project.name }}{% endblock %}

{% block main %}
{% include "breadcrumbs.html" %}
<main class="container mt-5">
  <section class="mb-4">
    <h1>Project: <code>{{ project.name }}</code></h1>
  </section>
  <section class="mb-4">
    <h2>Enabled Channels</h2>
    <form
      method="post"
      action="{{ breadcrumbs.join("update-enabled-channels") }}"
    >
      <div class="mb-3">
        <table class="table">
          <thead>
            <tr>
              <th>Channel Name</th>
              <th>Enabled</th>
            </tr>
          </thead>
          <tbody>
            {% for channel in team_channels %}
              <tr>
                <td>
                  <label for="enable-channel-switch-{{ channel.id.simple() }}">
                    <a
                      target="_blank"
                      href="{{ breadcrumbs.join(format!("../../channels/{}", channel.id.simple()).as_str()) }}"
                    >
                      {{ channel.name }}
                    </a>
                  </label>
                </td>
                <td>
                  <input
                    class="form-check-input"
                    {% if enabled_channel_ids.contains(channel.id) %}
                      checked=""
                    {% endif %}
                    type="checkbox"
                    name="enabled_channels"
                    value="{{ channel.id.simple() }}"
                    id="enable-channel-switch-{{ channel.id.simple() }}"
                  >
                </td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      </div>
      <div class="mb-3">
        <input type="hidden" name="csrf_token" value="{{ csrf_token }}">
        <button class="btn btn-primary" type="submit">Save</button>
      </div>
    </form>
  </section>
</main>
{% endblock %}
