{% 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.maximizer.com/support/crm-api/" target="_blank">Maximizer CRM API</a> and request access to their API.
1. When approved, you'll receive your details via email.
1. Enter your **Username** from {name} and paste in the **Username** field below.
1. Enter your **Password** from {name} and paste in the **Password** field below.
1. Copy the **Web Access URL** from {name} and paste in the **Web Access URL** field below.
1. Copy the **Database ID** from {name} and paste in the **Database ID** field below.
1. Copy the **Vendor ID** from {name} and paste in the **Vendor ID** field below.
1. Copy the **App Key** from {name} and paste in the **App Key** 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: '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} {label} here.' | 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: 'Web Access URL' | t('formie'),
    instructions: 'Enter your {name} {label} here.' | t('formie'),
    name: 'webAccessUrl',
    required: true,
    suggestEnvVars: true,
    value: integration.settings.webAccessUrl ?? '',
    warning: macros.configWarning('webAccessUrl', 'formie'),
    errors: integration.getErrors('webAccessUrl'),
}) }}

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

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

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