import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';

part 'analytics_date_picker_event.dart';
part 'analytics_date_picker_state.dart';

class AnalyticsDatePickerBloc
    extends Bloc<AnalyticsDatePickerEvent, AnalyticsDatePickerState> {
  AnalyticsDatePickerBloc() : super(AnalyticsDatePickerState()) {
    on<UpdateAnalyticsDatePickerEvent>(_onUpdateAnalyticsDatePickerEvent);
  }

  void _onUpdateAnalyticsDatePickerEvent(
    UpdateAnalyticsDatePickerEvent event,
    Emitter<AnalyticsDatePickerState> emit,
  ) {
    emit(
      state.copyWith(
        monthlyDate: event.montlyDate ?? state.monthlyDate,
        yearlyDate: event.yearlyDate ?? state.yearlyDate,
      ),
    );
  }
}
