{% 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.icontact.com/" target="_blank">{name}</a> and login to your account.
1. Click on your profile dropdown on the top-right of the screen, and select **Settings & Billing**.
1. Click on **iContact Integrations**.
1. Find the **Custom API Integrations** item and click the **Create** button.
1. Copy the **Application ID (AppId)** from {name} and paste in the **Application ID** field below.
1. Copy the **Username / Email Address** from {name} and paste in the **Username** field below.
1. Copy the **Password** from {name} and paste in the **Password** field below.
1. Copy the **Account ID** from {name} and paste in the **Account ID** field below.
1. Copy the **Client Folder ID** from {name} and paste in the **Client Folder ID** 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: 'Application ID' | t('formie'),
    instructions: 'Enter your {name} {label} here.' | t('formie'),
    name: 'appId',
    required: true,
    suggestEnvVars: true,
    value: integration.settings.appId ?? '',
    warning: macros.configWarning('appId', 'formie'),
    errors: integration.getErrors('appId'),
}) }}

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

{{ macros.proxyField(fieldVariables, 'autosuggestField', {
    label: 'Password' | t('formie'),
    instructions: 'Enter your {name} API password here. This is not your {name} account password.' | t('formie'),
    name: 'password',
    required: true,
    suggestEnvVars: true,
    value: integration.settings.password ?? '',
    warning: macros.configWarning('password', 'formie'),
    errors: integration.getErrors('password'),
}) }}

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

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