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

import { apiFavoriteService } from 'src/app/core/services/api/api.favorite.service';

@Component({
  selector: 'app-favorites-page',
  templateUrl: './favorites-page.component.html',
  styleUrls: ['./favorites-page.component.css']
})
export class FavoritesPageComponent implements OnInit {
  
  url: string = '';
  displayedColumns: string[] = ['picture', 'lot', 'title', 'estimate'];
  dataSource = []

  constructor(
    private router: Router,
    private apiFavoriteService: apiFavoriteService) {}

  openDialog(): void {

    this.router.navigate(['favorites/new', this.url]);

  } 

  ngOnInit(): void {
    this.apiFavoriteService.getAllFavorite().subscribe((data: any) => {
      this.dataSource = data;
    });
  }

}

