@if ($errors->any())
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
        <div>
            @foreach ($errors->all() as $error)
                <p>{{ $error }}</p>
            @endforeach
        </div>
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
@endif

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
@if (Session::has('success'))
    <script>
        Swal.fire({
            title: "Success!",
            text: "{{ Session::get('success') }}",
            icon: "success"
        }).then(() => {
            if ("{{ Session::get('redirect_url') }}") {
                window.location.href = "{{ Session::get('redirect_url') }}";
            }
        });
    </script>
@endif

@if (Session::has('error'))
    <script>
        Swal.fire({
            title: "Error!",
            text: "{{ Session::get('error') }}",
            icon: "error",
            timer: 5000
        }).then(() => {
            if ("{{ Session::get('redirect_url') }}") {
                window.location.href = "{{ Session::get('redirect_url') }}";
            }
        });
    </script>
@endif
