6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 709b772f
Changed files
.../up_sales/models/dto/addon_upgrade_dto.g.dart | 7 ++-- .../lib/booking_details/booking_details_page.dart | 2 +- .../lib/check_in/check_in_repository.dart | 25 --------------- .../components/balance_bottom_sheet.dart | 3 +- .../lib/my_booking/my_booking_page.dart | 25 ++++----------- comwell_key_app/lib/overview/models/booking.dart | 2 +- .../overview/repository/overview_repository.dart | 37 ---------------------- comwell_key_app/lib/routing/app_router.dart | 6 ++-- comwell_key_app/lib/services/api.dart | 1 + 9 files changed, 20 insertions(+), 88 deletions(-)
Diff
diff --git a/comwell_key_app/lib/.generated/up_sales/models/dto/addon_upgrade_dto.g.dart b/comwell_key_app/lib/.generated/up_sales/models/dto/addon_upgrade_dto.g.dart
index 039e32b4..ce02291d 100644
--- a/comwell_key_app/lib/.generated/up_sales/models/dto/addon_upgrade_dto.g.dart
+++ b/comwell_key_app/lib/.generated/up_sales/models/dto/addon_upgrade_dto.g.dart
@@ -14,9 +14,11 @@ AddOnUpgradeDTO _$AddOnUpgradeDTOFromJson(Map json) => AddOnUpgradeDTO(
isSelected: json['isSelected'] as bool,
images: (json['images'] as List<dynamic>).map((e) => e as String),
description: json['description'] as String,
- tags: (json['tags'] as List<dynamic>).map((e) => e as String),
quantity: (json['quantity'] as num?)?.toInt() ?? 0,
isService: json['isService'] as bool? ?? false,
+ isPopular: json['isPopular'] as bool? ?? false,
+ onlyAvailableBeforeCheckin:
+ json['onlyAvailableBeforeCheckin'] as bool? ?? false,
);
Map<String, dynamic> _$AddOnUpgradeDTOToJson(AddOnUpgradeDTO instance) =>
@@ -28,7 +30,8 @@ Map<String, dynamic> _$AddOnUpgradeDTOToJson(AddOnUpgradeDTO instance) =>
'isSelected': instance.isSelected,
'images': instance.images.toList(),
'description': instance.description,
- 'tags': instance.tags.toList(),
'quantity': instance.quantity,
'isService': instance.isService,
+ 'isPopular': instance.isPopular,
+ 'onlyAvailableBeforeCheckin': instance.onlyAvailableBeforeCheckin,
};
diff --git a/comwell_key_app/lib/booking_details/booking_details_page.dart b/comwell_key_app/lib/booking_details/booking_details_page.dart
index 7934b24d..0e8526ab 100644
--- a/comwell_key_app/lib/booking_details/booking_details_page.dart
+++ b/comwell_key_app/lib/booking_details/booking_details_page.dart
@@ -122,7 +122,7 @@ class BookingDetailsPage extends StatelessWidget {
BookingDetailsState state, BookingDetailsBloc cubit, ThemeData theme) {
return InkWell(
onTap: () {
- context.pushNamed(AppRoutes.myBooking.name, extra: cubit.booking);
+ context.pushNamed(AppRoutes.myBooking.name, extra: [cubit.booking, cubit.state.upSales]);
},
child: Container(
width: double.infinity,
diff --git a/comwell_key_app/lib/check_in/check_in_repository.dart b/comwell_key_app/lib/check_in/check_in_repository.dart
index e39c6f72..06d2078c 100644
--- a/comwell_key_app/lib/check_in/check_in_repository.dart
+++ b/comwell_key_app/lib/check_in/check_in_repository.dart
@@ -1,6 +1,5 @@
import 'package:comwell_key_app/database/comwell_db.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
-import 'package:comwell_key_app/overview/models/guest.dart';
import 'package:comwell_key_app/profile/profile_repository.dart';
import 'package:comwell_key_app/services/api.dart';
import 'package:comwell_key_app/utils/locator.dart';
@@ -52,28 +51,4 @@ class CheckInRepository {
}
}
- static final mockBooking = Booking(
- id: "helloworld",
- roomNumber: "1234",
- startDate: DateTime.now(),
- endDate: DateTime.now(),
- bookingStatus: BookingStatus.current,
- reservationStatus: ReservationStatus.newreservation,
- image: "",
- hotelName: "hotelName",
- roomType: "roomType",
- confirmationId: "",
- children: 0,
- adults: 2,
- hotelCode: "hotelCode",
- totalCharge: 100,
- balance: 0,
- maskedCardNumber: "1234567890",
- booker: const Guest(name: "Booker", id: "123"),
- bookingDate: DateTime.now(),
- digitalCard: true,
- guests: null,
- rooms: const [],
- addOnItems: const [],
- );
}
diff --git a/comwell_key_app/lib/my_booking/components/balance_bottom_sheet.dart b/comwell_key_app/lib/my_booking/components/balance_bottom_sheet.dart
index 24abef2f..86cd964b 100644
--- a/comwell_key_app/lib/my_booking/components/balance_bottom_sheet.dart
+++ b/comwell_key_app/lib/my_booking/components/balance_bottom_sheet.dart
@@ -1,5 +1,6 @@
import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
+import 'package:comwell_key_app/up_sales/models/addon_upgrade.dart';
import 'package:comwell_key_app/utils/share_button_utils.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
@@ -8,7 +9,7 @@ class BalanceBottomSheet extends StatelessWidget {
final num balance;
final String userName;
final Booking booking;
- final List<BalanceItem> items;
+ final List<AddOnUpgrade> items;
const BalanceBottomSheet({
super.key,
diff --git a/comwell_key_app/lib/my_booking/my_booking_page.dart b/comwell_key_app/lib/my_booking/my_booking_page.dart
index 20ec9eb9..7f576866 100644
--- a/comwell_key_app/lib/my_booking/my_booking_page.dart
+++ b/comwell_key_app/lib/my_booking/my_booking_page.dart
@@ -6,6 +6,7 @@ import 'package:comwell_key_app/my_booking/components/balance_bottom_sheet.dart'
import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/profile/profile_repository.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
+import 'package:comwell_key_app/up_sales/models/up_sales.dart';
import 'package:comwell_key_app/up_sales/up_sales_repository.dart';
import 'package:comwell_key_app/utils/locator.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -14,7 +15,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
class MyBookingPage extends StatelessWidget {
final Booking booking;
- const MyBookingPage({super.key, required this.booking});
+ final UpSales upSales;
+ const MyBookingPage({super.key, required this.booking, required this.upSales});
@override
Widget build(BuildContext context) {
@@ -76,25 +78,10 @@ class MyBookingPage extends StatelessWidget {
isScrollControlled: true,
context: context,
builder: (context) => BalanceBottomSheet(
- balance: booking.totalCharge ?? 0,
+ balance: booking.balance ?? 0,
userName: booking.booker.name,
booking: booking,
- items: [
- BalanceItem(
- description: booking.roomType,
- amount: 1634,
- isPaid: true,
- ),
- const BalanceItem(
- description: 'Romantisk kurv',
- amount: 500,
- isPaid: true,
- ),
- const BalanceItem(
- description: 'Tidlig check-in',
- amount: 200,
- ),
- ],
+ items: upSales.addOnItems,
),
);
},
@@ -306,7 +293,7 @@ class MyBookingPage extends StatelessWidget {
Row(
children: [
Text(
- '${booking.totalCharge} kr',
+ '${booking.balance} kr',
style: theme.textTheme.bodyLarge?.copyWith(
color: Colors.white,
fontWeight: FontWeight.w600,
diff --git a/comwell_key_app/lib/overview/models/booking.dart b/comwell_key_app/lib/overview/models/booking.dart
index da491ff7..f7aff991 100644
--- a/comwell_key_app/lib/overview/models/booking.dart
+++ b/comwell_key_app/lib/overview/models/booking.dart
@@ -52,7 +52,7 @@ class Booking extends Equatable {
required this.maskedCardNumber,
required this.rooms,
Iterable<Guest>? guests,
- this.addOnItems,
+ required this.addOnItems,
}) : guests = _ensureBookerInGuestList(booker, guests ?? []);
static Iterable<Guest> _ensureBookerInGuestList(
diff --git a/comwell_key_app/lib/overview/repository/overview_repository.dart b/comwell_key_app/lib/overview/repository/overview_repository.dart
index ef07949c..47c4468e 100644
--- a/comwell_key_app/lib/overview/repository/overview_repository.dart
+++ b/comwell_key_app/lib/overview/repository/overview_repository.dart
@@ -32,10 +32,6 @@ class OverviewRepository {
}
}
- Iterable<Booking> fetchAllBookingsForUserMock(String userId) {
- return mockBookings;
- }
-
Future<Booking?> findBooking(String bookingReference, String lastName) async {
// needs implementation
final user = await locator<ComwellDatabase>().userDAO.getUser();
@@ -62,36 +58,3 @@ class OverviewRepository {
return dto.toBooking(user.id, BookingStatus.current, []);
}
}
-
-final mockBookings = [1, 2, 3].map((i) => Booking(
- id: "id$i",
- confirmationId: "confirmationId$i",
- roomNumber: "roomNumber$i",
- startDate: DateTime.now(),
- endDate: DateTime.now(),
- bookingStatus: BookingStatus.current,
- reservationStatus: ReservationStatus.newreservation,
- image: "assets/images/no_current_bookings_background.jpeg",
- hotelName: "hotelName$i",
- roomType: "roomType$i",
- totalCharge: 100,
- children: 3,
- adults: 3,
- hotelCode: "hotelCode$i",
- booker: const Guest(id: "id", name: "name"),
- bookingDate: DateTime.now(),
- digitalCard: false,
- balance: 0,
- maskedCardNumber: "1234567890",
- rooms: [
- Room(
- confirmationNumber: "CONF00$i",
- assignedTo: "assignedTo$i",
- name: "roomName$i",
- description: "roomDescription$i",
- guests: 3,
- imageAssets: ["roomImageAsset$i"],
- roomFacilities: [],
- tags: ["10 M2"]),
- ],
- addOnItems: [BookingAddonItem("addOnItem$i", "addOnItem$i", 1, 100)]));
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 2400296a..74e1a2aa 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -291,13 +291,15 @@ GoRouter goRouter() {
path: "/${AppRoutes.myBooking.name}",
name: AppRoutes.myBooking.name,
builder: (context, state) {
- final booking = state.extra as Booking;
+ final extras = state.extra as List<dynamic>;
+ final booking = extras[0] as Booking;
+ final upSales = extras[1] as UpSales;
return BlocProvider(
create: (context) => MyBookingCubit(
locator<MyBookingRepository>(),
initialBooking: booking,
),
- child: MyBookingPage(booking: booking),
+ child: MyBookingPage(booking: booking, upSales: upSales),
);
}),
GoRoute(
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index d9ada2bb..30ffeb19 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -281,6 +281,7 @@ class Api {
};
final data = jsonEncode(body);
final response = await dio.post<Json>(ApiEndpoints.upSales, data: data);
+ print("response.data: ${response.data}");
return UpSalesDTO.fromJson(response.data!);
}