import 'package:queuedisplay/model/service_model.dart';

import '../app/constant.dart';
import '../model/display_counter_dedicated_modelv2.dart';
import 'base_repository.dart';

class ServiceRepository extends BaseRepository {
  ServiceRepository({required super.dio});
  Future<List<Layanan>> getData(String branchID) async {
    final url =
        "${Constant.baseUrl}antrian/AntrianCounterDedicated/list_counter/$branchID";
    final resp = await getService(service: url);

    final List<Layanan> listLayanan = List.empty(growable: true);

    resp['data']['records'].forEach((e) {
      final model = Layanan.fromJson(e);
      listLayanan.add(model);
    });
    return listLayanan;
  }

  // get data by Counter ID
  // Future<List<DisplayCounterDedicatedModel>> getDataByCounterID(List<int> arrCounterID) async {
  Future<List<DisplayCounterDedicatedModelV2>> getDataByCounterID(
      List<int> arrCounterID, String branchID) async {
    final url =
        "${Constant.baseUrl}antrian/AntrianCounterDedicated/get_antrian";
    final param = {"arr_counter": arrCounterID, "branchID": branchID};

    // print(param);
    final resp = await post(service: url, param: param);
    // print(resp);
    final List<DisplayCounterDedicatedModelV2> listDisplay =
        List.empty(growable: true);
    resp['data'].forEach((e) {
      final model = DisplayCounterDedicatedModelV2.fromJson(e);
      listDisplay.add(model);
    });

    // DisplayCounterDedicatedModel.fromJson(resp['data']);
    return listDisplay;
  }
}
