6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit ebf85344
Changed files
.../lib/booking_details/bloc/booking_details_bloc.dart | 17 +++++++++++++++++ .../components/booking_details_bottom_sheet.dart | 3 +-- comwell_key_app/lib/check_out/bloc/check_out_cubit.dart | 2 ++ comwell_key_app/lib/check_out/bloc/check_out_state.dart | 2 +- .../check_out/components/checkout_itemized_bill.dart | 4 ++-- 5 files changed, 23 insertions(+), 5 deletions(-)
Diff
diff --git a/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart b/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
index c205a9a9..1c89d08e 100644
--- a/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
+++ b/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
@@ -96,6 +96,7 @@ class BookingDetailsBloc
final bookingDetails =
await profileRepository.getBookingDetails(bookingId);
booking = bookingDetails;
+ print("booking in booking details bloc: ${booking}");
emit(state.copyWith(status: BookingDetailsStatus.main, isLoading: false));
return bookingDetails;
@@ -168,6 +169,22 @@ class BookingDetailsBloc
DateTime getCheckInTime() => booking.startDate.add(const Duration(hours: 15));
+ bool get canCheckOut {
+ final now = DateTime.now();
+ final today = DateTime(now.year, now.month, now.day);
+ final checkInDate = DateTime(booking.startDate.year, booking.startDate.month, booking.startDate.day);
+ final checkOutDate = DateTime(booking.endDate.year, booking.endDate.month, booking.endDate.day);
+
+ if (checkInDate == checkOutDate) {
+ return false;
+ }
+
+ print("checkOutDate: ${checkOutDate.isAfter(today)}");
+ print("today: $today");
+
+ return checkOutDate.isBefore(today);
+ }
+
DateTime getCheckOutTime() => booking.endDate.add(const Duration(hours: 5));
bool get isHouseKeepingTime =>
diff --git a/comwell_key_app/lib/booking_details/components/booking_details_bottom_sheet.dart b/comwell_key_app/lib/booking_details/components/booking_details_bottom_sheet.dart
index 6c6c4a33..ca32af6d 100644
--- a/comwell_key_app/lib/booking_details/components/booking_details_bottom_sheet.dart
+++ b/comwell_key_app/lib/booking_details/components/booking_details_bottom_sheet.dart
@@ -24,8 +24,7 @@ class BookingDetailsBottomSheet extends StatelessWidget {
return BottomSheetWidget(
widgetChildren: [
const SizedBox(height: 16),
- // && cubit.getCheckOutTime().isBefore(DateTime.now())
- cubit.booking.reservationStatus == ReservationStatus.checkedin
+ cubit.booking.reservationStatus == ReservationStatus.checkedin && cubit.canCheckOut
? const Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: CheckOutButton(),
diff --git a/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart b/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
index 7eb52a32..05c9a5fe 100644
--- a/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
+++ b/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
@@ -40,6 +40,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
} catch (e) {
// Todo handle error
+ emit(state.processingStateUpdated(CheckoutProcessingStateError()));
}
}
@@ -145,6 +146,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
final bookingPrice = booking.balance?.toInt();
+
final amount = Amount(
value: bookingPrice!,
currency: currency,
diff --git a/comwell_key_app/lib/check_out/bloc/check_out_state.dart b/comwell_key_app/lib/check_out/bloc/check_out_state.dart
index f712298c..dddda4a5 100644
--- a/comwell_key_app/lib/check_out/bloc/check_out_state.dart
+++ b/comwell_key_app/lib/check_out/bloc/check_out_state.dart
@@ -51,7 +51,7 @@ class CheckoutState extends Equatable {
isTermsAccepted = false,
page = CheckoutPage.confirmation,
showTermsError = false,
- clubPoints = 500,
+ clubPoints = 0,
paymentMethod = CheckoutPaymentMethod.creditCard,
processingState = CheckoutProcessingStateNotStarted(),
applyClubPoints = false;
diff --git a/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart b/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart
index 71f4785a..e0609efc 100644
--- a/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart
+++ b/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart
@@ -34,14 +34,14 @@ class CheckoutItemizedBill extends StatelessWidget {
Row(
children: [
Text(
- "${cubit.state.totalPriceBeforeDiscount.toInt()}",
+ "${cubit.state.totalPriceBeforeDiscount}",
style: const TextStyle(
decoration: TextDecoration.lineThrough,
decorationColor: colorDivider,
color: colorDivider),
),
const SizedBox(width: 4),
- Text("${cubit.state.totalPriceAfterDiscount.toInt()}"),
+ Text("${cubit.state.totalPriceAfterDiscount - cubit.state.clubPoints}"),
],
)
else