6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 1213e146
Changed files
comwell_key_app/assets/icons/ic_error.svg | 5 + comwell_key_app/assets/translations/da-DK.json | 12 +- comwell_key_app/assets/translations/en-US.json | 10 +- .../booking_details/bloc/booking_details_bloc.dart | 6 +- .../lib/check_in/bloc/check_in_cubit.dart | 4 +- .../lib/check_in/check_in_repository.dart | 4 +- .../lib/check_out/bloc/check_out_cubit.dart | 2 +- .../common/components/comwell_error_widget.dart | 45 ++++++++ comwell_key_app/lib/comwell_app.dart | 2 +- .../hotel_information/hotel_information_page.dart | 14 ++- .../lib/notifications/notifications_page.dart | 25 +++-- .../lib/overview/cubit/overview_cubit.dart | 2 +- comwell_key_app/lib/overview/overview_page.dart | 123 ++++++++++++--------- .../lib/payment_cards/payment_cards_page.dart | 16 ++- .../components/empty_card_content_widget.dart | 55 --------- .../lib/profile/components/error_page_widget.dart | 102 ++++++----------- .../lib/profile/profile_repository.dart | 4 +- comwell_key_app/lib/routing/app_router.dart | 63 +++++------ comwell_key_app/lib/services/api.dart | 8 +- .../test/overview_test/overview_cubic_test.dart | 22 +--- .../overview_test/overview_repository_test.dart | 6 +- 21 files changed, 270 insertions(+), 260 deletions(-)
Diff
diff --git a/comwell_key_app/assets/icons/ic_error.svg b/comwell_key_app/assets/icons/ic_error.svg
new file mode 100644
index 00000000..b0203447
--- /dev/null
+++ b/comwell_key_app/assets/icons/ic_error.svg
@@ -0,0 +1,5 @@
+<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
+<circle cx="24" cy="24" r="22.5" stroke="black" stroke-width="3"/>
+<path d="M25.875 12.75V27.75H22.875V12.75H25.875Z" fill="black"/>
+<circle cx="24.5" cy="33.5" r="2.5" fill="black"/>
+</svg>
diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index 27c89401..9696996f 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -29,7 +29,7 @@
"become_cc_member_title": "Bliv medlem af comwell club",
"become_cc_member_subtitle": "Bliv medlem og optjen point, hver gang du overnatter på et Comwell Hotel.",
"overview_tabbar_active": "Aktuelle",
- "overview_tabbar_past": "Tidligere",
+ "overview_tabbar_past": "Tidligere",
"overview_tabbar_cancelled": "Annulleret",
"no_past_bookings_title": "Ingen tidligere ophold",
"no_past_bookings_subtitle": "Du har ingen tidligere overnatninger på Comwell Hotels.",
@@ -334,5 +334,13 @@
"get_keys": "Hent digital nøgle",
"get_keys_subtitle": "Få dit digitale nøglekort med det samme",
"add_card": "Tilføj kort",
- "total": "I alt"
+ "total": "I alt",
+ "profile_error_title": "Kunne ikke loade din profil",
+ "profile_error_subtitle": "Der er sket en fejl. Prøv igen senere.",
+ "generic_error_title": "Der er sket en fejl",
+ "notifications_error_subtitle": "Notifikationer kan ikke hentes i øjeblikket. Prøv igen senere.",
+ "payment_cards_error_subtitle": "Dine betalingskort kan ikke hentes i øjeblikket. Prøv igen senere.",
+ "hotel_information_error_subtitle": "Hotelinformationen kan ikke hentes i øjeblikket. Prøv igen senere.",
+ "overview_error_title": "Kunne ikke indlæse dine bookinger",
+ "overview_error_subtitle": "Der er sket en fejl. Vi kunne ikke loade dine bookinger. Prøv igen senere."
}
\ No newline at end of file
diff --git a/comwell_key_app/assets/translations/en-US.json b/comwell_key_app/assets/translations/en-US.json
index 313a7fa7..3dae43b0 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -337,5 +337,13 @@
"get_keys": "Get digital key",
"get_keys_subtitle": "Get your digital key card",
"add_card": "Add card",
- "total": "Total"
+ "total": "Total",
+ "profile_error_title": "Could not load your profile",
+ "profile_error_subtitle": "An error occurred. Please try again later.",
+ "generic_error_title": "There was an error",
+ "notifications_error_subtitle": "Notifications could not be loaded. Please try again later.",
+ "payment_cards_error_subtitle": "Payment cards could not be loaded. Please try again later.",
+ "hotel_information_error_subtitle": "Hotel information could not be loaded. Please try again later.",
+ "overview_error_title": "Could not load your bookings",
+ "overview_error_subtitle": "An error occurred. We could not load your bookings. Please try again later."
}
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 dd85b997..2ebaeeda 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
@@ -93,7 +93,7 @@ class BookingDetailsBloc
});
on<GetBookingDetailsEvent>((event, emit) async {
- await getBookingDetails(emit, event.bookingId);
+ await getBookingDetails(emit, event.bookingId, booking.hotelCode);
});
on<GetUserEvent>((event, emit) async {
@@ -109,11 +109,11 @@ class BookingDetailsBloc
}
Future<Booking> getBookingDetails(
- Emitter<BookingDetailsState> emit, String bookingId) async {
+ Emitter<BookingDetailsState> emit, String bookingId, String hotelCode) async {
emit(state.loading());
try {
final bookingDetails =
- await profileRepository.getBookingDetails(bookingId);
+ await profileRepository.getBookingDetails(bookingId, hotelCode);
booking = bookingDetails;
return booking;
diff --git a/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart b/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart
index 43fa7848..eaf5d502 100644
--- a/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart
+++ b/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart
@@ -20,7 +20,7 @@ class CheckInCubit extends Cubit<CheckInState> {
Future<void> initOnlyKeys() async {
try {
final bookingDetails =
- await _checkInRepository.getBookingDetails(booking.id);
+ await _checkInRepository.getBookingDetails(booking.id, booking.hotelCode);
emit(state.checkInStatusRoomFound(roomNumber: bookingDetails.roomNumber));
debugPrint("bookingDetails ${bookingDetails.roomNumber}");
await _checkInRepository.checkIfSetup();
@@ -43,7 +43,7 @@ class CheckInCubit extends Cubit<CheckInState> {
emit(state.checkInStatusLoading());
await _checkInRepository.checkIn(booking.confirmationId);
final bookingDetails =
- await _checkInRepository.getBookingDetails(booking.id);
+ await _checkInRepository.getBookingDetails(booking.id, booking.hotelCode);
emit(state.checkInStatusRoomFound(roomNumber: bookingDetails.roomNumber));
await _checkInRepository.checkIfSetup();
await tryGetKeys();
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 ada4e167..5475d11f 100644
--- a/comwell_key_app/lib/check_in/check_in_repository.dart
+++ b/comwell_key_app/lib/check_in/check_in_repository.dart
@@ -31,8 +31,8 @@ class CheckInRepository {
}
}
- Future<Booking> getBookingDetails(String bookingId) async {
- final booking = await profileRepository.getBookingDetails(bookingId);
+ Future<Booking> getBookingDetails(String bookingId, String hotelCode) async {
+ final booking = await profileRepository.getBookingDetails(bookingId, hotelCode);
return booking;
}
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 afc9e00f..02f36b7e 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
@@ -156,7 +156,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
Future<void> checkOut() async {
try {
booking =
- await profileRepository.getBookingDetails(booking.confirmationId);
+ await profileRepository.getBookingDetails(booking.confirmationId, booking.hotelCode);
if (booking.balance == 0) {
await checkOutRepository.checkOut(booking.confirmationId);
diff --git a/comwell_key_app/lib/common/components/comwell_error_widget.dart b/comwell_key_app/lib/common/components/comwell_error_widget.dart
new file mode 100644
index 00000000..de8ddb31
--- /dev/null
+++ b/comwell_key_app/lib/common/components/comwell_error_widget.dart
@@ -0,0 +1,45 @@
+import 'package:comwell_key_app/themes/light_theme.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/widgets.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+
+class ComwellErrorWidget extends StatelessWidget {
+ final String title;
+ final String subtitle;
+ final bool border;
+ const ComwellErrorWidget(
+ {super.key, required this.title, required this.subtitle, this.border = false});
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = Theme.of(context);
+ return Container(
+ width: double.infinity,
+ decoration: const BoxDecoration(
+ color: Colors.white
+ ),
+ padding: const EdgeInsets.all(16),
+ child: Column(
+ children: [
+ Container(
+ decoration: BoxDecoration(
+ border: border ? Border.all(color: colorDivider) : null,
+ borderRadius: BorderRadius.circular(16),
+ ),
+ padding: const EdgeInsets.symmetric(horizontal: 48, vertical: 32),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ SvgPicture.asset('assets/icons/ic_error.svg', width: 48, height: 48),
+ const SizedBox(height: 30),
+ Text(title, style: theme.textTheme.headlineMedium, textAlign: TextAlign.center),
+ const SizedBox(height: 12),
+ Text(subtitle, style: theme.textTheme.bodySmall, textAlign: TextAlign.center),
+ ],
+ )),
+ ],
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/comwell_app.dart b/comwell_key_app/lib/comwell_app.dart
index 8f7e09d8..331982f6 100644
--- a/comwell_key_app/lib/comwell_app.dart
+++ b/comwell_key_app/lib/comwell_app.dart
@@ -29,7 +29,7 @@ class ComwellApp extends StatelessWidget {
providers: blocProviderList,
child: MaterialApp.router(
title: 'Comwell Key App',
- routerConfig: goRouter(),
+ routerConfig: router,
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
diff --git a/comwell_key_app/lib/hotel_information/hotel_information_page.dart b/comwell_key_app/lib/hotel_information/hotel_information_page.dart
index 65e7bef7..4e2e2145 100644
--- a/comwell_key_app/lib/hotel_information/hotel_information_page.dart
+++ b/comwell_key_app/lib/hotel_information/hotel_information_page.dart
@@ -1,5 +1,7 @@
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
+import 'package:comwell_key_app/common/components/comwell_error_widget.dart';
import 'package:comwell_key_app/hotel_information/cubit/hotel_information_cubit.dart';
+import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../common/components/shimmer_loader/hotel_information_shimmer_loader.dart';
@@ -19,7 +21,17 @@ class HotelInformationPage extends StatelessWidget {
body: Builder(builder: (context) {
return switch (state.hotelState) {
HotelState.loading => const Center(child: HotelInformationShimmerLoader()),
- HotelState.error => const Center(child: Text("Error")),
+ HotelState.error => Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ ComwellErrorWidget(
+ title: 'generic_error_title'.tr(),
+ subtitle: 'hotel_information_error_subtitle'.tr(),
+ border: false,
+ ),
+ ],
+ ),
HotelState.success => child,
};
}),
diff --git a/comwell_key_app/lib/notifications/notifications_page.dart b/comwell_key_app/lib/notifications/notifications_page.dart
index 9cb94de3..a520af7a 100644
--- a/comwell_key_app/lib/notifications/notifications_page.dart
+++ b/comwell_key_app/lib/notifications/notifications_page.dart
@@ -1,6 +1,8 @@
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
+import 'package:comwell_key_app/common/components/comwell_error_widget.dart';
import 'package:comwell_key_app/notifications/cubit/notifications_state.dart';
import 'package:comwell_key_app/notifications/models/notification_permission.dart';
+import 'package:comwell_key_app/profile/components/error_page_widget.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
@@ -24,10 +26,16 @@ class NotificationsPage extends StatelessWidget {
if (state.isLoading) {
return const Center(child: NotificationsShimmerLoader());
} else if (state.error != null) {
- return Center(
- child: Text(
- "generic_error".tr(),
- ),
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ ComwellErrorWidget(
+ title: 'generic_error_title'.tr(),
+ subtitle: 'notifications_error_subtitle'.tr(),
+ border: false,
+ ),
+ ],
);
} else {
return _buildNotificationsPage(context, cubit);
@@ -37,7 +45,8 @@ class NotificationsPage extends StatelessWidget {
);
}
- Widget _buildNotificationsPage(BuildContext context, NotificationsCubit cubit) {
+ Widget _buildNotificationsPage(
+ BuildContext context, NotificationsCubit cubit) {
final theme = Theme.of(context);
return SafeArea(
child: Column(
@@ -64,8 +73,10 @@ class NotificationsPage extends StatelessWidget {
activeColor: sandColor,
inactiveTrackColor: Colors.grey[200],
inactiveThumbColor: Colors.white,
- trackOutlineColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.surface),
- value: cubit.state.allNotifications.every((e) => e.allowed),
+ trackOutlineColor: WidgetStatePropertyAll(
+ Theme.of(context).colorScheme.surface),
+ value: cubit.state.allNotifications
+ .every((e) => e.allowed),
onChanged: (bool value) {
cubit.updateAllPermissionsUI(value);
},
diff --git a/comwell_key_app/lib/overview/cubit/overview_cubit.dart b/comwell_key_app/lib/overview/cubit/overview_cubit.dart
index b863bece..fca06172 100644
--- a/comwell_key_app/lib/overview/cubit/overview_cubit.dart
+++ b/comwell_key_app/lib/overview/cubit/overview_cubit.dart
@@ -17,7 +17,7 @@ class OverviewCubit extends Cubit<OverviewState> {
try {
final bookings = await overviewRepository.fetchAllBookingsForUser();
-
+
emit(OverviewLoaded(bookings: bookings));
} catch (e, st) {
if (kDebugMode) print("err=$e, $st");
diff --git a/comwell_key_app/lib/overview/overview_page.dart b/comwell_key_app/lib/overview/overview_page.dart
index 0269354d..04a772a6 100644
--- a/comwell_key_app/lib/overview/overview_page.dart
+++ b/comwell_key_app/lib/overview/overview_page.dart
@@ -1,7 +1,9 @@
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
+import 'package:comwell_key_app/common/components/comwell_error_widget.dart';
import 'package:comwell_key_app/common/components/generic_dialog.dart';
import 'package:comwell_key_app/overview/components/bookings_tab_view.dart';
import 'package:comwell_key_app/overview/components/current_bookings_tab_view.dart';
+import 'package:comwell_key_app/overview/components/find_booking_button.dart';
import 'package:comwell_key_app/overview/cubit/overview_cubit.dart';
import 'package:comwell_key_app/overview/models/bookings.dart';
import 'package:comwell_key_app/profile/utils/urls.dart';
@@ -60,6 +62,8 @@ class OverviewTabViewState extends State<OverviewPage>
shouldShowBackButton: false,
),
body: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding:
@@ -92,7 +96,18 @@ class OverviewTabViewState extends State<OverviewPage>
),
),
),
- if (state is OverviewLoaded) ...[
+ if (state is OverviewError) ...[
+ Column(
+ children: [
+ ComwellErrorWidget(
+ title: 'overview_error_title'.tr(),
+ subtitle: 'overview_error_subtitle'.tr(),
+ border: true,
+ ),
+ const FindBookingButton()
+ ],
+ ),
+ ] else if (state is OverviewLoaded) ...[
OverviewTabView(
tabController: _tabController,
bookings: (state).bookings),
@@ -108,53 +123,57 @@ class OverviewTabViewState extends State<OverviewPage>
tabController: _tabController,
bookings: const Bookings(bookings: [])),
],
- Divider(
- color: theme.colorScheme.outline,
- thickness: 1,
- height: 0,
- ),
- Padding(
- padding: const EdgeInsets.only(
- left: 18.0, right: 18.0, bottom: 32.0, top: 16.0),
- child: ElevatedButton(
- onPressed: () async {
- bool success = await launchUrl(
- Uri.parse(ComwellUrls.comwellWebsite));
- if (!success) {
- if (context.mounted) {
- showDialog<void>(
- context: context,
- builder: (BuildContext context) {
- return AlertDialog(
- backgroundColor: Colors.white,
- contentPadding: const EdgeInsets.all(24),
- title: Text(
- 'error_opening_website_title'.tr(),
- style: theme.textTheme.headlineMedium,
- textAlign: TextAlign.center),
- content: Text('error_opening_website'.tr(),
- style: theme.textTheme.bodySmall,
- textAlign: TextAlign.center),
- actions: [
- Center(
- child: ElevatedButton(
- onPressed: () {
- Navigator.of(context).pop();
- },
- style: ElevatedButton.styleFrom(
- foregroundColor: Colors.white),
- child: Text('generic_ok'.tr()),
- ),
- ),
- ],
+ Column(
+ children: [
+ Divider(
+ color: theme.colorScheme.outline,
+ thickness: 1,
+ height: 0,
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ left: 18.0, right: 18.0, bottom: 32.0, top: 16.0),
+ child: ElevatedButton(
+ onPressed: () async {
+ bool success = await launchUrl(
+ Uri.parse(ComwellUrls.comwellWebsite));
+ if (!success) {
+ if (context.mounted) {
+ showDialog<void>(
+ context: context,
+ builder: (BuildContext context) {
+ return AlertDialog(
+ backgroundColor: Colors.white,
+ contentPadding: const EdgeInsets.all(24),
+ title: Text(
+ 'error_opening_website_title'.tr(),
+ style: theme.textTheme.headlineMedium,
+ textAlign: TextAlign.center),
+ content: Text('error_opening_website'.tr(),
+ style: theme.textTheme.bodySmall,
+ textAlign: TextAlign.center),
+ actions: [
+ Center(
+ child: ElevatedButton(
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ style: ElevatedButton.styleFrom(
+ foregroundColor: Colors.white),
+ child: Text('generic_ok'.tr()),
+ ),
+ ),
+ ],
+ );
+ },
);
- },
- );
- }
- }
- },
- style:
- Theme.of(context).elevatedButtonTheme.style?.copyWith(
+ }
+ }
+ },
+ style: Theme.of(context)
+ .elevatedButtonTheme
+ .style
+ ?.copyWith(
minimumSize: const WidgetStatePropertyAll(
Size(double.infinity, 50)),
shape: WidgetStatePropertyAll(
@@ -163,10 +182,12 @@ class OverviewTabViewState extends State<OverviewPage>
),
),
),
- child: Text('new_booking'.tr(),
- style: theme.textTheme.bodyMedium
- ?.copyWith(color: Colors.white)),
- ),
+ child: Text('new_booking'.tr(),
+ style: theme.textTheme.bodyMedium
+ ?.copyWith(color: Colors.white)),
+ ),
+ ),
+ ],
),
],
),
diff --git a/comwell_key_app/lib/payment_cards/payment_cards_page.dart b/comwell_key_app/lib/payment_cards/payment_cards_page.dart
index 7b2afa67..7bc78917 100644
--- a/comwell_key_app/lib/payment_cards/payment_cards_page.dart
+++ b/comwell_key_app/lib/payment_cards/payment_cards_page.dart
@@ -1,4 +1,5 @@
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
+import 'package:comwell_key_app/common/components/comwell_error_widget.dart';
import 'package:comwell_key_app/payment_cards/bloc/payment_cards_state.dart';
import 'package:comwell_key_app/payment_cards/components/add_card.dart';
import 'package:comwell_key_app/payment_cards/components/edit_card_dialog.dart';
@@ -28,11 +29,16 @@ class PaymentCardsPage extends StatelessWidget {
return const Center(child: PaymentCardsShimmerLoader());
}
if (cubit.state.hasError) {
- return Center(
- child: Text(
- 'error_cards'.tr(),
- style: theme.textTheme.bodyMedium,
- ),
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ ComwellErrorWidget(
+ title: 'generic_error_title'.tr(),
+ subtitle: 'payment_cards_error_subtitle'.tr(),
+ border: false,
+ ),
+ ],
);
}
return _buildPaymentCards(context, state, cubit);
diff --git a/comwell_key_app/lib/profile/components/empty_card_content_widget.dart b/comwell_key_app/lib/profile/components/empty_card_content_widget.dart
deleted file mode 100644
index 1fbd6cc8..00000000
--- a/comwell_key_app/lib/profile/components/empty_card_content_widget.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-import 'package:easy_localization/easy_localization.dart';
-import 'package:flutter/material.dart';
-
-class EmptyCardContentWidget extends StatelessWidget {
- const EmptyCardContentWidget({super.key});
-
- @override
- Widget build(BuildContext context) {
- final theme = Theme.of(context);
-
- return SizedBox(
- width: double.infinity,
- height: double.infinity,
- child: Stack(
- children: [
- Positioned(
- top: 20,
- left: 20,
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
- decoration: BoxDecoration(
- color: Theme.of(context).colorScheme.surface,
- borderRadius: BorderRadius.circular(32),
- ),
- child: Text(
- 'error'.tr(),
- style: theme.textTheme.bodySmall!.copyWith(
- color: Theme.of(context).colorScheme.onSurface,
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- ),
- Positioned(
- bottom: 20,
- left: 20,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- 'profile_error_name'.tr(),
- style: theme.textTheme.bodySmall!.copyWith(
- color: Theme.of(context).colorScheme.onSurface,
- fontSize: 16,
- fontWeight: FontWeight.w600,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- );
- }
-}
diff --git a/comwell_key_app/lib/profile/components/error_page_widget.dart b/comwell_key_app/lib/profile/components/error_page_widget.dart
index 949a3e9a..fe2a2faa 100644
--- a/comwell_key_app/lib/profile/components/error_page_widget.dart
+++ b/comwell_key_app/lib/profile/components/error_page_widget.dart
@@ -1,6 +1,6 @@
import 'package:comwell_key_app/common/components/comwell_card_component.dart';
+import 'package:comwell_key_app/common/components/comwell_error_widget.dart';
import 'package:comwell_key_app/common/components/round_icon_button.dart';
-import 'package:comwell_key_app/profile/components/empty_card_content_widget.dart';
import 'package:comwell_key_app/profile/components/logout_dialog_widget.dart';
import 'package:comwell_key_app/profile/cubit/profile_cubit.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
@@ -14,76 +14,40 @@ class ErrorPageWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return SafeArea(
- child: Column(
- children: [
- Padding(
- padding: const EdgeInsets.only(top: 20),
- child: Container(
- alignment: Alignment.centerRight,
- child: RoundIconButton(
- icon: "assets/icons/close-icon.svg",
- color: Colors.white,
- onPressed: () {
- context.pop();
- }),
- ),
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(top: 80),
+ child: Container(
+ alignment: Alignment.centerRight,
+ child: RoundIconButton(
+ icon: "assets/icons/close-icon.svg",
+ color: Colors.white,
+ onPressed: () {
+ context.pop();
+ }),
),
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Column(
- children: [
- ComwellCard(
- content: const EmptyCardContentWidget(),
- backgroundColor: sandColor[10]!),
- ],
- ),
+ ),
+ Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Column(
+ children: [
+ ComwellCard(
+ content: const SizedBox.shrink(),
+ backgroundColor: sandColor[10]!),
+ ],
),
- const SizedBox(height: 10),
- Expanded(
- child: Container(
- color: Colors.white,
- child: Column(
- children: [
- const SizedBox(height: 20),
- Center(
- child: OutlinedButton(
- style: OutlinedButton.styleFrom(
- side: const BorderSide(color: colorDivider),
- ),
- onPressed: () {
- showDialog<void>(
- context: context,
- builder: (context) => LogoutDialogWidget(
- cubit: context.read<ProfileCubit>(),
- ),
- );
- },
- child: Text(
- 'logout_profile_menu'.tr(),
- style: TextStyle(color: Colors.grey[600]),
- ),
- ),
- ),
- const SizedBox(height: 16),
- FutureBuilder<String>(
- future: context.read<ProfileCubit>().getVersion(),
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- return Text(snapshot.data!,
- style: TextStyle(color: Colors.grey[500]));
- }
- return const SizedBox.shrink();
- },
- ),
- const SizedBox(height: 20),
- const Spacer(),
- ],
- ),
- ),
- ),
- ],
- ),
+ ),
+ const SizedBox(height: 10),
+ Expanded(
+ child: ComwellErrorWidget(
+ title: 'profile_error_title'.tr(),
+ subtitle: 'profile_error_subtitle'.tr(),
+ border: true),
+ ),
+ ],
);
}
}
diff --git a/comwell_key_app/lib/profile/profile_repository.dart b/comwell_key_app/lib/profile/profile_repository.dart
index 18634be0..21dbae1a 100644
--- a/comwell_key_app/lib/profile/profile_repository.dart
+++ b/comwell_key_app/lib/profile/profile_repository.dart
@@ -47,9 +47,9 @@ class ProfileRepository {
return user;
}
- Future<Booking> getBookingDetails(String bookingId) async {
+ Future<Booking> getBookingDetails(String bookingId, String hotelCode) async {
user = await fetchProfileSettings();
- final response = await api.getBookingDetails(bookingId);
+ final response = await api.getBookingDetails(bookingId, hotelCode);
await locator<ComwellDatabase>().bookingsDao.insertBookings(
BookingsDTO(bookings: [response!]));
final booking = response.toBooking(user.id, []);
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 2033cbf0..24ae763c 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -90,43 +90,41 @@ final _rootNavigatorKey = GlobalKey<NavigatorState>();
final rootNavigatorKey = _rootNavigatorKey;
final _shellNavigatorKey = GlobalKey<NavigatorState>();
-GoRouter goRouter() {
- final authRepo = locator<AuthenticationRepository>();
+final router = GoRouter(
+ initialLocation: '/login',
+ navigatorKey: _rootNavigatorKey,
+ debugLogDiagnostics: true,
+ observers: [GoRouterObserver()],
+ refreshListenable: StreamToListenable([locator<AuthenticationRepository>().broadcast]),
+ redirect: (context, state) async {
+ final authRepo = locator<AuthenticationRepository>();
+ final status = authRepo.statusBuffer;
+ final isAuthenticated = status == AuthenticationStatus.authenticated;
+ final isUnAuthenticated =
+ status == AuthenticationStatus.unauthenticated ||
+ status == AuthenticationStatus.forcedUnauthenticated;
- return GoRouter(
- initialLocation: '/login',
- navigatorKey: _rootNavigatorKey,
- debugLogDiagnostics: true,
- observers: [GoRouterObserver()],
- refreshListenable: StreamToListenable([authRepo.broadcast]),
- redirect: (context, state) async {
- final status = authRepo.statusBuffer;
- final isAuthenticated = status == AuthenticationStatus.authenticated;
- final isUnAuthenticated =
- status == AuthenticationStatus.unauthenticated ||
- status == AuthenticationStatus.forcedUnauthenticated;
+ if (status == AuthenticationStatus.unknown) {
+ bool doesTokenExist = await authRepo.doesTokenExist();
+ if (doesTokenExist) {
- if (status == AuthenticationStatus.unknown) {
- bool doesTokenExist = await authRepo.doesTokenExist();
- if (doesTokenExist) {
-
- authRepo.logIn();
- }
+ authRepo.logIn();
}
+ }
- // Redirect to the login page if the user is not authenticated, and if authenticated, do not show the login page
- if (isUnAuthenticated && !state.matchedLocation.contains("/login")) {
- final forced = status == AuthenticationStatus.forcedUnauthenticated;
+ // Redirect to the login page if the user is not authenticated, and if authenticated, do not show the login page
+ if (isUnAuthenticated && !state.matchedLocation.contains("/login")) {
+ final forced = status == AuthenticationStatus.forcedUnauthenticated;
- return "/login?forced=$forced";
- }
- // Redirect to the overview page if the user is authenticated
- else if (isAuthenticated && state.matchedLocation.contains("/login")) {
- return "/${AppRoutes.overview.name}";
- }
- return null;
- },
- routes: <RouteBase>[
+ return "/login?forced=$forced";
+ }
+ // Redirect to the overview page if the user is authenticated
+ else if (isAuthenticated && state.matchedLocation.contains("/login")) {
+ return "/${AppRoutes.overview.name}";
+ }
+ return null;
+ },
+ routes: <RouteBase>[
ShellRoute(
navigatorKey: _shellNavigatorKey,
parentNavigatorKey: _rootNavigatorKey,
@@ -638,4 +636,3 @@ GoRouter goRouter() {
);
}) */
]);
-}
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index 62ade0ee..7613f504 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -289,9 +289,11 @@ class Api {
.post<void>(ApiEndpoints.provisionKey, data: {'bookingId': bookingId});
}
- Future<BookingDTO?> getBookingDetails(String bookingId) async {
+ Future<BookingDTO?> getBookingDetails(String bookingId, String hotelCode) async {
final response =
- await dio.get<Json>('${ApiEndpoints.getBookingDetails}$bookingId');
+ await dio.get<Json>('${ApiEndpoints.getBookingDetails}$bookingId?hotelCode=$hotelCode');
+
+
return BookingDTO.fromJson(response.data!);
}
@@ -307,6 +309,8 @@ class Api {
return response.data!;
}
+
+
Future<UpSalesDTO> fetchUpSales(
String confirmationId, String hotelCode) async {
final body = {
diff --git a/comwell_key_app/test/overview_test/overview_cubic_test.dart b/comwell_key_app/test/overview_test/overview_cubic_test.dart
index ffae621a..2bdf9133 100644
--- a/comwell_key_app/test/overview_test/overview_cubic_test.dart
+++ b/comwell_key_app/test/overview_test/overview_cubic_test.dart
@@ -28,10 +28,9 @@ void main() {
build: () {
when(() => mockOverviewRepository.fetchAllBookingsForUser())
.thenAnswer((_) async => Bookings(
- current: [
+ bookings: [
Booking(
id: '1',
- bookingStatus: BookingStatus.current,
confirmationId: "s",
roomNumber: '',
startDate: DateTime(2021, 10, 10),
@@ -52,8 +51,6 @@ void main() {
rooms: const [],
addOnItems: const [])
],
- past: const [],
- cancelled: const [],
));
return overviewCubit;
},
@@ -62,10 +59,9 @@ void main() {
OverviewLoading(),
OverviewLoaded(
bookings: Bookings(
- current: [
+ bookings: [
Booking(
id: '1',
- bookingStatus: BookingStatus.current,
roomNumber: '',
startDate: DateTime(2021, 10, 10),
endDate: DateTime(2021, 10, 10),
@@ -86,8 +82,6 @@ void main() {
rooms: const [],
addOnItems: const [])
],
- past: const [],
- cancelled: const [],
),
),
],
@@ -114,14 +108,11 @@ void main() {
},
seed: () => const OverviewLoaded(
bookings: Bookings(
- current: [],
- past: [],
- cancelled: [],
+ bookings: [],
),
),
- act: (cubit) => cubit.addBooking(Booking(
+ act: (cubit) => cubit.addBooking(Booking(
id: '1',
- bookingStatus: BookingStatus.current,
roomNumber: '',
startDate: DateTime(2021, 10, 10),
endDate: DateTime(2021, 10, 10),
@@ -144,10 +135,9 @@ void main() {
expect: () => [
OverviewLoaded(
bookings: Bookings(
- current: [
+ bookings: [
Booking(
id: '1',
- bookingStatus: BookingStatus.current,
roomNumber: '',
startDate: DateTime(2021, 10, 10),
endDate: DateTime(2021, 10, 10),
@@ -168,8 +158,6 @@ void main() {
rooms: const [],
addOnItems: const [])
],
- past: const [],
- cancelled: const [],
),
),
],
diff --git a/comwell_key_app/test/overview_test/overview_repository_test.dart b/comwell_key_app/test/overview_test/overview_repository_test.dart
index ca8c2e6e..75cc8caf 100644
--- a/comwell_key_app/test/overview_test/overview_repository_test.dart
+++ b/comwell_key_app/test/overview_test/overview_repository_test.dart
@@ -18,10 +18,9 @@ void main() {
test('fetchAllBookingsForUser returns Bookings', () async {
const userId = '1';
final bookings = Bookings(
- current: [
+ bookings: [
Booking(
id: '1',
- bookingStatus: BookingStatus.current,
roomNumber: '101',
startDate: DateTime.now(),
endDate: DateTime.now().add(const Duration(days: 1)),
@@ -43,8 +42,6 @@ void main() {
addOnItems: const []
),
],
- past: const [],
- cancelled: const [],
);
when(() => overviewRepository.fetchAllBookingsForUser())
@@ -62,7 +59,6 @@ void main() {
const lastName = 'Doe';
final booking = Booking(
id: '1',
- bookingStatus: BookingStatus.current,
roomNumber: '101',
startDate: DateTime.now(),
confirmationId: "",