{% extends 'formie/_layouts/settings' %}

{% import '_includes/forms' as forms %}
{% import 'verbb-base/_macros' as macros %}

{% block content %}

<h2>{{ 'Submissions' | t('formie') }}</h2>

<form action="" method="post" accept-charset="UTF-8" data-saveshortcut>
    <input type="hidden" name="action" value="formie/settings/save-settings">
    {{ redirectInput('formie/settings/submissions') }}
    {{ csrfInput() }}

    {% namespace 'settings' %}
        {{ forms.textField({
            first: true,
            type: 'number',
            label: 'Maximum Incomplete Submission Age' | t('formie'),
            instructions: 'The maximum age of an incomplete submission in days before it is deleted in garbage collection. Set to 0 to disable automatic deletion.' | t('formie'),
            id: 'maxIncompleteSubmissionAge',
            name: 'maxIncompleteSubmissionAge',
            value: settings.maxIncompleteSubmissionAge,
            autofocus: true,
            warning: macros.configWarning('maxIncompleteSubmissionAge', 'formie'),
        }) }}

        {{ forms.lightswitchField({
            label: 'Enable CSRF Validation for Guests' | t('formie'),
            instructions: 'Whether to enable Craft‘s CSRF validation checks for anonymous form submissions.' | t('formie'),
            id: 'enableCsrfValidationForGuests',
            name: 'enableCsrfValidationForGuests',
            on: settings.enableCsrfValidationForGuests,
            warning: macros.configWarning('enableCsrfValidationForGuests', 'formie'),
        }) }}

        {{ forms.lightswitchField({
            label: 'Use Queue for Notifications' | t('formie'),
            instructions: 'Whether to use Craft‘s queue system to trigger emails. This is highly recommended to prevent slow submissions for your users.' | t('formie'),
            id: 'useQueueForNotifications',
            name: 'useQueueForNotifications',
            on: settings.useQueueForNotifications,
            warning: macros.configWarning('useQueueForNotifications', 'formie'),
        }) }}

        {{ forms.lightswitchField({
            label: 'Use Queue for Integrations' | t('formie'),
            instructions: 'Whether to use Craft‘s queue system to trigger integrations. This is highly recommended to prevent slow submissions for your users.' | t('formie'),
            id: 'useQueueForIntegrations',
            name: 'useQueueForIntegrations',
            on: settings.useQueueForIntegrations,
            warning: macros.configWarning('useQueueForIntegrations', 'formie'),
        }) }}

        {{ forms.checkboxSelectField({
            label: 'Default Submissions State' | t('formie'),
            instructions: 'Set what sorts of submissions should be shown by default when viewing submissions.' | t('formie'),
            id: 'submissionsBehaviour',
            name: 'submissionsBehaviour',
            values: settings.submissionsBehaviour,
            showAllOption: true,
            options: [
                { label: 'Complete', value: 'complete' },
                { label: 'Incomplete', value: 'incomplete' },
                { label: 'Spam', value: 'spam' },
            ],
            warning: macros.configWarning('submissionsBehaviour', 'formie'),
        }) }}
    {% endnamespace %}

    <hr>

    <input type="submit" class="btn submit" value="{{ 'Save' | t('formie') }}">
</form>

{% endblock %}
