{% extends 'base.html' %}

{% block title %}{% if object %}Edit Mission{% else %}New Mission{% endif %} - PixelMinds{% endblock %}

{% block content %}
<section class="section">
  <div class="container">
    <div class="row justify-content-center">
      <div class="col-lg-8">
        <div class="card shadow-sm">
          <div class="card-body p-5">
            <h1 class="card-title text-center mb-4">{% if object %}Edit Mission{% else %}Create a New Mission{% endif %}</h1>
            <form method="post" novalidate>
              {% csrf_token %}
              {% for field in form %}
                <div class="mb-3">
                  <label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}</label>
                  {{ field }}
                  {% if field.help_text %}
                    <div class="form-text">{{ field.help_text }}</div>
                  {% endif %}
                  {% for error in field.errors %}
                    <div class="invalid-feedback d-block">{{ error }}</div>
                  {% endfor %}
                </div>
              {% endfor %}
              <div class="d-grid gap-2 d-md-flex justify-content-md-start">
                <button type="submit" class="btn btn-primary">{% if object %}Save Changes{% else %}Create Mission{% endif %}</button>
                <a href="{% url 'core:mission_list' %}" class="btn btn-secondary">Cancel</a>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>
{% endblock %}
