using LSFE.API.Helper;
using LSFE.Domain.Contracts;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace LSFE.API.Controllers.Account
{
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class NavigationController : Controller
    {
        private readonly INavigationService _navigationService;
        public NavigationController(INavigationService navigationService)
        {
            _navigationService = navigationService;
        }

        [HttpGet("UserMenu")]
        public async Task<IActionResult> GetUserMenu()
        {
            var user = User.ToUserClaims();

            if (user is null) return Unauthorized();

            var result = await _navigationService
                .GetUserNavigationAsync(user.UserId);

            return Ok(result);
        }

        [HttpGet("role/{roleId}")]
        public async Task<IActionResult> GetNavigationByRole(string roleId)
        {
            var result = await _navigationService.GetNavigationByRoleAsync(roleId);
            return Ok(new { success = true, data = result });
        }
    }
}