


{% extends 'base.html' %}
{% block content %}
<head>
    <title>Edit Block</title>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css') }}">
    <script>
        window.onload = function () {
            const flash = document.getElementById('flash-message');
            if (flash) {
                alert(flash.innerText);
            }
        }
    </script>
</head>
<body>

<h2>Edit Block</h2>

<!-- Flash Message -->
{% with messages = get_flashed_messages(with_categories=true) %}
  {% if messages %}
    {% for category, message in messages %}
      <div id="flash-message" style="display:none;" data-category="{{ category }}">{{ message }}</div>
    {% endfor %}
  {% endif %}
{% endwith %}

<!-- Edit Block Form -->
<form method="POST">
    <label for="state_Id">State:</label>
    <select name="state_Id" id="state_Id" required>
        <option value="" disabled>Select State</option>
        {% for state in states %}
            <option value="{{ state[0] }}" {% if state[0] == block_data[1] %} selected {% endif %}>
                {{ state[1] }}
            </option>
        {% endfor %}
    </select><br><br>

    <label for="district_Id">District:</label>
    <select name="district_Id" id="district_Id" required>
        <option value="" disabled>Select District</option>
        {% for district in districts %}
            <option value="{{ district[0] }}" {% if district[0] == block_data[1] %} selected {% endif %}>
                {{ district[1] }}
            </option>
        {% endfor %}
    </select><br><br>

    <label for="block_Name">Block Name:</label>
    <input type="text" name="block_Name" value="{{ block_data[0] }}" placeholder="Enter Block Name" required><br><br>

    <button type="submit">Update Block</button>
</form>

</body>
{% endblock %}
