// Angular Core
import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';

@Component({
  standalone: false,
  selector: 'app-status-msg',
  templateUrl: './status-msg.component.html',
  styleUrls: ['./status-msg.component.scss']
})
export class StatusMsgComponent implements OnInit {

  @Input() status_type:string = '';
  @Input() show_status:boolean = false;
  @Input() status_msg:string = '';
  @Output() showStatus = new EventEmitter<boolean>();
  showClose:any = '';
  msgStyle = 'error-msg-style';
  showStatusAttrValue:boolean = this.show_status; 

  constructor() { }

  ngOnInit(): void { }

  ngOnChanges(){
    if(this.showClose === undefined 
      || this.showClose === ''
      || this.showClose === null) {
        this.showClose = true;        
    }
    /**
    * Status Div Style.
    */
    if (this.status_type !== undefined && this.status_type === 'success') {
      this.msgStyle = 'success-msg-style';
    }
    
    if (this.status_type !== undefined && this.status_type === 'error') {
      this.msgStyle = 'error-msg-style';
    }
  }

  /**
  * Method used to close the Status Div.
  * @param {boolean} showStatusAttrValue
  * @returns {undefined}
  */
    closeStatusMsg(showStatusAttrValue:boolean) {
      this.show_status = false;
      this.showStatus.emit(showStatusAttrValue)
    };
}
