package com.mvrent.carrental.controller;

import com.mvrent.carrental.model.Permission;
import com.mvrent.carrental.model.Role;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/admin/users")
@RequiredArgsConstructor
@PreAuthorize("hasRole('ADMIN') or hasAuthority('MANAGE_USERS')")
public class AdminUserController {

    @GetMapping
    public String page(Model model) {
        model.addAttribute("permissions", Permission.values());
        model.addAttribute("roles", new Role[]{Role.STAFF, Role.ADMIN});
        return "admin/users";
    }
}
