import 'package:bloc/bloc.dart';


// Events
abstract class ScanHistoryDetailEvent  {
  List<Object?> get props => [];
}

class LoadScanHistoryDetail extends ScanHistoryDetailEvent {
  final String passId;
  LoadScanHistoryDetail(this.passId);

  @override
  List<Object?> get props => [passId];
}

// States
abstract class ScanHistoryDetailState  {
  @override
  List<Object?> get props => [];
}

class ScanHistoryDetailInitial extends ScanHistoryDetailState {}

class ScanHistoryDetailLoading extends ScanHistoryDetailState {}

class ScanHistoryDetailLoaded extends ScanHistoryDetailState {
  final Map<String, dynamic> data;
  ScanHistoryDetailLoaded(this.data);

  @override
  List<Object?> get props => [data];
}

class ScanHistoryDetailError extends ScanHistoryDetailState {
  final String message;
  ScanHistoryDetailError(this.message);

  @override
  List<Object?> get props => [message];
}

// Bloc
class ScanHistoryDetailBloc extends Bloc<ScanHistoryDetailEvent, ScanHistoryDetailState> {
  ScanHistoryDetailBloc() : super(ScanHistoryDetailInitial()) {
    on<LoadScanHistoryDetail>(_onLoadPassDetail);
  }

  Future<void> _onLoadPassDetail(LoadScanHistoryDetail event, Emitter<ScanHistoryDetailState> emit) async {
    try {
      emit(ScanHistoryDetailLoading());

      // Placeholder: Replace with repository call later
      await Future.delayed(const Duration(milliseconds: 200));

      final dummy = {
        'cardType': 'Selective',
        'validity': 'Valid',
        'customerName': 'Lila Heart',
        'phone': '(+971) 050 421 4456',
        'email': 'ninarokz21@gmail.com',
        'city': 'The Enchanted Garden',
        'attractionName': 'The Enchanted Garden',
      };

      emit(ScanHistoryDetailLoaded(dummy));
    } catch (e) {
      emit(ScanHistoryDetailError(e.toString()));
    }
  }
}
