{% extends "demo/_layout" %}

{% set pageTitle = "Deleting Submission" %}

{% block content %}

    {% set formHandle = craft.app.request.segment(4) %}
    {% set form = freeform.form(formHandle) %}
    {% set token = craft.app.request.segment(5) %}

    {# Allow Admins only to modify submission data for Demo Templates by default #}
    {% if currentUser and currentUser.admin %}

        <div class="freeform-page-heading">
            <h2>Delete Submission</h2>
            <p>This page will delete any submission sent to it. This action cannot be undone.</p>
        </div>

        {% if freeform.deleteSubmissionByToken(token) %}
            <div class="freeform-success{{ colorMode == "dark" ? " freeform-notice-dark" }}">
                The submission has been removed successfully!
            </div>
        {% else %}
            <div class="freeform-error{{ colorMode == "dark" ? " freeform-notice-dark" }}">
                Error! The submission you specified cannot be found.
            </div>
        {% endif %}

    {% else %}

        <div class="freeform-warning-notice{{ colorMode == "dark" ? " freeform-notice-dark" }}">
            Sorry, you do not have permission to access this page.
        </div>

    {% endif %}

{% endblock %}