package com.cloudhandson.vpdbackoffice.web;

import com.cloudhandson.vpdbackoffice.service.GroupService;
import com.cloudhandson.vpdbackoffice.service.PermissionService;
import com.cloudhandson.vpdbackoffice.service.UserService;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class DashboardController {

  private final UserService userService;
  private final GroupService groupService;
  private final PermissionService permissionService;

  public DashboardController(
      UserService userService,
      GroupService groupService,
      PermissionService permissionService
  ) {
    this.userService = userService;
    this.groupService = groupService;
    this.permissionService = permissionService;
  }

  @GetMapping("/")
  public String dashboard(Model model) {
    // The backoffice home is an identity-administration landing page.
    // It intentionally does not query legacy CB_* VPD catalog objects.
    model.addAttribute("users", userService.findAll());
    model.addAttribute("groups", groupService.findAll());
    model.addAttribute("objects", List.of());
    model.addAttribute("roles", permissionService.findRoles());
    model.addAttribute("tokens", List.of());
    return "dashboard";
  }
}
