package com.mvrent.carrental.controller;

import com.mvrent.carrental.service.CarService;
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/inspections")
@RequiredArgsConstructor
@PreAuthorize("hasRole('ADMIN') or hasAuthority('MANAGE_FLEET')")
public class AdminInspectionController {

    private final CarService carService;

    @GetMapping
    public String page(Model model) {
        model.addAttribute("cars", carService.findAll());
        return "admin/inspections";
    }
}
