namespace Brizco.Api.Controllers;

public class PageController : ICarterModule
{

    public void AddRoutes(IEndpointRouteBuilder app)
    {

        var group = app.NewVersionedApi("Page")
            .MapGroup($"api/page")
            .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());

        group.MapGet("/app/dashboard", GetAppDashboardAsync)
            .WithDisplayName("GetAppDashboard")
            .HasApiVersion(1.0);

        group.MapGet("/app/shifting", GetAppShiftingPageAsync)
            .WithDisplayName("Get App Shifting Page")
            .HasApiVersion(1.0);


    }

    public async Task<IResult> GetAppDashboardAsync([FromServices] IPageService pageService, CancellationToken cancellationToken)
        => TypedResults.Ok(await pageService.GetAppDashboardAsync(cancellationToken));

    public async Task<IResult> GetAppShiftingPageAsync([FromQuery]Guid routineId,[FromServices] IPageService pageService, CancellationToken cancellationToken)
        => TypedResults.Ok(await pageService.GetShiftingPageAsync(routineId,cancellationToken));
}