6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit db8c77e5

AuthorEdmir Suljic<esu@dwarf.dk>
Date2025-08-15 10:02:53 +0200
Almost finished feature. Need to figure out some edge cases that are left

Changed files

comwell_key_app/assets/translations/en-US.json     |  2 +-
 .../check_out/models/check_out_item.g.dart         | 22 -----------
 .../.generated/services/models/booking_dto.g.dart  | 17 +++++++-
 .../booking_details/bloc/booking_details_bloc.dart |  7 +---
 .../bloc/booking_details_state.dart                |  2 +-
 .../components/booking_details_bottom_sheet.dart   |  4 +-
 .../lib/check_out/bloc/check_out_cubit.dart        | 41 ++++++++++++--------
 .../lib/check_out/bloc/check_out_state.dart        | 35 ++++++++++-------
 .../components/check_out_bill_list_item.dart       |  4 +-
 .../components/check_out_payment_card.dart         |  2 +-
 .../components/checkout_itemized_bill.dart         |  6 +--
 .../lib/check_out/models/check_out_item.dart       | 26 -------------
 .../pages/check_out_confirmation_page.dart         | 45 ++++++++++++++++++++++
 .../pages/check_out_confirmation_pages.dart        | 45 ----------------------
 .../lib/check_out/pages/check_out_error_page.dart  |  7 +---
 .../lib/check_out/pages/check_out_page.dart        |  2 +-
 .../check_out/pages/check_out_processing_page.dart |  2 +-
 comwell_key_app/lib/overview/models/booking.dart   |  7 ++--
 .../overview/repository/overview_repository.dart   |  5 +--
 .../payment_cards/bloc/payment_cards_cubit.dart    |  2 +-
 .../pregistration/pregistration_repository.dart    |  5 ++-
 comwell_key_app/lib/services/api.dart              |  3 +-
 .../lib/services/mappers/addon_item_mapper.dart    |  8 ++--
 .../lib/services/mappers/booking_mapper.dart       |  2 -
 .../lib/services/models/booking_dto.dart           | 30 ++++++++-------
 25 files changed, 154 insertions(+), 177 deletions(-)

Diff

