<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>View Inventory</title>
</head>
<body align="center">
    <h2>Item Inventory</h2>

    <table border="1" align="center">
        <tr>
            <!-- Table headers -->
            {% for attrib, config in item_attributes.items() %}
                <th>{{ config.display_name }}</th>
            {% endfor %}
            <th colspan="2">Actions</th>
        </tr>

        <!-- Table rows -->
        {% for item in items %}
        <tr>
            {% for attrib, config in item_attributes.items() %}
                <td>{{ item[attrib] }}</td>
            {% endfor %}
            <td>
                <form action="/update/{{ item[primary_attrib] }}" method="get">
                    <button type="submit">Edit</button>
                </form>
            </td>
            <td>
                <form action="/delete/{{ item[primary_attrib] }}" method="get">
                    <button type="submit">Delete</button>
                </form>
            </td>
        </tr>
        {% endfor %}
    </table>

    <br>
    <form action="/create" method="get">
        <button type="submit">Add new Item</button>
    </form>
    <form action="/uploadcsv" method="get">
        <button type="submit">Import from CSV</button>
    </form>
    <form action="/export_csv" method="POST">
        <button type="submit">Export Data</button>
    </form>
</body>
</html>