{% 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://sharpspring.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**.
1. In the left-hand sidebar menu, click on **API Settings**.
1. Click the **Generate New API Keys** button.
1. Copy the **Account ID** from {name} and paste in the **Account ID** field below.
1. Copy the **Secret Key** from {name} and paste in the **Secret Key** field below.

### Step 2. Provide Form Base URL
1. If you do not wish to map Formie Submission to a SharpSpring form, you can skip this step.
1. Click **Marketing** > **Content** > **Forms** in {name}'s top toolbar.
1. Click the **Create Form** button.
1. Enter a name for the form and select the **Native Form** radio button. Click the **Continue** button.
1. On the next screen, you'll be presented with embed instructions. We want to extract two bits of information.
1. Seach for the line `__ss_noform.push(['baseURI', 'https://app-xxxx.marketingautomation.services/webforms/receivePostback/xxxx/']);`
1. Copy the _just_ the **URL** value from the embed code (between the single quotes) and paste in the **Form URL** field below.

### Step 3. 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: '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: 'Secret Key' | t('formie'),
    instructions: 'Enter your {name} {label} here.' | t('formie'),
    name: 'secretKey',
    required: true,
    suggestEnvVars: true,
    value: integration.settings.secretKey ?? '',
    warning: macros.configWarning('secretKey', 'formie'),
    errors: integration.getErrors('secretKey'),
}) }}

{{ macros.proxyField(fieldVariables, 'autosuggestField', {
    label: 'Form Base URL' | t('formie'),
    instructions: 'Enter your {name} Form Base URL here if you wish to map to a {name} form.' | t('formie'),
    name: 'formUrl',
    required: false,
    suggestEnvVars: true,
    value: integration.settings.formUrl ?? '',
    warning: macros.configWarning('formUrl', 'formie'),
    errors: integration.getErrors('formUrl'),
}) }}
