import {Component, OnInit} from '@angular/core';
import {ProblemService} from '../problem.service';
import { ApiService } from '../api.service';
import {Problem} from '../problem';
import { User } from '../user';

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

  user: User;
  problems: Problem[];

  constructor(private dataService: ApiService,
    private problemService: ProblemService) {
  }

  ngOnInit(): void {
    this.user = JSON.parse(this.dataService.getToken());
    console.log(this.user);
    this.getProblems();
  }

  getProblems(): void {
    this.problemService.getProblems()
      .subscribe(problems => this.problems = problems);
  }

}
