import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import { TeamsService } from '../../teams.service';
import {MatListModule} from '@angular/material/list';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import { CommonModule } from '@angular/common';
import { TranslateModule, TranslatePipe } from '@ngx-translate/core';

@Component({
  selector: 'app-details',
  templateUrl: './details.component.html',
  styleUrls: ['./details.component.scss'],
  standalone: true,
  imports: [CommonModule, MatDialogModule, MatListModule, MatProgressSpinnerModule, TranslateModule],
  providers: []
})
export class DetailsComponent implements OnInit {

  constructor(
    public dialogRef: MatDialogRef<DetailsComponent>,
    @Inject(MAT_DIALOG_DATA) public data: { user: any  },
    private teamService: TeamsService
  ) {}

  ngOnInit(): void {
    console.log("Onmit")
    this.teamService.loadTransactionsOfUser(this.data.user.id);
  }

  get transactions(): any[] {
    return this.teamService.selectedUserTransaction;
  }

  get isLoading(): boolean {
    return this.teamService.transactionsLoading;
  }

}
