<!DOCTYPE html>
<html lang="en">
<head>
    <title>Edit {{ reward_data["type"] }}</title>
    <link rel="icon" type="image/x-icon" href="/static/img/favicon.ico">
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
    <div class="panel">
    <div class="navbar">
        <p>Edit {{ reward_data["type"] }} "{{ reward_name }}"</p>
        <img alt="Ownchat Bot logo, whimsical robot" src="/static/img/ownchatbotwide.png">
    </div>
        <body style="text-align: left;">
            <form id="Edit reward/category" method="POST">
                <table>
                    {% if reward_data["type"] == "goal" %}
                    <tr>
                        <td> <label for="target">Target:</label> </td>
                        <td> <input id="target" type="number" name="target" value="{{ reward_data["target"] }}" required> </td>
                    </tr>
                    {% else %}
                    <tr>
                        <td> <label for="price">Price:</label> </td>
                        <td> <input id="price" type="number" name="price" value="{{ reward_data["price"] }}" required> </td>
                    </tr>
                    {% endif %}
                        <input type="hidden" name="type" value="{{ reward_data["type"] }}"><br>
                    <tr>
                        <td> <label for="info">Info:</label> </td>
                        <td> <textarea id="info" name="info" rows="1" cols="50" required>{{ reward_data["info"] }}</textarea> </td>
                    </tr>
                    {% if reward_data["type"] == "special" %}
                    <tr>
                        <td> <label for="cmd">Command:</label> </td>
                        <td> <input id="cmd" type="text" name="cmd" value="{{ reward_data["cmd"] }}" required> </td>
                    </tr>
                    {% endif %}
                    {% if reward_data["type"] != "category"%}
                        {% if reward_data["type"] == "goal" or reward_data["type"] == "vote" %}
                            <input type="hidden" name="cooldown" value="0">
                        {% else %}
                        <tr>
                            <td> <label for="cooldown">Cool down:</label> </td>
                            <td> <input id="cooldown" type="number" name="cooldown" maxlength="2" size="2" value="{{ reward_data["cooldown"] }}" required> minutes until this reward can be redeemed again, after each use.</td>
                        </tr>
                        {% endif %}
                    {% endif %}
                    
                    {% if reward_data["type"] == "goal" %}
                        <tr>
                            <td>
                                Milestones:
                            </td>
                            <td>
                                <table>
                                    <tr>
                                        <td>
                                            <label for="milestone1_desc">Reward:</label>
                                        </td>
                                        <td>
                                            <input id="milestone1_desc" type="text" name="milestone1_desc" size="30" value="{{ reward_data["milestones"]["milestone1"][0] }}">
                                        </td>
                                        <td>
                                            <label for="milestone1_points"> at </label>
                                        </td>
                                        <td>
                                            <input id="milestone1_points" type="number" name="milestone1_points" maxlength="4" size="4" value="{{ reward_data["milestones"]["milestone1"][1] }}"> points reached.
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <label for="milestone2_desc">Reward:</label>
                                        </td>
                                        <td>
                                            <input id="milestone2_desc" type="text" name="milestone2_desc" size="30" value="{{ reward_data["milestones"]["milestone2"][0] }}">
                                        </td>
                                        <td>
                                            <label for="milestone2_points"> at </label>
                                        </td>
                                        <td>
                                            <input id="milestone2_points" type="number" name="milestone2_points" maxlength="4" size="4" value="{{ reward_data["milestones"]["milestone2"][1] }}"> points reached.
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <label for="milestone3_desc">Reward:</label>
                                        </td>
                                        <td>
                                            <input ="milestone3_desc" type="text" name="milestone3_desc" size="30" value="{{ reward_data["milestones"]["milestone3"][0] }}">
                                        </td>
                                        <td>
                                            <label for="milestone3_points"> at </label>
                                        </td>
                                        <td>
                                            <input ="milestone3_points" type="number" name="milestone3_points" maxlength="4" size="4" value="{{ reward_data["milestones"]["milestone3"][1] }}"> points reached.
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    {% endif %}
                    
                    <tr>
                        <td>Categories</td>
                        <td>Categories in <span style="color: orange;">orange</span> are inactive.
                            <table>
                                {% for cat in all_cats %}
                                    <tr>
                                        {% if cat in active_categories %}
                                        <td> <label for="category">{{ cat }}:</label> </td>
                                        {% else %}
                                        <td> <label for="category"><span style="color: orange;">{{ cat }}</span>:</label> </td>
                                        {% endif %}
                                        {% if cat in reward_data["categories"] %}
                                            <td> <input id="category" type="checkbox" name="category" value="{{ cat }}" checked> </td>
                                        {% else %}
                                            <td> <input id="category" type="checkbox" name="category" value="{{ cat }}"> </td>
                                        {% endif %}
                                    </tr>
                                {% endfor %}
                            </table>
                        </td>
                    </tr>
                </table>
                <br><button id="Edit reward/category" class="button button2" type="submit">Save Changes</button><br>
            </form>
		{% if reward_data["type"] == "category"%}
			<a href="{{ url_for('web_panels.mgmt', activeTab='categories') }}">Cancel</a>
		{% else %}
			<a href="{{ url_for('web_panels.mgmt', activeTab='managerewards') }}">Cancel</a>
		{% endif %}
            <br><br>
        </body>
    </div>
</html>
