@extends('layouts.staff')
@section('title', 'Library')
@section('content')
    <x-page-head title="Library" subtitle="Catalog & loans" />
    <x-panel>
        <h4 style="margin-bottom:12px;">Active Loans</h4>
        @if ($activeLoans->isEmpty())
            <p style="color:var(--text2);">No active loans.</p>
        @else
            <div class="table-wrap"><table><thead><tr><th>Book</th><th>Student</th><th>Due</th></tr></thead><tbody>
                @foreach ($activeLoans as $loan)
                    <tr><td>{{ $loan->book?->title }}</td><td>{{ $loan->student?->full_name }}</td><td>{{ $loan->due_on?->format('d M Y') }}</td></tr>
                @endforeach
            </tbody></table></div>
        @endif
    </x-panel>
    <x-panel>
        <h4 style="margin-bottom:12px;">Catalog</h4>
        <div class="table-wrap"><table><thead><tr><th>Title</th><th>Author</th><th>Available</th></tr></thead><tbody>
            @foreach ($books as $book)
                <tr><td>{{ $book->title }}</td><td>{{ $book->author }}</td><td>{{ $book->copies_available }}/{{ $book->copies_total }}</td></tr>
            @endforeach
        </tbody></table></div>
        {{ $books->links() }}
    </x-panel>
@endsection
