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

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

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

		<h1 class="mt-4">CurrencyAPI</h1>
	</div>

	<x-form>
		<form class="flex flex-col gap-8" @submit.prevent="submit" x-ref="form">
			<div class="flex flex-col gap-2">
				<section class="flex flex-col gap-6 box" data-density="comfortable">
					<h2>{{ p__('heading', 'API') }}</h2>

					<div>
						<label for="currencyapi.api_key">
							{{ p__('label', 'API Key') }}
						</label>

						<div class="relative mt-2" x-data="{isVisible: false}">
							<input class="input pe-11" id="currencyapi.api_key" name="currencyapi[api_key]" :type="isVisible ? 'text' : 'password'" autocomplete="off" placeholder="{{ __('Include your API key') }}" value="{{ environment == 'demo' ? 'hidden-in-demo' : option.currencyapi.api_key ?? '' }}" required>

							<button type="button" class="absolute text-2xl -translate-y-1/2 top-1/2 end-3 text-content-dimmed" @click="isVisible = !isVisible">
								<i class="block ti" :class="{'ti-eye-closed' : isVisible, 'ti-eye':!isVisible}"></i>
							</button>
						</div>

						<ul class="info mt-2">
							<li>
								{{ __("Can't find your API Key?") }}

								<a href="https://app.currencyapi.com/api-keys" target="_blank" class="text-content hover:underline">
									{{ p__('button', 'Click here') }}
								</a>
							</li>
						</ul>
					</div>
				</section>
			</div>

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

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

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