part of 'auth_bloc.dart';

@freezed
class AuthState with _$AuthState {
  const AuthState._();

  const factory AuthState({
    required User user,
    @Default(AuthStatus.initial()) AuthStatus status,
    required Option<AuthFailure> failureOption,
    @Default(false) bool isFetching,
  }) = _AuthState;

  factory AuthState.initial() =>
      AuthState(user: User.empty(), failureOption: none());

  bool get isAuthenticated => status == const AuthStatus.authenticated();
  bool get isInitial => status == const AuthStatus.initial();
}

@freezed
sealed class AuthStatus with _$AuthStatus {
  const factory AuthStatus.authenticated() = _Authenticated;
  const factory AuthStatus.unauthenticated() = _Unauthenticated;
  const factory AuthStatus.initial() = _Initial;
}
