import { Query } from '@datorama/akita';
import sessionStore, { AuthenticationState } from './session.store';
export class AuthenticationQuery extends Query {
  constructor(store) {
    super(store);
    this.store = store;
    this.sessionState$ = this.select((state) => state.authenticationState);
    this.jwt$ = this.select((state) => state.jwt);
  }
  get sessionState() {
    return this.getValue().authenticationState;
  }
  get isUnauthorized() {
    return (this.getValue().authenticationState === AuthenticationState.Unauthorized ||
      this.getValue().authenticationState === AuthenticationState.Error);
  }
  get isAuthorized() {
    return this.getValue().authenticationState === AuthenticationState.Authenticated;
  }
}
export default new AuthenticationQuery(sessionStore);
