import 'package:betting/data/base_service/api_response.dart';
import 'package:betting/data/model/res/infor_team/infor_team.dart';
import 'package:betting/data/model/res/matches/matches.dart';
import 'package:betting/data/repository/matches/matches_repo.dart';

import 'package:get/get.dart';
import 'package:intl/intl.dart';

class H2hMatchesRegionsController extends GetxController{
  var listTypeTable = ["MEETINGS","REAL MADRID","MANCHESTER CITY"];
  var indexCLick = 0.obs;
  var itemMatches = Matches().obs;
  MatchesRepo matchesRepo = MatchesRepo();
  var inforTeam = InforTeam().obs;
  var outputDateFormat = DateFormat('dd/mm/yyyy');
  var listMatChesH2h = <ItemsMatches>[].obs;
  var h2hMatch = <h2hMatches>[].obs;
  @override
  void onInit() {
    itemMatches.value = Get.arguments;
    getInforMatchesH2h(itemMatches.value.sId!);

    super.onInit();
  }
  List itemCount =[
    {
      'title':'Overal',
      'win':'6',
      'draws':'6',
      'win2':'7'
    },
    {
      'title':'Last 5',
      'win':'2',
      'draws':'2',
      'win2':'1'
    }
  ];

  getInforMatchesH2h(String matchesId){
    matchesRepo.inforMatches(matchesId).then((value) {
      if(value.state == Status.SUCCESS){
        inforTeam.value = value.object!;
        if(inforTeam.value.h2h?.h2h!= null){
          h2hMatch.value = inforTeam.value.h2h!.h2h!;
        }
        listTypeTable[1] = itemMatches.value.homeName!;
        listTypeTable[2] = itemMatches.value.awayName!;

      }
    },);

  }

  getListMatchesH2hTeam1(String teamId, date, String status) async{
      await matchesRepo.getListMatches(date, '', teamId, status).then((value) {
        if(value.state == Status.SUCCESS){
          listMatChesH2h.value = value.object!;
        }
      },);
      update();

  }


    }

