@extends('layouts.theme1')

@section('title', 'Joueurs de la session')

@section('content')
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="border-bottom title-part-padding">
                <h4 class="card-title mb-0">Joueurs de la session {{ $sessionId }}</h4>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table id="players-table" class="table table-bordered">
                        <thead>
                            <tr>
                                <th>Nom</th>
                                <th>Score</th>
                                <th>Temps de jeu</th>
                                <th>#ID joueur</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

{{-- Scripts --}}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>

<script>
    $(document).ready(function() {
        $('#players-table').DataTable({
            processing: true,
            serverSide: true,
            ajax: '{{ route("firebase.multijoueurs.players", $sessionId) }}',
            columns: [
                { data: 'name', name: 'name', defaultContent: '-' },
                { data: 'score', name: 'score', defaultContent: '0' },
                { data: 'playTime', name: 'playTime', defaultContent: '-' },
                { data: 'id', name: 'id' },
                { data: 'action', name: 'action', orderable: false, searchable: false }
            ]
        });
    });
</script>
@endsection
