package com.spring.web.constant;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.spring.domain.user.entity.AgentUserRole;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum Menus {
    
    DASHBOARD(
        "/dashboard", 
        "Dashboard", 
        "bi bi-grid", 
        List.of(AgentUserRole.ROLE_SUPER, AgentUserRole.ROLE_ADMIN, AgentUserRole.ROLE_USER)
    ),
    SCHEDULE(
        "/schedule", 
        "Schedule", 
        "bi bi-menu-button-wide", 
        List.of(AgentUserRole.ROLE_SUPER, AgentUserRole.ROLE_ADMIN)
    ),
    USER_MANAGEMENT(
        "/user/management", 
        "User Management", 
        "bi bi-person", 
        List.of(AgentUserRole.ROLE_SUPER)
    );

    private final String menuUri;
    private final String menuName;
    private final String menuIcon;
    private final List<AgentUserRole> roles;

    public static List<Menus> fromRole(AgentUserRole role) {
        return Arrays.stream(values())
                    .filter(menu -> menu.roles.contains(role))
                    .collect(Collectors.toList());
    }

}
