package dev.lions.user.manager.client.view;

import dev.lions.faces.layout.view.AbstractMenuModel;
import jakarta.enterprise.context.SessionScoped;
import jakarta.inject.Named;

import java.util.List;

/**
 * UserManagerMenuModel — Navigation de lions-user-manager.
 *
 * <p>Étend {@link AbstractMenuModel} pour fournir les entrées de menu
 * spécifiques à l'application de gestion des utilisateurs.</p>
 *
 * <p>Ce bean est injecté automatiquement dans {@code menu.xhtml}
 * (lions-faces-layout) via la référence EL {@code #{menuModel.model}}.</p>
 */
@Named("menuModel")
@SessionScoped
public class UserManagerMenuModel extends AbstractMenuModel {

    private static final long serialVersionUID = 1L;

    @Override
    protected List<MenuEntry> buildMenuItems() {
        return List.of(

            // ── Dashboard ────────────────────────────────────────────
            MenuEntry.item("m_dashboard",
                    "Tableau de Bord",
                    "pi pi-home",
                    "/pages/user-manager/dashboard.xhtml"),

            // ── Gestion des Utilisateurs ─────────────────────────────
            MenuEntry.submenu("m_users",
                    "Utilisateurs",
                    "pi pi-users",
                    List.of(
                        MenuEntry.item("m_user_list",
                                "Liste des utilisateurs",
                                "pi pi-list",
                                "/pages/user-manager/users/list.xhtml"),
                        MenuEntry.item("m_user_create",
                                "Créer un utilisateur",
                                "pi pi-user-plus",
                                "/pages/user-manager/users/create.xhtml"),
                        MenuEntry.item("m_user_profile",
                                "Mon profil",
                                "pi pi-id-card",
                                "/pages/user-manager/users/profile.xhtml")
                    )),

            // ── Gestion des Rôles ────────────────────────────────────
            MenuEntry.submenu("m_roles",
                    "Rôles",
                    "pi pi-shield",
                    List.of(
                        MenuEntry.item("m_role_list",
                                "Liste des rôles",
                                "pi pi-list",
                                "/pages/user-manager/roles/list.xhtml"),
                        MenuEntry.item("m_role_assign",
                                "Attribuer des rôles",
                                "pi pi-sitemap",
                                "/pages/user-manager/roles/assign.xhtml")
                    )),

            // ── Synchronisation Keycloak ──────────────────────────────
            MenuEntry.submenu("m_sync",
                    "Synchronisation",
                    "pi pi-sync",
                    List.of(
                        MenuEntry.item("m_sync_dashboard",
                                "Dashboard Sync",
                                "pi pi-chart-bar",
                                "/pages/user-manager/sync/dashboard.xhtml")
                    )),

            // ── Audit ────────────────────────────────────────────────
            MenuEntry.submenu("m_audit",
                    "Audit",
                    "pi pi-book",
                    List.of(
                        MenuEntry.item("m_audit_logs",
                                "Journal d'audit",
                                "pi pi-file-o",
                                "/pages/user-manager/audit/logs.xhtml")
                    )),

            // ── Paramètres ───────────────────────────────────────────
            MenuEntry.item("m_settings",
                    "Paramètres",
                    "pi pi-cog",
                    "/pages/user-manager/settings.xhtml")

        );
    }
}
