import '../core/api_client.dart';

class AdminService {
  final ApiClient _api;
  AdminService(this._api);

  Future<Map<String, dynamic>> getDoctors() async {
    final res = await _api.get('/api/admin/doctors');
    return res.data;
  }

  Future<Map<String, dynamic>> addDoctor(Map<String, dynamic> data) async {
    final res = await _api.post('/api/admin/doctors', data: data);
    return res.data;
  }

  Future<Map<String, dynamic>> updateDoctor(String id, Map<String, dynamic> data) async {
    final res = await _api.put('/api/admin/doctors/$id', data: data);
    return res.data;
  }

  Future<Map<String, dynamic>> toggleDoctorActive(String id) async {
    final res = await _api.put('/api/admin/doctors/$id/disable');
    return res.data;
  }

  Future<Map<String, dynamic>> deleteDoctor(String id) async {
    final res = await _api.delete('/api/admin/doctors/$id');
    return res.data;
  }

  Future<Map<String, dynamic>> getPatients({String? search, int page = 1, int pageSize = 20}) async {
    final query = <String, dynamic>{'page': page, 'pageSize': pageSize};
    if (search != null && search.isNotEmpty) query['search'] = search;
    final res = await _api.get('/api/admin/patients', queryParameters: query);
    return res.data;
  }
}
