using Microsoft.AspNetCore.Mvc; using LingAdmin.API.DTOs; namespace LingAdmin.API.Controllers; [ApiController] [Route("api/[controller]")] public class PagesController : ControllerBase { private readonly ILogger _logger; public PagesController(ILogger logger) { _logger = logger; } [HttpGet("inventory/config")] public ActionResult> GetInventoryConfig() { try { var config = new PageConfigDto { Title = "Inventory Management", TitleKey = "common.inventory", DataUrl = "/api/inventory", Columns = new List { new ColumnConfig { Field = "sku", Title = "SKU", HeaderKey = "common.sku" }, new ColumnConfig { Field = "name", Title = "Product Name", HeaderKey = "common.productName" }, new ColumnConfig { Field = "stock", Title = "Stock", HeaderKey = "common.stock" }, new ColumnConfig { Field = "price", Title = "Price", HeaderKey = "common.price" } }, Actions = new List { new ActionConfig { Code = "add", Label = "Add Item", LabelKey = "common.add" }, new ActionConfig { Code = "edit", Label = "Edit Item", LabelKey = "common.edit" }, new ActionConfig { Code = "delete", Label = "Delete Item", LabelKey = "common.delete" } } }; return Ok(ApiResponse.Success(config)); } catch (Exception ex) { _logger.LogError(ex, "Error getting inventory config"); return StatusCode(500, ApiResponse.Error("Internal server error", 500)); } } [HttpGet("audit/config")] public ActionResult> GetAuditConfig() { try { var config = new PageConfigDto { Title = "Audit Logs", TitleKey = "common.audit", DataUrl = "/api/audit", Columns = new List { new ColumnConfig { Field = "id", Title = "ID", HeaderKey = "common.id" }, new ColumnConfig { Field = "user", Title = "User", HeaderKey = "common.user" }, new ColumnConfig { Field = "action", Title = "Action", HeaderKey = "common.action" }, new ColumnConfig { Field = "timestamp", Title = "Time", HeaderKey = "common.time" } }, Actions = null // Audit logs typically don't have actions }; return Ok(ApiResponse.Success(config)); } catch (Exception ex) { _logger.LogError(ex, "Error getting audit config"); return StatusCode(500, ApiResponse.Error("Internal server error", 500)); } } }