import 'package:flutter/foundation.dart' show ChangeNotifier;
import 'package:hmg_patient_app_new/core/app_state.dart' show AppState;
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/doctor_list_api_response.dart';
import 'package:hmg_patient_app_new/presentation/book_appointment/select_clinic_page.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart';

enum AppointmentViaRegionState {
  REGION_SELECTION,
  TYPE_SELECTION,
  HOSPITAL_SELECTION,
  CLINIC_SELECTION,
  DOCTOR_SELECTION
}

class AppointmentViaRegionViewmodel extends ChangeNotifier {
  String? selectedRegionId;
  String? selectedFacilityType;
  PatientDoctorAppointmentList? selectedHospital;
  final NavigationService navigationService;
  AppointmentViaRegionState bottomSheetState =
      AppointmentViaRegionState.REGION_SELECTION;
  final AppState appState;

  AppointmentViaRegionViewmodel({required this.navigationService,required this.appState});

  void setSelectedRegionId(String? regionId) {
    selectedRegionId = regionId;
    notifyListeners();
  }

  void setFacility(String? facility) {
    selectedFacilityType = facility;
    notifyListeners();
  }

  void setBottomSheetState(AppointmentViaRegionState state) {
    bottomSheetState = state;
    notifyListeners();
  }

  void handleLastStep(){
    navigationService.pop();
    navigationService.push(CustomPageRoute(
      page: SelectClinicPage(),
    ),);
  }

  void handleBackPress() {
    switch (bottomSheetState) {
      case AppointmentViaRegionState.REGION_SELECTION:
        break;
      case AppointmentViaRegionState.TYPE_SELECTION:
        setBottomSheetState(AppointmentViaRegionState.REGION_SELECTION);
        setSelectedRegionId(null);
        break;
      case AppointmentViaRegionState.HOSPITAL_SELECTION:
        setBottomSheetState(AppointmentViaRegionState.TYPE_SELECTION);
        break;
      default:
    }
  }

  void flush() {
    setSelectedRegionId(null);
    setFacility(null);
    setBottomSheetState(AppointmentViaRegionState.REGION_SELECTION);
  }

  void setHospitalModel(PatientDoctorAppointmentList? hospital) {
    selectedHospital = hospital;
  }

  bool get isArabic => appState.isArabic();
}
