import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:injectable/injectable.dart';
import 'package:krow/core/application/clients/api/api_client.dart';
import 'package:krow/core/data/models/staff/staff.dart';
import 'package:krow/core/sevices/auth_state_service/gql.dart';

@injectable
class AuthServiceDataProvider {
  final ApiClient _client;

  AuthServiceDataProvider({required ApiClient client}) : _client = client;

  Future<StaffStatus> getStaffStatus() async {
    final QueryResult result = await _client.query(schema: getStaffStatusQuery);

    if (result.hasException) {
      throw Exception(result.exception.toString());
    }


    final Map<String, dynamic> data = result.data!['me'];
    return Staff.fromJson(data).status!;
  }
}
