import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs';

import { RPCClientError } from '@loafer/ng-rpc';
import { Member } from '@overflow/commons-typescript/model/member';

import { AuthContainerSelector } from '@overflow/shared/auth/store';
import { DomainMember } from '@overflow/commons-typescript/model/domain';

import * as MemberEntityStore from '../store/entity/member';

@Component({
  selector: 'of-member-profile-container',
  templateUrl: './member-profile-container.component.html',
})
export class MemberProfileContainerComponent implements OnInit, OnDestroy {
  domainMember$: Observable<DomainMember>;

  constructor(
    private store: Store<any>,
  ) {
  }


  ngOnInit() {
    this.domainMember$ = this.store.pipe(select(AuthContainerSelector.selectDomainMember));
  }

  ngOnDestroy() {
  }

  modify(member: Member) {
    this.store.dispatch(new MemberEntityStore.Modify(member));
  }

}
