import { Component, Input, OnInit } from '@angular/core';
import { AuthService } from '@shared/auth/auth.service';

@Component({
  selector: 'app-credit-warning',
  templateUrl: './credit-warning.component.html',
  styleUrls: ['./credit-warning.component.scss']
})
export class CreditWarningComponent implements OnInit {
  @Input() message: string;
  @Input() resourceName: string;

  constructor(private auth: AuthService) {
  }

  ngOnInit(): void {
  }

  showWarning(): boolean {
    const activeClient = this.auth.activeClient();
    if (activeClient) {
      return !activeClient.enough_credit;
    } else {
      return false;
    }
  }
}
