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

{% set displayName = integration.displayName() %}

{% set instructions %}
### Step 1. Connect to the {name} API
1. Go to <a href="https://www.avochato.com/" target="_blank">{name}</a> and login to your account.
1. In the left-hand sidebar menu, click on **Settings**.
1. Click the **Generate Credentials** button.
1. Copy the **Auth ID** from {name} and paste in the **Auth ID** field below.
1. Copy the **Auth Secret** from {name} and paste in the **Auth Secret** field below.

### Step 2. Test Connection
1. Save this integration.
1. Click on the **Refresh** button in the right-hand sidebar.
{% endset %}

<div class="fui-settings-block">
    {{ instructions | t('formie', { name: displayName }) | md }}
</div>

{% if not craft.app.config.general.allowAdminChanges %}
    <span class="warning with-icon">
        {{ 'Integration settings can only be editable on an environment with `allowAdminChanges` enabled.' | t('formie') | md(inlineOnly=true) }}
    </span>
{% endif %}

{{ macros.proxyField(fieldVariables, 'autosuggestField', {
    label: 'Auth ID' | t('formie'),
    instructions: 'Enter your {name} {label} here.' | t('formie'),
    name: 'authId',
    required: true,
    suggestEnvVars: true,
    value: integration.settings.authId ?? '',
    warning: macros.configWarning('authId', 'formie'),
    errors: integration.getErrors('authId'),
}) }}

{{ macros.proxyField(fieldVariables, 'autosuggestField', {
    label: 'Auth Secret' | t('formie'),
    instructions: 'Enter your {name} {label} here.' | t('formie'),
    name: 'authSecret',
    required: true,
    suggestEnvVars: true,
    value: integration.settings.authSecret ?? '',
    warning: macros.configWarning('authSecret', 'formie'),
    errors: integration.getErrors('authSecret'),
}) }}