diff --git a/comwell_key_app/assets/translations/en-US.json b/comwell_key_app/assets/translations/en-US.json
index eb40af8a..eb61f550 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -8,7 +8,7 @@
"generic_apple_pay": "Apple Pay",
"generic_google_pay": "Google Pay",
"generic_error": "An error occurred. Please try again later.",
- "welcome_headline": "Welcome at Comwell Hotels",
+ "lcome_headline": "Welcome at Comwell Hotels",
"welcome_button": "Continue",
"welcome_error": "An error occurred. Please try again later.",
"room_key": "Room key",
diff --git a/comwell_key_app/lib/.generated/check_out/models/check_out_item.g.dart b/comwell_key_app/lib/.generated/check_out/models/check_out_item.g.dart
deleted file mode 100644
index 4eff251f..00000000
--- a/comwell_key_app/lib/.generated/check_out/models/check_out_item.g.dart
+++ /dev/null
@@ -1,22 +0,0 @@
-// GENERATED CODE - DO NOT MODIFY BY HAND
-
-part of '../../../check_out/models/check_out_item.dart';
-
-// **************************************************************************
-// JsonSerializableGenerator
-// **************************************************************************
-
-CheckoutAddonItem _$CheckoutAddonItemFromJson(Map json) => CheckoutAddonItem(
- json['code'] as String,
- json['description'] as String,
- (json['quantity'] as num).toInt(),
- (json['price'] as num).toInt(),
- );
-
-Map<String, dynamic> _$CheckoutAddonItemToJson(CheckoutAddonItem instance) =>
- <String, dynamic>{
- 'code': instance.code,
- 'description': instance.description,
- 'quantity': instance.quantity,
- 'price': instance.price,
- };
diff --git a/comwell_key_app/lib/.generated/services/models/booking_dto.g.dart b/comwell_key_app/lib/.generated/services/models/booking_dto.g.dart
index 84facacd..4b118d0e 100644
--- a/comwell_key_app/lib/.generated/services/models/booking_dto.g.dart
+++ b/comwell_key_app/lib/.generated/services/models/booking_dto.g.dart
@@ -27,7 +27,7 @@ BookingDTO _$BookingDTOFromJson(Map json) => BookingDTO(
maskedCardNumber: json['maskedCardNumber'] as String?,
addOnItems: (json['addOnItems'] as List<dynamic>?)
?.map((e) =>
- CheckoutAddonItem.fromJson(Map<String, dynamic>.from(e as Map)))
+ BookingAddonItem.fromJson(Map<String, dynamic>.from(e as Map)))
.toList(),
);
@@ -53,3 +53,18 @@ Map<String, dynamic> _$BookingDTOToJson(BookingDTO instance) =>
'maskedCardNumber': instance.maskedCardNumber,
'addOnItems': instance.addOnItems?.map((e) => e.toJson()).toList(),
};
+
+BookingAddonItem _$BookingAddonItemFromJson(Map json) => BookingAddonItem(
+ json['code'] as String,
+ json['description'] as String,
+ (json['quantity'] as num).toInt(),
+ (json['price'] as num).toInt(),
+ );
+
+Map<String, dynamic> _$BookingAddonItemToJson(BookingAddonItem instance) =>
+ <String, dynamic>{
+ 'code': instance.code,
+ 'description': instance.description,
+ 'quantity': instance.quantity,
+ 'price': instance.price,
+ };
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 38c4533d..4d2c9160 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
@@ -24,14 +24,12 @@ class BookingDetailsBloc
late Booking booking;
late User user;
Timer? _timer;
- Timer? _timer;
final BookingDetailsRepository bookingDetailsRepository;
final ProfileRepository profileRepository;
final SeosRepository seosRepository = locator<SeosRepository>();
Duration _remainingTime = Duration.zero;
final UpSalesRepository upSaleRepository;
-
BookingDetailsBloc(
this.booking, {
required this.bookingDetailsRepository,
@@ -47,9 +45,8 @@ class BookingDetailsBloc
add(CheckMobileKeys());
add(GetBookingDetailsEvent(booking.confirmationId));
add(GetUserEvent());
- add(GetUpSalesEvent());
add(UpdateRemainingEvent(getCheckInTime().difference(DateTime.now())));
- add(GetUpSalesEvent(upSales));
+ add(GetUpSalesEvent());
} catch (e, st) {
if (kDebugMode) print("err=$e, $st");
emit(state.setupError());
@@ -64,6 +61,7 @@ class BookingDetailsBloc
try {
await getUpSales(emit);
emit(state.main());
+
} catch (e) {
if (kDebugMode) print("err=$e");
emit(state.setupError());
@@ -207,7 +205,6 @@ class BookingDetailsBloc
DateTime getCheckOutTime() => booking.endDate.add(const Duration(hours: 5));
-
bool get isHouseKeepingTime =>
booking.endDate.difference(booking.startDate).inDays >= 2;
diff --git a/comwell_key_app/lib/booking_details/bloc/booking_details_state.dart b/comwell_key_app/lib/booking_details/bloc/booking_details_state.dart
index 6848e6c2..4dce73f8 100644
--- a/comwell_key_app/lib/booking_details/bloc/booking_details_state.dart
+++ b/comwell_key_app/lib/booking_details/bloc/booking_details_state.dart
@@ -43,7 +43,7 @@ class BookingDetailsState extends Equatable {
copyWith(status: BookingDetailsStatus.guestsUpdated, guests: guests);
BookingDetailsState loading() => copyWith(status: BookingDetailsStatus.loading, isLoading: true);
BookingDetailsState updateRemainingTime(Duration remainingTime) => copyWith(remainingTime: remainingTime);
- BookingDetailsState main() => copyWith(status: BookingDetailsStatus.main);
+ BookingDetailsState main() => copyWith(status: BookingDetailsStatus.main, isLoading: false);
BookingDetailsState getUpSales(UpSales upSales) => copyWith(upSales: upSales);
@override
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 3075378b..b8abcf5d 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,8 @@ class BookingDetailsBottomSheet extends StatelessWidget {
return BottomSheetWidget(
widgetChildren: [
const SizedBox(height: 16),
- cubit.booking.reservationStatus == ReservationStatus.checkedin &&
- cubit.getCheckOutTime().isBefore(DateTime.now())
+ cubit.booking.reservationStatus == ReservationStatus.checkedin
+ // TODO Uncomment this when feature is ready && cubit.getCheckOutTime().isBefore(DateTime.now())
? 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 915cf6d7..60f0dd9b 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
@@ -1,9 +1,7 @@
import 'package:adyen_checkout/adyen_checkout.dart';
import 'package:bloc/bloc.dart';
-import 'package:comwell_key_app/booking_details/booking_details_repository.dart';
import 'package:comwell_key_app/check_out/bloc/check_out_state.dart';
import 'package:comwell_key_app/check_out/check_out_repository.dart';
-import 'package:comwell_key_app/check_out/models/check_out_item.dart';
import 'package:comwell_key_app/check_out/models/checkout_processing_state.dart';
import 'package:comwell_key_app/check_out/models/payment_method.dart';
import 'package:comwell_key_app/check_out/pages/check_out_page.dart';
@@ -12,6 +10,7 @@ import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/pregistration/pregistration_repository.dart';
import 'package:comwell_key_app/profile/profile_repository.dart';
import 'package:comwell_key_app/profile/utils/urls.dart';
+import 'package:comwell_key_app/services/models/booking_dto.dart';
import 'package:comwell_key_app/tracking/comwell_tracking.dart';
import 'package:comwell_key_app/tracking/models/analytics_event_item.dart';
import 'package:comwell_key_app/utils/locator.dart';
@@ -32,15 +31,13 @@ class CheckoutCubit extends Cubit<CheckoutState> {
CheckoutPage.fromIndex(pageController.page?.toInt() ?? 0);
CheckoutCubit(this.booking, this.checkOutRepository)
- : super(CheckoutState.initial());
+ : super(CheckoutState.initial(booking.balance ?? 0));
void init() async {
try {
final user = await profileRepository.fetchProfileSettings();
//emit(state.clubPointsFetched(user.points));
setItems(booking.addOnItems ?? []);
- print("qqq user ${state.items}");
-
} catch (e) {
emit(state.processingStateUpdated(
CheckoutProcessingStateError(message: "Error fetching club points")));
@@ -55,8 +52,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
}
}
- void setItems(Iterable<CheckoutAddonItem> items) {
-
+ void setItems(Iterable<BookingAddonItem> items) {
emit(state.itemsUpdated(items));
}
@@ -108,7 +104,9 @@ class CheckoutCubit extends Cubit<CheckoutState> {
if (!state.isTermsAccepted && (booking.balance ?? 0.0) > 0.0) {
emit(state.showAcceptTermsError());
} else {
- if (booking.balance == 0) {
+ //Check if the balance is 0 or if the club points are equal to the balance
+ if (booking.balance == 0 ||
+ (state.applyClubPoints && state.clubPoints == booking.balance)) {
processCheckoutWithoutPaying();
} else {
processCheckout();
@@ -176,13 +174,15 @@ class CheckoutCubit extends Cubit<CheckoutState> {
Future<void> createSession() async {
try {
- final bookingPrice = booking.balance?.toInt();
+ final bookingPrice = totalPriceAfterDiscount;
final amount = Amount(
- value: bookingPrice!,
+ value: bookingPrice,
currency: currency,
);
- final paymentConfigurations = await preregistrationRepository
- .sessionCheckout(amount, booking.confirmationId);
+ print("qqq applyClubPoints ${state.applyClubPoints}");
+ final paymentConfigurations =
+ await preregistrationRepository.sessionCheckout(
+ amount, booking.confirmationId, state.applyClubPoints);
emit(state.processingStateUpdated(CheckoutProcessingStateSessionReceived(
paymentConfigurations: paymentConfigurations)));
await Future<void>.delayed(const Duration(milliseconds: 4000));
@@ -200,6 +200,8 @@ class CheckoutCubit extends Cubit<CheckoutState> {
emit(state
.processingStateUpdated(CheckoutProcessingPaymentStateSuccess()));
emit(state.processingStateUpdated(CheckoutProcessingStateConfirmed()));
+ //This is here to add time so that the payment is represented in the BookingDetails
+ await Future<void>.delayed(const Duration(milliseconds: 2000));
await checkOut();
break;
@@ -218,14 +220,21 @@ class CheckoutCubit extends Cubit<CheckoutState> {
launchUrl(Uri.parse(ComwellUrls.termsAndConditions));
}
+ int get totalPriceAfterDiscount {
+ if (state.applyClubPoints) {
+ return trimmedBalance - state.clubPoints;
+ }
+ return trimmedBalance;
+ }
+
//Removes the decimal point from the balance if it is .0
- String get trimmedBalance {
+ int get trimmedBalance {
final balance = booking.balance;
- if (balance == null) return '';
+ if (balance == null) return 0;
if (balance == balance.toInt()) {
- return balance.toInt().toString();
+ return balance.toInt();
} else {
- return balance.toStringAsFixed(2);
+ return balance.toInt();
}
}
}
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 039cfb94..3cac4821 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
@@ -1,11 +1,12 @@
-import 'package:comwell_key_app/check_out/models/check_out_item.dart';
+
import 'package:comwell_key_app/check_out/models/checkout_processing_state.dart';
import 'package:comwell_key_app/check_out/models/payment_method.dart';
+import 'package:comwell_key_app/services/models/booking_dto.dart';
import 'package:comwell_key_app/check_out/pages/check_out_page.dart';
import 'package:equatable/equatable.dart';
class CheckoutState extends Equatable {
- final Iterable<CheckoutAddonItem> _items;
+ final Iterable<BookingAddonItem> _items;
final bool isTermsAccepted;
final bool applyClubPoints;
final int clubPoints;
@@ -13,23 +14,25 @@ class CheckoutState extends Equatable {
final CheckoutPage page;
final CheckoutPaymentMethod? paymentMethod;
final bool showTermsError;
+ final num bookingBalance;
int get totalPriceBeforeDiscount => _sumOfList(_items);
int get totalPriceAfterDiscount => _sumOfList(items);
+
int get totalPrice => _sumOfList(_items);
- Iterable<CheckoutAddonItem> get items {
+ Iterable<BookingAddonItem> get items {
if (applyClubPoints) {
- return [..._items, CheckoutAddonItem("Rabat", "Rabat", clubPoints * -1, clubPoints * -1)];
+ return [..._items, BookingAddonItem("Rabat", "Rabat", clubPoints * -1, clubPoints * -1)];
}
return _items;
}
- int _sumOfList(Iterable<CheckoutAddonItem> list) {
+ int _sumOfList(Iterable<BookingAddonItem> list) {
if (list.isEmpty) return 0;
return list
.map((item) => item.price)
@@ -37,7 +40,7 @@ class CheckoutState extends Equatable {
}
const CheckoutState({
- required Iterable<CheckoutAddonItem> items,
+ required Iterable<BookingAddonItem> items,
required this.isTermsAccepted,
required this.page,
required this.showTermsError,
@@ -45,21 +48,23 @@ class CheckoutState extends Equatable {
required this.applyClubPoints,
required this.processingState,
this.paymentMethod,
+ required this.bookingBalance,
}) : _items = items;
- CheckoutState.initial()
+ CheckoutState.initial(num bookingBalance)
: _items = [],
isTermsAccepted = false,
page = CheckoutPage.confirmation,
showTermsError = false,
- clubPoints = 10,
+ clubPoints = 500,
paymentMethod = CheckoutPaymentMethod.creditCard,
processingState = CheckoutProcessingStateNotStarted(),
- applyClubPoints = false;
+ applyClubPoints = false,
+ bookingBalance = bookingBalance;
- CheckoutState itemsUpdated(Iterable<CheckoutAddonItem> items) {
+ CheckoutState itemsUpdated(Iterable<BookingAddonItem> items) {
- final newItems = <CheckoutAddonItem>[];
+ final newItems = <BookingAddonItem>[];
for (var item in items) {
newItems.add(item.copyWith(price: item.price * item.quantity));
}
@@ -90,7 +95,7 @@ class CheckoutState extends Equatable {
CheckoutState _copyWith({
- Iterable<CheckoutAddonItem>? items,
+ Iterable<BookingAddonItem>? items,
bool? termsAccepted,
bool? applyClubPoints,
CheckoutProcessingState? updateProcessingState,
@@ -98,7 +103,8 @@ class CheckoutState extends Equatable {
CheckoutPaymentMethod? paymentMethod,
int? clubPoints,
bool? showTermsError,
- }) {
+ num? bookingBalance,
+ }) {
return CheckoutState(
items: items ?? _items,
page: page ?? this.page,
@@ -107,7 +113,8 @@ class CheckoutState extends Equatable {
processingState: updateProcessingState ?? processingState,
isTermsAccepted: termsAccepted ?? isTermsAccepted,
applyClubPoints: applyClubPoints ?? this.applyClubPoints,
- paymentMethod: paymentMethod ?? this.paymentMethod);
+ paymentMethod: paymentMethod ?? this.paymentMethod,
+ bookingBalance: bookingBalance ?? this.bookingBalance);
}
@override
diff --git a/comwell_key_app/lib/check_out/components/check_out_bill_list_item.dart b/comwell_key_app/lib/check_out/components/check_out_bill_list_item.dart
index 0d651ac1..1d1722fb 100644
--- a/comwell_key_app/lib/check_out/components/check_out_bill_list_item.dart
+++ b/comwell_key_app/lib/check_out/components/check_out_bill_list_item.dart
@@ -1,8 +1,8 @@
-import 'package:comwell_key_app/check_out/models/check_out_item.dart';
+ import 'package:comwell_key_app/services/models/booking_dto.dart';
import 'package:flutter/material.dart';
class CheckOutBillListItem extends StatelessWidget {
- final CheckoutAddonItem item;
+ final BookingAddonItem item;
const CheckOutBillListItem({super.key, required this.item});
diff --git a/comwell_key_app/lib/check_out/components/check_out_payment_card.dart b/comwell_key_app/lib/check_out/components/check_out_payment_card.dart
index 2d926d20..a7abd319 100644
--- a/comwell_key_app/lib/check_out/components/check_out_payment_card.dart
+++ b/comwell_key_app/lib/check_out/components/check_out_payment_card.dart
@@ -31,7 +31,7 @@ class CheckOutPaymentCard extends StatelessWidget {
style: theme.textTheme.bodySmall?.copyWith(color: colorBlack[65]),
),
const SizedBox(height: 4),
- Text("checkout_page_payment_price".tr(args: [(cubit.trimmedBalance)]),
+ Text("checkout_page_payment_price".tr(args: [(cubit.trimmedBalance.toString())]),
style: theme.textTheme.displaySmall),
],
),
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 3fa9025c..f4001d77 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
@@ -13,8 +13,6 @@ class CheckoutItemizedBill extends StatelessWidget {
final cubit = context.read<CheckoutCubit>();
final items = cubit.state.items;
- print("discount ${cubit.state.totalPriceBeforeDiscount}");
- print("discount ${cubit.state.totalPriceAfterDiscount}");
return Column(
children: [
...items.map((item) => Column(
@@ -41,11 +39,11 @@ class CheckoutItemizedBill extends StatelessWidget {
color: colorDivider),
),
const SizedBox(width: 4),
- Text("${cubit.state.totalPriceAfterDiscount}"),
+ Text("${cubit.totalPriceAfterDiscount}"),
],
)
else
- Text(cubit.trimmedBalance),
+ Text(cubit.trimmedBalance.toString()),
],
),
const SizedBox(height: 12),
diff --git a/comwell_key_app/lib/check_out/models/check_out_item.dart b/comwell_key_app/lib/check_out/models/check_out_item.dart
deleted file mode 100644
index 8a00d0f6..00000000
--- a/comwell_key_app/lib/check_out/models/check_out_item.dart
+++ /dev/null
@@ -1,26 +0,0 @@
-import 'package:json_annotation/json_annotation.dart';
-
-part '../../.generated/check_out/models/check_out_item.g.dart';
-
-@JsonSerializable()
-class CheckoutAddonItem {
- final String code;
- final String description;
- final int quantity;
- final int price;
-
- CheckoutAddonItem(this.code, this.description, this.quantity, this.price);
-
- @override
- String toString() {
- return 'AddOnItem{code: $code, description: $description, quantity: $quantity, price: $price}';
- }
-
- factory CheckoutAddonItem.fromJson(Map<String, dynamic> json) => _$CheckoutAddonItemFromJson(json);
-
- Map<String, dynamic> toJson() => _$CheckoutAddonItemToJson(this);
-
- CheckoutAddonItem copyWith({int? quantity, int? price}) {
- return CheckoutAddonItem(code, description, quantity ?? this.quantity, price ?? this.price);
- }
-}
\ No newline at end of file
diff --git a/comwell_key_app/lib/check_out/pages/check_out_confirmation_page.dart b/comwell_key_app/lib/check_out/pages/check_out_confirmation_page.dart
new file mode 100644
index 00000000..cc1c5090
--- /dev/null
+++ b/comwell_key_app/lib/check_out/pages/check_out_confirmation_page.dart
@@ -0,0 +1,45 @@
+import 'package:comwell_key_app/check_out/components/check_out_payment_card.dart';
+import 'package:comwell_key_app/themes/light_theme.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flutter/material.dart';
+
+class CheckOutConfirmationPage extends StatelessWidget {
+ const CheckOutConfirmationPage({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const SizedBox(height: 40),
+ Text(
+ "checkout_page_confirmation_title".tr(),
+ style: Theme.of(context).textTheme.headlineLarge,
+ ),
+ const SizedBox(height: 18),
+ Text(
+ style: Theme.of(context)
+ .textTheme
+ .bodySmall
+ ?.copyWith(color: colorBlack[70]),
+ "checkout_page_confirmation_subtitle".tr(),
+ ),
+ const SizedBox(height: 16),
+ Text(
+ "checkout_page_confirmation_deadline".tr(),
+ style: Theme.of(context)
+ .textTheme
+ .bodySmall
+ ?.copyWith(color: colorBlack[65]),
+ ),
+ const SizedBox(height: 24),
+ const Divider(color: colorDivider),
+ const SizedBox(height: 24),
+ const CheckOutPaymentCard(),
+ ],
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/check_out/pages/check_out_confirmation_pages.dart b/comwell_key_app/lib/check_out/pages/check_out_confirmation_pages.dart
deleted file mode 100644
index cc1c5090..00000000
--- a/comwell_key_app/lib/check_out/pages/check_out_confirmation_pages.dart
+++ /dev/null
@@ -1,45 +0,0 @@
-import 'package:comwell_key_app/check_out/components/check_out_payment_card.dart';
-import 'package:comwell_key_app/themes/light_theme.dart';
-import 'package:easy_localization/easy_localization.dart';
-import 'package:flutter/material.dart';
-
-class CheckOutConfirmationPage extends StatelessWidget {
- const CheckOutConfirmationPage({super.key});
-
- @override
- Widget build(BuildContext context) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 40),
- Text(
- "checkout_page_confirmation_title".tr(),
- style: Theme.of(context).textTheme.headlineLarge,
- ),
- const SizedBox(height: 18),
- Text(
- style: Theme.of(context)
- .textTheme
- .bodySmall
- ?.copyWith(color: colorBlack[70]),
- "checkout_page_confirmation_subtitle".tr(),
- ),
- const SizedBox(height: 16),
- Text(
- "checkout_page_confirmation_deadline".tr(),
- style: Theme.of(context)
- .textTheme
- .bodySmall
- ?.copyWith(color: colorBlack[65]),
- ),
- const SizedBox(height: 24),
- const Divider(color: colorDivider),
- const SizedBox(height: 24),
- const CheckOutPaymentCard(),
- ],
- ),
- );
- }
-}
diff --git a/comwell_key_app/lib/check_out/pages/check_out_error_page.dart b/comwell_key_app/lib/check_out/pages/check_out_error_page.dart
index 3152a987..6bf709af 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_error_page.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_error_page.dart
@@ -7,13 +7,10 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
class CheckOutErrorPage extends StatelessWidget {
- final String message;
- const CheckOutErrorPage({super.key, required this.message});
+ const CheckOutErrorPage({super.key});
@override
Widget build(BuildContext context) {
- final booking = context.read<CheckoutCubit>().booking;
-
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Padding(
@@ -33,7 +30,7 @@ class CheckOutErrorPage extends StatelessWidget {
?.copyWith(color: Colors.white),
),
Text(
- message,
+ "checkout_page_processing_error_subtitle".tr(),
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
diff --git a/comwell_key_app/lib/check_out/pages/check_out_page.dart b/comwell_key_app/lib/check_out/pages/check_out_page.dart
index f17d0308..a93e9503 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_page.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_page.dart
@@ -1,4 +1,4 @@
-import 'package:comwell_key_app/check_out/pages/check_out_confirmation_pages.dart';
+import 'package:comwell_key_app/check_out/pages/check_out_confirmation_page.dart';
import 'package:flutter/cupertino.dart';
import 'checkout_payment_page.dart';
diff --git a/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart b/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart
index e6056fd0..ba7276de 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_processing_page.dart
@@ -104,7 +104,7 @@ class _CheckOutProcessingPageState extends State<CheckOutProcessingPage>
if (processingState is CheckoutProcessingStateConfirmed) {
return const CheckOutSuccessPage();
} else if (processingState is CheckoutProcessingStateError) {
- return CheckOutErrorPage(message: processingState.message);
+ return const CheckOutErrorPage();
} else if (processingState
is CheckoutProcessingStateSessionReceived) {
showAdyenModal(context);
diff --git a/comwell_key_app/lib/overview/models/booking.dart b/comwell_key_app/lib/overview/models/booking.dart
index d03d5ed2..da491ff7 100644
--- a/comwell_key_app/lib/overview/models/booking.dart
+++ b/comwell_key_app/lib/overview/models/booking.dart
@@ -1,7 +1,8 @@
-import 'package:comwell_key_app/check_out/models/check_out_item.dart';
+
import 'package:comwell_key_app/overview/models/guest.dart';
import 'package:comwell_key_app/overview/models/payment_details.dart';
import 'package:comwell_key_app/overview/models/room.dart';
+import 'package:comwell_key_app/services/models/booking_dto.dart';
import 'package:comwell_key_app/up_sales/models/upgrade.dart';
import 'package:equatable/equatable.dart';
@@ -27,7 +28,7 @@ class Booking extends Equatable {
final num? balance;
final String? maskedCardNumber;
final List<Room> rooms;
- final List<CheckoutAddonItem>? addOnItems;
+ final List<BookingAddonItem>? addOnItems;
Booking({
required this.id,
@@ -116,7 +117,7 @@ class Booking extends Equatable {
Iterable<Guest>? guests,
num? totalCharge,
List<Room>? rooms,
- List<CheckoutAddonItem>? addOnItems,
+ List<BookingAddonItem>? addOnItems,
}) {
return Booking(
id: id ?? this.id,
diff --git a/comwell_key_app/lib/overview/repository/overview_repository.dart b/comwell_key_app/lib/overview/repository/overview_repository.dart
index 8517e5fa..ef07949c 100644
--- a/comwell_key_app/lib/overview/repository/overview_repository.dart
+++ b/comwell_key_app/lib/overview/repository/overview_repository.dart
@@ -1,4 +1,3 @@
-import 'package:comwell_key_app/check_out/models/check_out_item.dart';
import 'package:comwell_key_app/choose_share_room/choose_share_room_repository.dart';
import 'package:comwell_key_app/database/comwell_db.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
@@ -59,7 +58,7 @@ class OverviewRepository {
totalCharge: 12345,
balance: 0,
maskedCardNumber: "1234567890",
- addOnItems: [CheckoutAddonItem("addOnItem1", "addOnItem1", 1, 100), CheckoutAddonItem("addOnItem2", "addOnItem2", 1, 200), CheckoutAddonItem("addOnItem3", "addOnItem3", 1, 300)]);
+ addOnItems: [BookingAddonItem("addOnItem1", "addOnItem1", 1, 100), BookingAddonItem("addOnItem2", "addOnItem2", 1, 200), BookingAddonItem("addOnItem3", "addOnItem3", 1, 300)]);
return dto.toBooking(user.id, BookingStatus.current, []);
}
}
@@ -95,4 +94,4 @@ final mockBookings = [1, 2, 3].map((i) => Booking(
roomFacilities: [],
tags: ["10 M2"]),
],
- addOnItems: [CheckoutAddonItem("addOnItem$i", "addOnItem$i", 1, 100)]));
+ addOnItems: [BookingAddonItem("addOnItem$i", "addOnItem$i", 1, 100)]));
diff --git a/comwell_key_app/lib/payment_cards/bloc/payment_cards_cubit.dart b/comwell_key_app/lib/payment_cards/bloc/payment_cards_cubit.dart
index f9104817..ca8b228c 100644
--- a/comwell_key_app/lib/payment_cards/bloc/payment_cards_cubit.dart
+++ b/comwell_key_app/lib/payment_cards/bloc/payment_cards_cubit.dart
@@ -24,7 +24,7 @@ class PaymentCardsCubit extends Cubit<PaymentCardsState> {
Future<PaymentConfigurations> fetchPaymentConfiguration() async {
final session = await _preregistrationRepository.sessionCheckout(
- Amount(currency: "DKK", value: 0), "CBO");
+ Amount(currency: "DKK", value: 0), "CBO", false);
return session;
}
diff --git a/comwell_key_app/lib/pregistration/pregistration_repository.dart b/comwell_key_app/lib/pregistration/pregistration_repository.dart
index 31b63a6c..01f74c9e 100644
--- a/comwell_key_app/lib/pregistration/pregistration_repository.dart
+++ b/comwell_key_app/lib/pregistration/pregistration_repository.dart
@@ -15,9 +15,10 @@ class PreregistrationRepository {
Future<PaymentConfigurations> sessionCheckout(
Amount amount,
- String bookingId,
+ String bookingId,
+ bool usePoints,
) async {
- final response = await _api.createAdyenSession(bookingId);
+ final response = await _api.createAdyenSession(bookingId, usePoints);
final clientKey = response["clientKey"] as String;
final sessionResponse = response["sessionResponse"];
final id = sessionResponse["id"] as String;
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index 669f2692..d9ada2bb 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -52,10 +52,11 @@ class Api {
return StoredPaymentsResponse.fromJson(response.data!);
}
- Future<dynamic> createAdyenSession(String bookingId) async {
+ Future<dynamic> createAdyenSession(String bookingId, bool usePoints) async {
final body = {
"bookingConfirmationId": bookingId,
"returnUrl": "adyencheckout://com.comwell.phoenix.test/adyenPayment",
+ "usePoints": usePoints,
};
final json = jsonEncode(body);
final response =
diff --git a/comwell_key_app/lib/services/mappers/addon_item_mapper.dart b/comwell_key_app/lib/services/mappers/addon_item_mapper.dart
index d9cf2379..cc08cb4a 100644
--- a/comwell_key_app/lib/services/mappers/addon_item_mapper.dart
+++ b/comwell_key_app/lib/services/mappers/addon_item_mapper.dart
@@ -3,7 +3,7 @@ import 'package:comwell_key_app/up_sales/models/upgrade.dart';
import 'package:comwell_key_app/up_sales/models/room_upgrade.dart';
import 'package:comwell_key_app/up_sales/models/addon_upgrade.dart';
-extension AddOnItemDTOMapper on AddOnItemDTO {
+extension AddOnItemDTOMapper on BookingAddonItem {
Upgrade toUpgrade() {
// Determine if this is a room upgrade or addon based on the code
// You may need to adjust this logic based on your business rules
@@ -13,7 +13,7 @@ extension AddOnItemDTOMapper on AddOnItemDTO {
id: code,
name: description,
price: price.toInt(),
- currency: currency,
+ currency: "DKK",
images: const [],
description: description,
tags: const [],
@@ -26,7 +26,7 @@ extension AddOnItemDTOMapper on AddOnItemDTO {
id: code,
name: description,
price: price.toInt(),
- currency: currency,
+ currency: "DKK",
images: const [],
description: description,
tags: const [],
@@ -38,6 +38,6 @@ extension AddOnItemDTOMapper on AddOnItemDTO {
}
}
-extension ListAddOnItemDTOMapper on List<AddOnItemDTO> {
+ extension ListAddOnItemDTOMapper on List<BookingAddonItem> {
List<Upgrade> toUpgrades() => map((dto) => dto.toUpgrade()).toList();
}
diff --git a/comwell_key_app/lib/services/mappers/booking_mapper.dart b/comwell_key_app/lib/services/mappers/booking_mapper.dart
index 1506640b..026b6da8 100644
--- a/comwell_key_app/lib/services/mappers/booking_mapper.dart
+++ b/comwell_key_app/lib/services/mappers/booking_mapper.dart
@@ -33,7 +33,6 @@ extension BookingDTOMapper on BookingDTO {
balance: balance,
maskedCardNumber: maskedCardNumber,
rooms: rooms,
- addOnItems: addOnItems?.map((upgrade) => upgrade.toUpgrade()).toList() ?? [],
);
}
}
@@ -87,7 +86,6 @@ extension BookingWithRoomsMapper on Booking {
balance: balance,
maskedCardNumber: maskedCardNumber,
rooms: rooms,
- addOnItems: addOnItems,
);
}
}
diff --git a/comwell_key_app/lib/services/models/booking_dto.dart b/comwell_key_app/lib/services/models/booking_dto.dart
index 3961a0c0..a2710cec 100644
--- a/comwell_key_app/lib/services/models/booking_dto.dart
+++ b/comwell_key_app/lib/services/models/booking_dto.dart
@@ -1,4 +1,4 @@
-import 'package:comwell_key_app/check_out/models/check_out_item.dart';
+
import 'package:comwell_key_app/utils/json.dart';
import 'package:json_annotation/json_annotation.dart';
@@ -24,7 +24,7 @@ class BookingDTO {
final num? totalCharge;
final num? balance;
final String? maskedCardNumber;
- final List<CheckoutAddonItem>? addOnItems;
+ final List<BookingAddonItem>? addOnItems;
BookingDTO({
required this.roomNumber,
@@ -54,22 +54,24 @@ class BookingDTO {
}
@JsonSerializable()
-class AddOnItemDTO {
+class BookingAddonItem {
final String code;
final String description;
- final double price;
- final String currency;
final int quantity;
+ final int price;
- AddOnItemDTO({
- required this.code,
- required this.description,
- required this.price,
- required this.currency,
- required this.quantity,
- });
+ BookingAddonItem(this.code, this.description, this.quantity, this.price);
+
+ @override
+ String toString() {
+ return 'AddOnItem{code: $code, description: $description, quantity: $quantity, price: $price}';
+ }
+
+ factory BookingAddonItem.fromJson(Map<String, dynamic> json) => _$BookingAddonItemFromJson(json);
- Json toJson() => _$AddOnItemDTOToJson(this);
+ Map<String, dynamic> toJson() => _$BookingAddonItemToJson(this);
- factory AddOnItemDTO.fromJson(Json json) => _$AddOnItemDTOFromJson(json);
+ BookingAddonItem copyWith({int? quantity, int? price}) {
+ return BookingAddonItem(code, description, quantity ?? this.quantity, price ?? this.price);
+ }
}
\ No newline at end of file