{% extends "/layouts/main.twig" %}
{% set active_menu = '/admin/settings' %}

{% set xdata = 'settings' %}
{% block title p__('title', 'SMTP settings')|title %}

{% block template %}
	<div>
		{% include "snippets/back.twig" with {link: 'admin/settings', label: 'Settings'} %}

		<h1 class="mt-4">{{ p__('heading', 'SMTP') }}</h1>
	</div>

	<x-form>
		<form class="flex flex-col gap-8" @submit.prevent="submit" x-ref="form" data-path="/smtp">
			<section class="grid gap-6 md:grid-cols-2 box" data-density="comfortable">
				<h2 class="md:col-span-2">SMTP connection details</h2>

				<div>
					<label for="smtp.host">{{ p__('label', 'Host') }}</label>

					<input type="text" id="smtp.host" name="smtp[host]" class="mt-2 input" autocomplete="off" placeholder="{{ __('Enter your SMTP server host name') }}" value="{{ option.smtp.host ?? '' }}" required/>
				</div>

				<div>
					<label for="smtp.port">{{ p__('label', 'Port') }}</label>
					<input type="number" id="smtp.port" name="smtp[port]" class="mt-2 input" autocomplete="off" placeholder="{{ __('Enter your SMTP server port') }}" value="{{ option.smtp.port ?? '' }}" required/>

					<ul class="info mt-2">
						<li>{{ __('Common ports: 25, 465, 587 or 2525') }}</li>
					</ul>
				</div>

				<div>
					<label for="smtp.username">{{ p__('label', 'Username') }}</label>

					<input type="text" id="smtp.username" name="smtp[username]" class="mt-2 input" autocomplete="off" placeholder="{{ __('Authentication username') }}" value="{{ option.smtp.username ?? '' }}" required/>
				</div>

				<div>
					<label for="smtp.password">{{ p__('label', 'Password') }}</label>

					<input type="password" id="smtp.password" name="smtp[password]" class="mt-2 input" autocomplete="new-password" placeholder="{{ __('Password to authenticate') }}" value="{{ environment == 'demo' ? 'hidden-in-demo' : option.smtp.password ?? '' }}" required/>
				</div>
			</section>

			<div class="flex justify-end gap-4">
				<a href="admin/settings" class="button button-outline">
					{{ p__('button', 'Cancel') }}
				</a>

				<button type="submit" class="button button-accent" :processing="isProcessing">
					{% include "/snippets/spinner.twig" %}

					{{ p__('button', 'Save changes') }}
				</button>
			</div>
		</form>
	</x-form>
{% endblock %}
