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

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

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

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

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

				<div>
					<label for="site.name">{{ p__('label', 'Name') }}</label>

					<input type="text" id="site.name" name="site[name]" class="mt-2 input" autocomplete="off" placeholder="Aikeedo" value="{{ option.site.name ?? '' }}"/>
				</div>

				<div>
					<label for="site[domain]">{{ p__('label', 'Site Domain') }}</label>

					<input type="text" id="site[domain]" name="site[domain]" class="mt-2 input" autocomplete="off" placeholder="subdomain.example.com:8080" value="{{ option.site.domain ?? '' }}"/>

					<ul class="info mt-2">

						<li>
							{{ __('Include only domain, subdomain(if any) and port number(if any). Do not include protocol or path. Omit port number if it\'s 80 or 443.') }}
          </li>
        </ul>
      </div>

      <div>
        <div
          class="flex justify-between items-center p-3 rounded-lg bg-intermediate">
          {{ p__('label', 'Is SSL Enabled?') }}

          <label class="inline-flex gap-2 items-center cursor-pointer">
            <input type="checkbox" name="site[is_secure]" class="hidden peer"
              {{ option.site.is_secure is defined and option.site.is_secure ? 'checked' : '' }}>

            <span
              class="block relative w-10 h-6 rounded-3xl transition-all bg-line peer-checked:bg-success after:h-5 after:w-5 after:top-0.5 after:absolute after:left-0 after:ms-0.5 after:transition-all after:rounded-full after:bg-white peer-checked:after:left-4"></span>

            <span class="text-content-dimmed peer-checked:hidden">
              {{ __('No') }}
            </span>

            <span class="hidden text-success peer-checked:inline">
              {{ __('Yes') }}
            </span>
          </label>
        </div>

        <ul
          class="info mt-2">

          <li>
            {{ __('Enable this only if you have SSL certificate installed on your server. SSL is required for various features like SSO, Payment Gateways etc. It\'s highly recommended to enable SSL.') }}
						</li>
					</ul>
				</div>

				<div>
					<div class="flex justify-between items-center p-3 rounded-lg bg-intermediate">
						{{ p__('label', 'Landing Page') }}

						<label class="inline-flex gap-2 items-center cursor-pointer">
							<input type="checkbox" name="site[is_landing_page_enabled]" class="hidden peer" {{ option.site.is_landing_page_enabled is not defined or option.site.is_landing_page_enabled ? 'checked' : '' }}>

							<span class="block relative w-10 h-6 rounded-3xl transition-all bg-line peer-checked:bg-success after:h-5 after:w-5 after:top-0.5 after:absolute after:left-0 after:ms-0.5 after:transition-all after:rounded-full after:bg-white peer-checked:after:left-4"></span>

							<span class="text-content-dimmed peer-checked:hidden">
								{{ __('Disabled') }}
							</span>

							<span class="hidden text-success peer-checked:inline">
								{{ __('Enabled') }}
							</span>
						</label>
					</div>

					<ul class="info mt-2">

						<li>
							{{ __('Disabling landing page will redirect users to login page.') }}
						</li>
					</ul>
				</div>

				<div>
					<label>{{ p__('label', 'Default app page') }}</label>

					<input type="text" id="site[default_app_page]" name="site[default_app_page]" class="mt-2 input" autocomplete="off" placeholder="/app" value="{{ option.site.default_app_page ?? '' }}"/>

					<ul class="info mt-2">

						<li>
							{{ __('This setting will be used as the default page for the users when they login.') }}
						</li>

						<li>
							{{ __('Admins will always be redirected to the admin dashboard.') }}
						</li>
					</ul>
				</div>
			</section>

			<section class="grid grid-cols-1 gap-6 box" data-density="comfortable">
				<h2>{{ p__('heading', 'SEO') }}</h2>

				<div>
					<label for="site.keywords">{{ p__('label', 'Keywords') }}</label>

					<input type="text" id="site.keywords" name="site[keywords]" class="mt-2 input" autocomplete="off" placeholder="Aikeedo" value="{{ option.site.keywords ?? '' }}"/>
				</div>

				<div>
					<label for="site.description">{{ p__('label', 'Description') }}</label>

					<textarea name="site[description]" id="site.description" class="mt-2 input" rows="3">{{ option.site.description ?? '' }}</textarea>
				</div>
			</section>
		</div>

		<div class="flex gap-4 justify-end">
			<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>
{% endblock %}
