6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 212e3c1a

AuthorEdmir Suljic<esu@dwarf.dk>
Date2025-05-08 11:05:55 +0200
No major changes

Changed files

.../lib/check_in/bloc/check_in_cubit.dart          |  2 +-
 .../lib/check_in/check_in_repository.dart          | 16 ++++++++--
 .../past_cancelled_booking_detail_page.dart        |  1 +
 comwell_key_app/lib/profile/profile_page.dart      |  2 +-
 comwell_key_app/lib/services/api.dart              | 37 +++++++++-------------
 5 files changed, 32 insertions(+), 26 deletions(-)

Diff

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 8c5e20e7..b93feced 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
@@ -18,7 +18,7 @@ class CheckInCubit extends Cubit<CheckInState> {
await Future<void>.delayed(const Duration(milliseconds: 500));
emit(state.checkInStatusLoading());
await _checkInRepository.checkIn(booking.confirmationId);
- //await _checkInRepository.checkIfSetup();
+ await _checkInRepository.checkIfSetup();
await tryGetKeys();
emit(state.checkInStatusRoomFound(roomNumber: booking.roomNumber));
await Future<void>.delayed(const Duration(milliseconds: 1000));
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 237a11d3..daf95b65 100644
--- a/comwell_key_app/lib/check_in/check_in_repository.dart
+++ b/comwell_key_app/lib/check_in/check_in_repository.dart
@@ -9,6 +9,7 @@ import 'package:comwell_key_app/services/mappers/booking_mapper.dart';
import 'package:comwell_key_app/services/models/booking_dto.dart';
import 'package:comwell_key_app/utils/json.dart';
import 'package:comwell_key_app/utils/locator.dart';
+import 'package:dio/dio.dart';
import '../utils/seos_repository.dart';
@@ -19,8 +20,19 @@ class CheckInRepository {
final profileRepository = locator<ProfileRepository>();
Future<void> checkIn(String confirmationId) async {
- final response = await api.checkIn(confirmationId);
- print("response in checkInRepository: $response");
+ try {
+ final response = await api.checkIn(confirmationId);
+ print("response in checkInRepository: ${response.data}");
+ } on DioException catch (err) {
+ if (err.response?.data != null) {
+ final errorData = err.response?.data as Map<String, dynamic>;
+ throw Exception("${errorData['title']}: ${errorData['detail']}");
+ }
+ throw Exception("Failed to check in: ${err.message}");
+ } catch (err, st) {
+ print("error in checkInRepository: $err, $st");
+ throw Exception("An unexpected error occurred during check-in");
+ }
}
Future<Booking> getBookingDetails(String bookingId) async {
diff --git a/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart b/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart
index 6922061a..43fcf9da 100644
--- a/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart
+++ b/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart
@@ -15,6 +15,7 @@ class PastCancelledBookingDetailPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
+ print("booking: $booking");
return Scaffold(
appBar: const ComwellAppBar(
shouldShowProfileButton: false,
diff --git a/comwell_key_app/lib/profile/profile_page.dart b/comwell_key_app/lib/profile/profile_page.dart
index c7b40d8b..1601e42d 100644
--- a/comwell_key_app/lib/profile/profile_page.dart
+++ b/comwell_key_app/lib/profile/profile_page.dart
@@ -47,7 +47,7 @@ class ProfilePage extends StatelessWidget {
Widget _buildProfilePage(ProfileCubit cubit, BuildContext context) {
final user = cubit.state.user;
- final isActive = cubit.state.user!.clubLevel != 'L1';
+ final isActive = cubit.state.user!.clubLevel != '';
return SafeArea(
child: Column(
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index b6bd15bf..e68ef8e8 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -31,7 +31,6 @@ class Api {
Future<BookingsDTO> fetchAllBookingsForUser() async {
final response = await dio.get<Json>(ApiEndpoints.getCurrentBookings);
- print("response in api: $response");
return BookingsDTO.fromJson(response.data!);
}
@@ -59,7 +58,7 @@ class Api {
"x-API-key":
"AQEohmfuXNWTK0Qc+iSTnWkvouiXYIRZCJ9ZsI49DtvZ0d3gjdIA7pissxDBXVsNvuR83LVYjEgiTGAH-4HQnMZXxLZfhge7EdwYZZW0ynntChj41ziiKl6D1Glo=-.\$>;9&L_t@^g7[IR"
};
- final Map<String, dynamic> data = {
+ final Map<String, dynamic> data = {
"shopperReference": "Test reference",
"amount": {"value:": 0, "currency": "DKK"},
"countryCode": "DK",
@@ -70,19 +69,17 @@ class Api {
};
data.addAll(paymentResult);
data.remove("storePaymentMethod");
- final response =
- await dio.post<Json>(ApiEndpoints.adyenPayments,
- data: data,
- options: Options(
- headers: headers,
- ));
+ final response = await dio.post<Json>(ApiEndpoints.adyenPayments,
+ data: data,
+ options: Options(
+ headers: headers,
+ ));
return response.data!;
}
Future<Response<dynamic>> fetchProfileSettings() async {
print("fetching profile settings");
final response = await dio.get(ApiEndpoints.getGuestProfile);
- print("response in api: $response");
return response;
}
@@ -92,13 +89,10 @@ class Api {
Future<Response<dynamic>> signupForComwellClub(User user) async {
final zipCode = user.address.zipCode;
- final body = {
- "gender": user.gender,
- "addressZip": zipCode
- };
+ final body = {"gender": user.gender, "addressZip": zipCode};
final json = jsonEncode(body);
- print("json in api: $json");
- final response = await dio.post<dynamic>(ApiEndpoints.clubSignup, data: json);
+ final response =
+ await dio.post<dynamic>(ApiEndpoints.clubSignup, data: json);
return response;
}
@@ -108,7 +102,8 @@ class Api {
};
final json = jsonEncode(body);
- final response = await dio.post<dynamic>(ApiEndpoints.preRegistration, data: json);
+ final response =
+ await dio.post<dynamic>(ApiEndpoints.preRegistration, data: json);
return response;
}
@@ -157,14 +152,13 @@ class Api {
return response;
}
- Future<dynamic> checkIn(String confirmationId) async {
- print("checking in with confirmationId: $confirmationId");
+ Future<Response<dynamic>> checkIn(String confirmationId) async {
final body = {
"confirmationId": confirmationId,
};
final json = jsonEncode(body);
- final response = await dio.post<dynamic>(ApiEndpoints.checkIn,
- data: json);
+ final response = await dio.post<dynamic>(ApiEndpoints.checkIn, data: json);
+ print("response in api: ${response.data}");
return response;
}
@@ -192,8 +186,7 @@ class Api {
};
data.addAll(body);
data.remove("storePaymentMethod");
- final response = await dio.post<Json>(
- ApiEndpoints.adyenPaymentsDetails,
+ final response = await dio.post<Json>(ApiEndpoints.adyenPaymentsDetails,
data: data,
options: Options(
headers: headers,