package dev.lions.unionflow.server.resource;

import dev.lions.unionflow.server.api.dto.dashboard.MembreDashboardSyntheseResponse;
import dev.lions.unionflow.server.service.MembreDashboardService;
import jakarta.annotation.security.RolesAllowed;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;

@Path("/api/dashboard/membre")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Tag(name = "Dashboard Membre", description = "API pour le tableau de bord personnel des membres")
public class MembreDashboardResource {

    @Inject
    MembreDashboardService dashboardService;

    @GET
    @Path("/me")
    @RolesAllowed({ "USER", "MEMBRE", "ADMIN", "ADMIN_ORGANISATION", "SUPER_ADMIN" })
    @Operation(summary = "Récupérer la synthèse du dashboard pour le membre connecté")
    public Response getMonDashboard() {
        MembreDashboardSyntheseResponse data = dashboardService.getDashboardData();
        return Response.ok(data).build();
    }
}
