{% extends 'dashboard/admin_dashboard/main.html' %}
{% load static %}
{% block content %}
<h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Masters / Area /</span> Edit Area </h4>
<div style="padding: 10px;">
  {% if messages %}
    {% for message in messages %}
      <div class="alert {% if 'success' in message.tags %}alert-success alert-dismissible{% elif 'danger' in message.tags %}alert-danger 0{% endif %}" role="alert" id="success-alert">
        {{ message }}
        <button type="button" class="btn-close" data-bs-dismiss="alert"  aria-label="Close">
        </button>
      </div>
    {% endfor %}
  {% endif %}
</div>
<div class="row">
    <div class="col-md-12">
      <div class="card mb-4">
        <form role="form" method="POST" enctype="multipart/form-data" action="">
            {% csrf_token %}
            <div class="card-body">
            <!-- Area code -->
            <div class="mb-3">
              <label  class="form-label">Area Code <span style="color:red">*</span></label>
              <input type="text" class="form-control" id="defaultFormControlInput" name="area_code"  value="{{all_areas.area_code}}" required>
            </div>

            <!-- Area Name -->
            <div class="mb-3">
              <label  class="form-label">Area Name <span style="color:red">*</span></label>
              <input type="text" class="form-control"  name="area_name" value="{{all_areas.area_name}}" required>
            </div>

            <!-- Area Name -->
            <div class="mb-3">
              <label for="location-dropdown" class="form-label">Location <span style="color:red">*</span></label>
              <select name="location_id" id="location-dropdown" class="form-control" required>
                <option value="">-- Select Location --</option>
                {% for all_location in location %}
                  <option value="{{ all_location.id }}" {% if all_areas.location_id == all_location.id %} selected {% endif %}>{{ all_location.location_name }}</option>
                {% endfor %}
              </select>
            </div>

            <!-- Submit Button -->
            <div class="mt-3 d-flex justify-content-end">
              <button type="submit" class="btn btn-primary" id="btn_submit">Update</button>
            </div>

            </div>
        </form>
      </div>
    </div>
  </div>
<!-- JavaScript for dynamic dropdowns -->
<script src="{% static 'plugins/jQuery/jQuery-2.1.3.min.js' %}" type="text/javascript"></script>
{% endblock %}