import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gap/gap.dart';
import 'package:krow/core/presentation/widgets/ui_kit/kw_button.dart';
import 'package:krow/features/profile/schedule/domain/bloc/schedule_bloc.dart';

class CalendarButtonSectionWidget extends StatelessWidget {
  const CalendarButtonSectionWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        const Gap(16),
        BlocSelector<ScheduleBloc, ScheduleState, bool>(
          selector: (state) =>
              state.tempSchedules.firstOrNull?.isViableForSaving ?? false,
          builder: (context, isEnabled) {
            return KwButton.primary(
              label: 'save_slots'.tr(),
              disabled: !isEnabled,
              onPressed: () {
                BlocProvider.of<ScheduleBloc>(context)
                    .add(const ScheduleEventSave());
              },
            );
          },
        ),
        const Gap(12),
        KwButton.outlinedPrimary(
          label: 'cancel'.tr(),
          onPressed: () {
            BlocProvider.of<ScheduleBloc>(context)
                .add(const ScheduleEventCancel());
          },
        )
      ],
    );
  }
}
