package com.gbcm.client.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import com.gbcm.client.service.CoachingSessionRestService;
import com.gbcm.server.api.dto.session.CoachingSessionDTO;
import com.gbcm.server.api.dto.common.PagedResponseDTO;

import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;

@Named("sessionBean")
@RequestScoped
public class CoachingSessionBean implements Serializable {

    private static final Logger logger = Logger.getLogger(CoachingSessionBean.class.getName());

    @Inject
    private CoachingSessionRestService sessionRestService;

    public List<CoachingSessionDTO> getSessions() {
        try {
            logger.info("Récupération de la liste des sessions");
            PagedResponseDTO<CoachingSessionDTO> pagedResponse = sessionRestService.getCoachingSessions(0, 50, null,
                    null, null, null, null, null);
            return pagedResponse.getContent();
        } catch (Exception e) {
            logger.severe("Erreur lors de la récupération des sessions: " + e.getMessage());
            return new ArrayList<>();
        }
    }
}
