import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { SobreDoencasService } from 'src/app/services/sobre-doencas/sobre-doencas.service';
import { SobreDoenca } from 'src/app/models/sobre-doenca/sobre-doenca.model';

@Component({
  selector: 'app-saiba-mais',
  templateUrl: './saiba-mais.component.html',
  styleUrls: ['./saiba-mais.component.css']
})
export class SaibaMaisComponent implements OnInit {
  
  doenca: SobreDoenca = new SobreDoenca();

  constructor(private service: SobreDoencasService, private route: ActivatedRoute ) { }

  ngOnInit()
  {
   const id = this.route.snapshot.paramMap.get('id');
   this.carregarDoenca(id);
  }

  carregarDoenca(id: string | null){
    if(id){
      this.service.buscarDoencaPorId(id).subscribe(
        response => {
          this.doenca = response;
        },
        error => {
          console.error("Erro ao obter doença", error);
        }
      )
    }
  }
}
