import '../models/work_status_model.dart';
import '../models/work_supervisor_model.dart';

import '../app/constant.dart';
import '../models/work_type_model.dart';
import 'base_repository.dart';

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

  Future<List<WorkTypeModel>> getType() async {
    final url = Constant.baseUrl + "/v1/courier/mobile/homescreen/list_tipe";
    final resp = await get(service: url);
    List<WorkTypeModel> data;
    // print(resp['data']);
    if (resp['status'] == 'OK') {
      data = [];
      resp['data'].forEach((e) {
        final model = WorkTypeModel.fromJson(e);
        data.add(model);
      });
    } else {
      data = [];
    }

    return data;
  }

  Future<List<WorkStatusModel>> getStatus() async {
    final url = Constant.baseUrl + "v1/courier/mobile/homescreen/list_status";
    final resp = await get(service: url);
    List<WorkStatusModel> data;
    // print(resp['data']);
    if (resp['status'] == 'OK') {
      data = [];
      resp['data'].forEach((e) {
        final model = WorkStatusModel.fromJson(e);
        data.add(model);
      });
    } else {
      data = [];
    }

    return data;
  }

  Future<List<WorkSupervisorModel>> getSupervisor() async {
    final url =
        Constant.baseUrl + "v1/courier/mobile/homescreen/list_supervisor";
    final resp = await get(service: url);
    List<WorkSupervisorModel> data;
    // print(resp['data']);
    if (resp['status'] == 'OK') {
      data = [];
      resp['data'].forEach((e) {
        final model = WorkSupervisorModel.fromJson(e);
        data.add(model);
      });
    } else {
      data = [];
    }

    return data;
  }
}
