import {AfterViewInit, Component, OnDestroy, OnInit} from "@angular/core";
import {ActivatedRoute} from "@angular/router";
import {OrgInfo, OrgService} from "./org.service";
import {PersonService} from "../person/person.service";
import {AppComponent} from "../app.component";
import {Observable, ReplaySubject} from "rxjs";

@Component({
  selector: 'private-page',
  templateUrl: 'privotal.page.component.html',
  styleUrls: ['privotal.page.component.scss']
})
export class PrivotalPageComponent implements OnInit, OnDestroy, AfterViewInit {

  orgInfo: Observable<OrgInfo>

  constructor(private app: AppComponent, private route: ActivatedRoute, private orgService: OrgService, private personService: PersonService) {
    let orgInfo = this.orgInfo = new ReplaySubject()
    route.paramMap.subscribe(par => personService.getCurrentPerson().subscribe(person => orgService.getOrg(par.get("privateId"), person.auth.id).subscribe(org => {
      orgInfo.next(org)
    })))
    app.setTitle("КАБИНЕТ ОРГАНИЗАЦИИ")
  }

  ngAfterViewInit(): void {

  }

  ngOnDestroy(): void {

  }

  ngOnInit(): void {

  }

}
