<x-jetstream.form-section submit="updateProfileInformation">
    <x-slot name="title">
        {{ __('Credentials') }}
    </x-slot>

    <x-slot name="description">
        {{ __('Update your profile information and email address.') }}
    </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="{{ Storage::url(Session('activeProfilePhoto')) }}" alt="{{ getActiveProfile()->name }}" class="rounded-full profile-photo h-20 w-20 object-cover shadow 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 (getActiveProfile()->profile_photo_path)
                    <x-jetstream.secondary-button type="button" class="mt-2" wire:click="deleteProfilePhoto">
                        {{ __('Delete Photo') }}
                    </x-jetstream.secondary-button>
                @endif

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

        <!-- Full Name -->
        <div class="col-span-6 sm:col-span-4">
            <x-jetstream.label for="full_name" value="{{ __('Full name') }}" />
            @if(getActiveProfile() instanceof \App\Models\User)
                <x-jetstream.input id="full_name" type="text" class="mt-1 block w-full text-theme-muted
        bg-gray-100 bg-clip-padding
        border border-solid border-theme-border"
                    wire:model="state.full_name"
                    placeholder="{{__('Your real, full name, only visible for') . ' ' . __('messages.platform_users')}}"
                    autocomplete="name" disabled />
            @else
                <x-jetstream.input id="full_name" type="text" class="mt-1 block w-full"
                    wire:model="state.full_name"
                    placeholder="{{__('Your real, full name, only visible for') . ' ' . __('messages.platform_users')}}"
                    autocomplete="name" />
            @endif
            <x-jetstream.input-error for="state.full_name" class="mt-2" />
        </div>

        <!-- Username -->
        <div class="col-span-6 sm:col-span-4">
            <x-jetstream.label for="name" value="{{ __('Username') }}" />
            <x-jetstream.input id="name" type="text" class="mt-1 block w-full text-theme-muted
        bg-gray-100 bg-clip-padding
        border border-solid border-theme-border"
                wire:model="state.name"
                placeholder="{{__('Unique and public name, also used outside this platform')}}"
                autocomplete="username" disabled />
            <x-jetstream.input-error for="name" class="mt-2" />
        </div>

        <!-- Email -->
        <div class="col-span-6 sm:col-span-4">
            <x-jetstream.label for="email" value="{{ __('Email') }}" />
            <x-jetstream.input id="email" type="email" class="mt-1 block w-full" wire:model="state.email" />
            <x-jetstream.input-error for="state.email" class="mt-2" />


            <!-- Email verification for Org, Bank, Admin -->
            @if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::emailVerification()) && ! getActiveProfile()->hasVerifiedEmail())
                <p class="text-sm mt-2">
                    {{ __('Your email address is unverified.') }}

                    <button type="button" class="underline text-sm text-theme-secondary hover:text-theme-primary" wire:click.prevent="sendEmailVerification">
                        {{ __('Click here to re-send the verification email.') }}
                    </button>
                </p>

                @if ($verificationLinkSent)
                    <p v-show="verificationLinkSent" class="mt-2 font-medium text-sm text-green-600">
                        {{ __('A new verification link has been sent to your email address.') }}
                    </p>
                @endif
            @endif
        </div>

    </x-slot>

    <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>
