@extends('backend.layouts.app')
@section('content')
<div class="content-wrapper">
  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6 pb-2 pb-sm-0">
          <h1>{{ $headerTitle }}</h1>
          <small><a href="{{ url('admin/series') }}">← Back to Series</a></small>
        </div>
        <div class="col-sm-6 text-sm-right">
          <a href="{{ url('admin/series/'.$series->id.'/seasons/add') }}" class="btn btn-primary">Add Season</a>
        </div>
      </div>
    </div>
  </section>

  <section class="content">
    <div class="container-fluid">
      @if(session('success'))
        <div class="alert alert-success">{{ session('success') }}</div>
      @endif
      <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-body table-responsive p-3">
              <table id="seasonTable" style="width:100%;" class="table table-striped">
                <thead>
                  <tr>
                    <th style="width:60px">S.No.</th>
                    <th>Season #</th>
                    <th>Title</th>
                    <th>Episodes</th>
                    <th>Status</th>
                    <th>Actions</th>
                  </tr>
                </thead>
                <tbody></tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</div>
@endsection

@push('scripts')
<script>
$(document).ready(function () {
  $('#seasonTable').DataTable({
    processing: true,
    serverSide: true,
    ajax: { url: '{{ route('admin.seasons.index', $series->id) }}' },
    columns: [
      { data: null, orderable: false, searchable: false, render: (d, t, r, m) => m.row + 1 },
      { data: 'season_number', name: 'season_number' },
      { data: 'title', name: 'title' },
      { data: 'episodes_count', name: 'episodes_count', orderable: false, searchable: false },
      { data: 'status', name: 'status' },
      { data: 'actions', name: 'actions', orderable: false, searchable: false },
    ],
    responsive: true,
  });
});
</script>
@endpush
