import 'package:sigap/src/features/auth/data/models/administrative_division.dart';
import 'package:sigap/src/features/map/data/repositories/administrative_data_service.dart';

class AdiminstrativeLocationRepository {
  final AdministrativeRepository _dataService = AdministrativeRepository();

  // Get divisions by type and parent ID
  Future<List<AdministrativeDivision>> getDivisionsByType(
    DivisionType type,
    String? parentId,
  ) async {
    switch (type) {
      case DivisionType.province:
        return await _dataService.getProvinces();
      case DivisionType.regency:
        return await _dataService.getRegenciesByProvince(parentId ?? '');
      case DivisionType.district:
        return await _dataService.getDistrictsByRegency(parentId ?? '');
      case DivisionType.village:
        return await _dataService.getVillagesByDistrict(parentId ?? '');
    }
  }

  // Search across all divisions
  Future<List<AdministrativeDivision>> searchLocations(String query) async {
    return await _dataService.searchLocations(query);
  }

  // Get the full location string for a division (for search results)
  Future<String> getFullLocationString(AdministrativeDivision division) async {
    return await _dataService.getFullLocationString(division);
  }

  // Get a division ID from its name and type (for breadcrumb navigation)
  Future<String?> getIdFromName(String name, DivisionType type) async {
    return await _dataService.getIdFromName(name, type);
  }
}
