import 'package:flutter/foundation.dart' show ChangeNotifier;

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

class AppointmentViaRegionViewmodel extends ChangeNotifier {
  String? selectedRegionId;
  String? selectedFacilityType;
  AppointmentViaRegionState bottomSheetState =
      AppointmentViaRegionState.REGION_SELECTION;

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

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

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

  void handleBackPress() {
    switch (bottomSheetState) {
      case AppointmentViaRegionState.REGION_SELECTION:
        // Do nothing or exit the bottom sheet
        break;
      case AppointmentViaRegionState.TYPE_SELECTION:
        setBottomSheetState(AppointmentViaRegionState.REGION_SELECTION);
        setSelectedRegionId(null);
        break;
      case AppointmentViaRegionState.HOSPITAL_SELECTION:
        setBottomSheetState(AppointmentViaRegionState.TYPE_SELECTION);
        break;

      // case AppointmentViaRegionState.HOSPITAL_SELECTION:
      // case AppointmentViaRegionState.CLINIC_SELECTION:
      //   setBottomSheetState(AppointmentViaRegionState.TYPE_SELECTION);
      //   setFacility(null);
      //   break;
      // case AppointmentViaRegionState.DOCTOR_SELECTION:
      //   if (selectedFacilityType == 'Hospital') {
      //     setBottomSheetState(AppointmentViaRegionState.HOSPITAL_SELECTION);
      //   } else if (selectedFacilityType == 'Medical Center') {
      //     setBottomSheetState(AppointmentViaRegionState.CLINIC_SELECTION);
      //   }
      //   break;
      default:
    }
  }

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