import { Component, OnInit, Input } from '@angular/core';

import { FundRecordData } from '../../../structures/fund-record-data';

import { LoginService } from '../../../services/login.service';
import { FundService } from '../../../services/fund.service';

@Component({
  selector: 'app-fund-table',
  templateUrl: './fund-table.component.html',
  styleUrls: ['./fund-table.component.scss']
})
export class FundTableComponent implements OnInit {

  @Input() fund: FundRecordData[] = [];

  displayedColumns: string[] = ['date', 'description', 'amount'];

  constructor(private loginService: LoginService, private fundService: FundService) { }

  ngOnInit(): void {
    if(this.loginService.instructorRoleAtLeast('zamestnanec')){
      this.displayedColumns.push('delete');
    }
  }

  removeFundRecord(id: number) {
    this.fundService.removeFund(id);
  }

}
