<?php

use App\Services\Chapter4Service;
use Livewire\Component;

new class extends Component
{
    public $data = [];
    public $school;

    public function mount(Chapter4Service $srvs) {
        $this->data = $srvs->getUsers($this->school, 3);
    }
};
?>

<div>
    <div class="table-responsive">
        <table class="table table-bordered" style="width: 100%">
            <thead>
                <tr>
                    <th class="text-center" style="width: 3%; padding: 8px">N°</th>
                    <th class="text-center" style="padding: 8px">Nom et Prénons</th>
                    <th class="text-center" style="padding: 8px">Matrimonile</th>
                    <th class="text-center" style="padding: 8px">Ancienneté</th>
                </tr>
            </thead>
            <tbody>
                @php $i = 1; @endphp
                @forelse ($data as $item)
                    <tr>
                        <th class="text-center" style="padding: 8px">{{ $i < 10 ? '0'.$i++:$i++ }}</th>
                        <td class="text-center" style="padding: 8px">
                            {{ ($item->sexe == 'F' ? 'Mme':'Mr').' '.strtoupper($item->first_name).' '.ucwords($item->last_name) }}
                        </td>
                        <td style="padding: 8px">{{ ucwords($item->matrimoniale) }}</td>
                        <td style="padding: 8px">A definir</td>
                    </tr> 
                @empty
                    <tr>
                        <td colspan="4" class="text-center" style="padding: 8px">Underdefined data</td>
                    </tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>