import '../app/constant.dart';
import '../models/auth_model.dart';
import '../models/response_list_branch_model.dart';
import '../models/response_save_pengantaran_hasil_model.dart';
import '../models/response_search_pengantaran_hasil_model.dart';
import 'base_repository.dart';

class DummyNoLabDokter {
  final String noLab;
  final int idLab;
  final String nama;
  final String alamatPengantaran;

  DummyNoLabDokter(
    this.noLab, 
    this.idLab,
    this.nama,
    this.alamatPengantaran
  );
}

class InputLainLainRepository extends BaseRepository {
  InputLainLainRepository({required super.dio});

  List<DummyNoLabDokter> result = [
    DummyNoLabDokter("110378", 1, "Agas", "Jl wora wari"),
    DummyNoLabDokter("110390", 2, "Indy Ratna", "Jl moestopo"),
    DummyNoLabDokter("140390", 3, "Jarot", "Jl pahlawan no 1"),
    DummyNoLabDokter("190390", 4, "Deny", "Jl Ir Soekarno"),
    DummyNoLabDokter("119090", 5, "Said Hasan", "Jl mawar no 04"),
    DummyNoLabDokter("110391", 1, "Jarot P", "Jl nawangsih no 07"),
    DummyNoLabDokter("110399", 2, "Joko S", "Jl Pegangsaan no 04"),
  ];

  Future<List<ResponseListBranchModel>> loadListCabangInputLainLain() async {
    final service =
        "${Constant.baseUrl}v1/courier/mobile/homescreen/list_branch";
    final resp = await get(service: service);

    final result = List<ResponseListBranchModel>.empty(growable: true);
    if (resp['data'] != null) {
      resp['data'].forEach((e) {
        final model = ResponseListBranchModel.fromJson(e);
        result.add(model);
      });
    }

    return result;
  }

  Future<ResponseSavePengantaranHasilModel> inputLainLainSave({
    required String courierID,
    required String tipeID,
    required String branchID,
    required String branchCode,
    required String pickup,
    required String destination,
    required String note
  }) async {
    final param = {
      "id": courierID,
      "tipeid": tipeID,
      "branchid": branchID,
      "branchcode": branchCode,
      "pickup": pickup,
      "destination":destination,
      "note": note
    };

    print("param : $param");

    final service = "${Constant.baseUrl}v1/courier/mobile/inputcourier/add/?id=$courierID&tipeid=$tipeID&branchid=$branchID&branchcode=$branchCode&pickup=$pickup&destination=$destination&note=$note";
    final resp = await post(param: param, service: service);
    return ResponseSavePengantaranHasilModel.fromJson(resp);
  }
}
