import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';

export type AuthDialogState = 'login' | 'register' | null;

@Injectable({ providedIn: 'root' })
export class AuthDialogService {
    private readonly dialogStateSubject = new BehaviorSubject<AuthDialogState>(null);

    readonly dialogState$ = this.dialogStateSubject.asObservable();

    openLogin(): void {
        this.dialogStateSubject.next('login');
    }

    openRegister(): void {
        this.dialogStateSubject.next('register');
    }

    close(): void {
        this.dialogStateSubject.next(null);
    }
}