import { Component } from '@angular/core';
import { ICellRendererAngularComp } from 'ag-grid-angular';
import { ICellRendererParams } from 'ag-grid-community';
import { TeamActivity } from '../../models/transaction.model';
import { TransactionAmount } from '../transaction-amount/transaction-amount';

@Component({
  selector: 'app-amount-cell-renderer',
  imports: [TransactionAmount],
  template: `
    @if (data) {
      <app-transaction-amount
        [amount]="data.amount"
        [type]="data.type"
        [context]="data.isTeamWalletTransaction ? 'team' : 'player'"
      />
    }
  `,
})
export class AmountCellRenderer implements ICellRendererAngularComp {
  protected data?: TeamActivity;

  agInit(params: ICellRendererParams<TeamActivity>): void {
    this.data = params.data;
  }

  refresh(params: ICellRendererParams<TeamActivity>): boolean {
    this.data = params.data;
    return true;
  }
}
