<x-layout>
    <x-slot:title>Bookmarks</x-slot:title>
    @if(auth()->check())
        <a href="{{ route('bookmarks.create-category') }}">new category pretty please</a><br>
        <a href="{{ route('bookmarks.create-bookmark') }}">new bookmark pretty please</a>
    @endif
    @foreach($categories as $category)
        <div class="bookmark-category">
            <h2>{{ $category->name }}</h2>
            @if(Auth::check())
                <hr>
                <form action="{{ route('bookmarks.destroy-category',$category->id) }}" method="POST">
                    @csrf
                    @method('DELETE')
                    <button type="submit">Delete</button>
                </form>
            @endif
            @if($category->shuffled)
                <p><em>(These are shuffled every load)</em></p>
                @php
                    $sites = $category->sites->shuffle();
                @endphp
            @else
                @php
                    $sites = $category->sites;
                @endphp
            @endif
            <hr>
            <ul>
            @foreach($sites as $site)
                    <li>
                        <a href="{{ $site->url }}"><font color="#000000">{{ $site->name }}</font></a> - {{ $site->description }}
                        @if(Auth::check())
                            <hr>
                            <form action="{{ route('bookmarks.destroy-bookmark',$site->id) }}" method="POST">
                                @csrf
                                @method('DELETE')
                                <button type="submit">Delete</button>
                            </form>
                        @endif
                    </li>
            @endforeach
            </ul>
        </div>
    @endforeach
</x-layout>
