const infoUsername = getID("infoUsername")
const infoUserimage = getID("infoUserimage")
const infoDisplayname = getID("infoDisplayname")
const views = getID("views")
const panelBox = getID("panel-box")


// User Request

const REQ_user = get("USERINFO")

REQ_user.then((ANS_user) => {
    infoUserimage.src = ANS_user.picture
    infoUsername.innerHTML = ANS_user.username
    infoDisplayname.innerHTML = ANS_user.display_name

    const permissions = ANS_user.permission

    const AvailableViews = new Array()

    permissions.forEach((permValue) => {

        AllComponents.forEach((component) => {
            if(component.permission == permValue) {
                component.inject(AvailableViews)
            }
          })

        
    })
    

    if(AvailableViews.join("") == "") {

        AvailableViews.push("<p style='width: 100%;' class='yellow t-center'><i class='fa-solid fa-warning'></i> Aucune permission ne semble vous êtes accordée<br>Demandez à Raphix afin de résoudre ce problème</p>")
        views.classList.remove("views-box")
        panelBox.style.justifyContent = "unset"
        console.log(panelBox.style)
    } else {

        views.classList.add("views-box")
    }

    views.innerHTML = AvailableViews.join("")

    // BindView

    AllComponents.forEach((component) => {
        component.bindView()
    })

  

})

