using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;

namespace PlotLine.Controllers;

[Authorize]
public sealed class HelpDiagnosticsController(IHelpService help) : Controller
{
    public IActionResult Index()
    {
        return View(new HelpDiagnosticsViewModel
        {
            Articles = help.GetAllArticles(),
            Coverage = help.GetCoverage()
        });
    }

    public IActionResult Article(string path)
    {
        var article = help.GetByRelativePath(path);
        return article is null ? NotFound() : View(new HelpArticleDiagnosticViewModel { Article = article });
    }
}
