@extends('iqec.layouts.app')

@section('content')
    <div class="container-fluid">
        <div class="row page-titles">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Dashboard</a></li>
                <li class="breadcrumb-item active"><a href="javascript:void(0)">Courseware Partners</a></li>
            </ol>
        </div>
        @include('iqec.partials.flash')
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h4 class="card-title mb-0">Courseware Partners</h4>
                <a href="{{ route('courseware-partners.create') }}" class="btn btn-primary btn-sm">Add Courseware Partner</a>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-responsive-md">
                        <thead>
                            <tr>
                                <th>Name</th>
                                <th>Email</th>
                                <th>Authorised Partner</th>
                                <th>Status</th>
                                <th class="text-end">Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse ($partners as $partner)
                                <tr>
                                    <td>{{ $partner->applicant_name }}</td>
                                    <td>{{ $partner->email }}</td>
                                    <td>{{ $partner->authorisedPartner?->applicant_name }}</td>
                                    <td><span class="badge {{ $partner->user->status->badgeClass() }}">{{ $partner->user->status->label() }}</span></td>
                                    <td class="text-end">
                                        @include('iqec.partials.table-actions', [
                                            'resource' => 'courseware-partners',
                                            'record' => $partner,
                                            'label' => 'courseware partner',
                                        ])
                                    </td>
                                </tr>
                            @empty
                                <tr><td colspan="5">No courseware partners yet.</td></tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>
                {{ $partners->links() }}
            </div>
        </div>
    </div>
@endsection
