import { Component, OnInit } from '@angular/core';
import { ReferralsApiService } from '@fleio-api/client-user/referrals/referrals-api.service';
import { ClipboardService } from '@shared/ui-api/clipboard.service';
import { ConfigService } from '@shared/config/config.service';
import { NotificationService } from '@shared/ui-api/notification.service';

@Component({
  selector: 'app-user-referral-details-tab',
  templateUrl: './user-referral-details-tab.component.html',
  styleUrl: './user-referral-details-tab.component.scss'
})
export class UserReferralDetailsTabComponent implements OnInit {
  loading = false;
  referralData;

  constructor(
    private referralsApiService: ReferralsApiService,
    public clipboard: ClipboardService,
    public config: ConfigService,
    private notificationService: NotificationService,
  ) {
  }


  ngOnInit() {
    this.loading = true;
    this.referralsApiService.referralData().subscribe({
      next: value => {
        this.referralData = value;
      }, error: error => {
        this.notificationService.showMessage(error.error.detail);
      }
    }).add(() => {
      this.loading = false;
    });
  }
}
