
class Alert {
    constructor(domItem) {
        this.item = domItem
        this.headingTitle = this.item.find(".alert-heading")
        this.body = this.item.find(".alert-body")
        this.icon = this.item.find(".icon-alert")
        this.iconSuccess = "ti-circle-check"
        this.iconError = "ti-exclamation-mark"
        this.iconInfo = "ti-question-mark"




    }
    setIcon(iconClass){
        this.icon.removeClass(this.iconSuccess)
        this.icon.removeClass(this.iconError)
        this.icon.removeClass(this.iconInfo)
        this.icon.addClass(iconClass)
    }
    setAsError() {
        this.item.removeClass("alert-success")
        this.item.addClass("alert-danger")
        this.setIcon(this.iconError)

    }
    setAsSuccess() {
        this.item.removeClass("alert-danger")
        this.item.removeClass("alert-warning")
        this.item.removeClass("alert-info")
        this.item.addClass("alert-success")
        this.setIcon(this.iconSuccess)
    }
    setAsWarning() {
        this.item.removeClass("alert-success")
        this.item.removeClass("alert-danger")
        this.item.removeClass("alert-info")
        this.item.addClass("alert-warning")
        this.setIcon(this.iconError)

    }
    setAsInfo() {
        this.item.removeClass("alert-success")
        this.item.removeClass("alert-danger")
        this.item.addClass("alert-warning")
        this.item.addClass("alert-info")
        this.setIcon(this.iconInfo)
    }
    show() { 
        this.item.removeClass("d-none")
    }
    hide() { 
        this.item.addClass("d-none")
    }
    setHeadingTitle(title) { 
        this.headingTitle.text(title)
    }
    setContent(content) {
        this.body.append(content)
     }
    setErrors() { }
    reset(){
        this.item.removeClass("alert-success")
        this.item.removeClass("alert-danger")
        this.item.removeClass("alert-warning")
        this.item.removeClass("alert-info")
        this.item.setContent("")
        this.item.setHeadingTitle("")
        this.item.hide()
        
    }
}

export default Alert;