import 'package:comwell_key_app/check_out/bloc/check_out_cubit.dart';
import 'package:comwell_key_app/common/template_pages/payment_page_template.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

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

  @override
  Widget build(BuildContext context) {
    final cubit = context.read<CheckoutCubit>();
    final addOnItems = cubit.state.items;
    final applyClubPoints = cubit.state.applyClubPoints;
    final totalPriceBeforeDiscount = cubit.state.totalPriceBeforeDiscount;
    final totalPriceAfterDiscount = cubit.state.totalPriceAfterDiscount;
    final trimmedBalance = cubit.trimmedBalance;
    final clubPoints = cubit.state.clubPoints;
    final isTermsAccepted = cubit.state.isTermsAccepted;
    final onAcceptTermsChanged = cubit.onAcceptTermsChanged;
    final showError = cubit.state.showTermsError;
    final onShowTermsAndConditions = cubit.showTermsAndConditions;
    final onApplyClubPointsChanged = cubit.onApplyClubPointsClicked;

    return PaymentPageTemplate(
        addOnItems: addOnItems,
        applyClubPoints: applyClubPoints,
        totalPriceBeforeDiscount: totalPriceBeforeDiscount,
        totalPriceAfterDiscount: totalPriceAfterDiscount,
        trimmedBalance: trimmedBalance,
        clubPoints: clubPoints,
        isTermsAccepted: isTermsAccepted,
        userEmail: cubit.booking.bookerLastName,
        onAcceptTermsChanged: onAcceptTermsChanged,
        showError: showError,
        onShowTermsAndConditions: onShowTermsAndConditions,
        onApplyClubPointsChanged: onApplyClubPointsChanged);
  }
}