<div class="col card--ui" id="card--dashboard">

    <a class="btn--ui lightGrey" href="/calendar"><i class="fa-solid fa-arrow-left"></i></a><br>

    <header id="title--section" style="display:none !important" class="d-flex align-items-center justify-content-between">
        <div class="title--section_name d-flex align-items-center justify-content-between">
            <i class="ico--ui title_section utenti me-2"></i>
            <h2 class="primary">Impostazioni calendario</h2>
        </div>
    </header>

    <div class="row">
        <div class="col-12 mb-3">
            <h3 class="primary">Corsi</h3>
        </div>
        <div class="col-12 mb-3">
            @foreach ($course_colors as $course)
                <div class="course-color mb-4 gap-3">
                    <input type='color' wire:model='colors.{{$course->id}}' />
                    <span>{{$course->name}}</span>
                </div>
            @endforeach
        </div>
        <div class="col-12 mb-3 text-end">
            <button wire:click='store()' class='btn--ui'@if (!$changed) disabled @endif>Salva modifiche</button>
        </div>
    </div>

    
    <div wire:ignore.self class="modal fade saved-modal" id="savedModal" tabindex="-1" role="dialog" aria-labelledby="savedModal" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header"></div>
                <div class="modal-body pt-4 pb-4 text-center fw-bold">Modifiche salvate con successo</div>
            </div>
        </div>
    </div>
</div>


@push('scripts')
<style>
.modal-backdrop.show{
    opacity: 0.3
}
</style>
@endpush

@push('scripts')
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>

<script>
Livewire.on('success', () => {
    isSaving = true;
    showSavedAlert();
});

let saved_alert_timeout;
function showSavedAlert() {
    $('#savedModal').modal("show");
    clearTimeout(saved_alert_timeout);
    saved_alert_timeout = setTimeout(() => {
        $('#savedModal').modal("hide");
    }, 3000);
}
</script>
@endpush
