<x-jetstream.form-section submit="updateProfilePersonalForm">
    <x-slot name="title">
        {{ __('Bank information') }}

    </x-slot>

    <x-slot name="description">
        {{ __('A complete profile makes it easier for others to connect with your bank. Adding a photo, an introduction, a motivation for working with Timebank, and the languages your bank uses gives a clearer picture of who you are and why you use ' . platform_name()) }}
    </x-slot>

    <x-slot name="form">
        <!-- Profile Photo -->
        @if (Laravel\Jetstream\Jetstream::managesProfilePhotos())
            <div x-data="{photoName: null, photoPreview: null}" class="col-span-6 sm:col-span-4">
                <!-- Profile Photo File Input -->
                <input type="file" class="hidden"
                            wire:model.live="photo"
                            x-ref="photo"
                            x-on:change="
                                    photoName = $refs.photo.files[0].name;
                                    const reader = new FileReader();
                                    reader.onload = (e) => {
                                        photoPreview = e.target.result;
                                    };
                                    reader.readAsDataURL($refs.photo.files[0]);
                            " />

                <x-jetstream.label for="photo" value="{{ __('Profile Photo') }}" />

                <!-- Current Profile Photo -->
                <div class="mt-3 mb-3" x-show="! photoPreview">
                    <img src="{{ $this->profilePhotoUrl }}" alt="{{ $this->bank->name }}" class="rounded-full profile-photo h-20 w-20 object-cover outline outline-1 outline-offset-1 outline-gray-500">
                </div>

                <!-- New Profile Photo Preview -->
                <div class="mt-3 mb-3" x-show="photoPreview" style="display: none;">
                <span class="block rounded-full w-20 h-20 bg-cover bg-no-repeat bg-center"
                        x-bind:style="'background-image: url(\'' + photoPreview + '\');'">
                    </span>
                </div>

                <x-jetstream.secondary-button class="mt-2 mr-2" type="button" x-on:click.prevent="$refs.photo.click()">
                    {{ __('Change Photo') }}
                </x-jetstream.secondary-button>

                @if ($this->bank->profile_photo_path)
                    <x-jetstream.secondary-button type="button" class="mt-2" wire:click="deleteProfilePhoto" x-on:click.prevent="">
                        {{ __('Delete Photo') }}
                    </x-jetstream.secondary-button>
                @endif

                <x-jetstream.input-error for="photo" class="mt-2" />
            </div>
        @endif

        <!-- About field -->
        <div class="col-span-6 sm:col-span-4">
            <x-textarea
                wire:model.live.debounce.500ms="state.about"
                label="{{ $this->aboutLabel }}"
                placeholder="{{ __('What does your bank do? And who are you?') }}"
                class="placeholder-gray-300"
                rows="14"
                maxlength="{{ timebank_config('rules.profile_bank.about_max_input') }}" />
            <x-jetstream.input-error for="about" class="mt-2" />
        </div>

        <!-- About short field -->
        <div class="col-span-6 sm:col-span-4">
            <x-textarea
                wire:model.live.debounce.500ms="state.about_short"
                label="{{ $this->aboutShortLabel }}"
                placeholder="{{ __('I.e. your goal or slogan') }}"
                class="placeholder-gray-300"
                rows="3"
                maxlength="{{ timebank_config('rules.profile_bank.about_short_max_input') }}" />
            <x-jetstream.input-error for="about_short" class="mt-2" />
        </div>

        <!-- Motivation -->
        <div class="col-span-6 sm:col-span-4">
            <x-textarea
                wire:model.live.debounce.800ms="state.motivation"
                label="{{ $this->motivationLabel }}"
                placeholder="{{__('Reaching out to a new community or serious about a new value system?')}}"
                class="placeholder-gray-300"
                rows="5"
                maxlength="{{ timebank_config('rules.profile_bank.motivation_max_input') }}" />
            <x-jetstream.input-error for="motivation" class="mt-2" />
        </div>

        <!--- Languages -->
        <div class="col-span-6 sm:col-span-4">
            @livewire('profile.languages-dropdown', ['languages' => $languages])
            <x-jetstream.input-error for="languages" class="mt-2" />
        </div>

        <!--- Social media -->
        <div class="grid col-span-6 sm:col-span-4">
            @livewire('profile.socials-form')
            <x-jetstream.input-error for="socials" class="mt-2" />
        </div>

        <!-- Website -->
        <div class="grid col-span-6 sm:col-span-4">
            <x-jetstream.label for="website" value="{{ __('External website') }}" />
            <x-jetstream.input
                placeholder="website.org"
                              wire:model.blur="website"
                class="placeholder-gray-300"
            />
            <x-jetstream.input-error for="website" class="mt-2" />
        </div>

    </x-slot>

    <!-- List of validation errors -->
    <x-errors />

    <x-slot name="actions">
        <x-jetstream.action-message class="mr-3" on="saved">
            {{ __('Saved') }}
        </x-jetstream.action-message>

        <x-jetstream.button wire:loading.attr="disabled" wire:target="photo">
            {{ __('Save') }}
        </x-jetstream.button>
    </x-slot>
</x-jetstream.form-section>

