@page "/competence-list"
@using DataLayer.Interfaces
@using Domain.XML_Model
@attribute [StreamRendering(true)]

<div>
    <h3>Competence</h3>
</div>
<div>
    @if (Competences == null)
    {
        <p><em>Loading...</em></p>
    }
    else
    {
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>Nom</th>
                    <th>Type</th>
                    <th>Carac</th>
                    <th>Registre</th>
                    <th>Description</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var competence in Competences)
                {
                    <tr>
                        <td>@competence.Nom</td>
                        <td>@competence.Type</td>
                        <td>@competence.Carac</td>
                        <td>@competence.Registre</td>
                        <td>@competence.Description</td>
                    </tr>
                }
            </tbody>
        </table>
    }
</div>

@code {
    private List<Competence> Competences { get; set; }
    [Inject]
    public IAbstractRepository<Competence> _competenceRepository { get; set; }

    protected override async Task OnInitializedAsync()
    {
        // Load the competences data here
        Competences = await LoadCompetencesAsync();
    }

    private async Task<List<Competence>> LoadCompetencesAsync()
    {
        // Implement the logic to load competences data
        var skills = await _competenceRepository.GetAll();
        return skills.OrderBy(t => t.Nom).ToList();
    }
}