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

AuthorEdmir Suljic<esu@dwarf.dk>
Date2025-05-26 10:16:05 +0200
Work in progress

Changed files

.../.generated/services/models/booking_dto.g.dart  |  10 +-
 .../lib/.generated/services/models/user_dto.g.dart |   2 +-
 .../booking_details/bloc/booking_details_bloc.dart |  18 +-
 .../bloc/booking_details_state.dart                |  17 +-
 .../lib/booking_details/booking_details_page.dart  | 249 +++++++++++----------
 .../components/preregister_button.dart             |  89 ++++----
 .../lib/check_in/check_in_repository.dart          |   2 +-
 .../lib/my_booking/my_booking_page.dart            |   2 +-
 comwell_key_app/lib/overview/models/booking.dart   |  20 +-
 .../overview/repository/overview_repository.dart   |   4 +-
 .../pregistration/bloc/preregistration_cubit.dart  |  21 +-
 .../pregistration/bloc/preregistration_state.dart  |  18 +-
 .../pregistration/pages/prereg_profile_page.dart   |  71 ++++--
 comwell_key_app/lib/profile/profile_page.dart      |   3 +-
 .../lib/profile/profile_repository.dart            |   5 +-
 .../components/intl_phone_field.dart               |  16 +-
 .../cubit/profile_settings_cubit.dart              |  32 ++-
 .../profile_settings/profile_settings_page.dart    |  43 ++--
 .../repostiory/profile_settings_repository.dart    |   2 +
 comwell_key_app/lib/services/api.dart              |   1 +
 .../lib/services/mappers/booking_mapper.dart       |   4 +-
 .../lib/services/mappers/bookings_mapper.dart      |   6 +-
 .../lib/services/models/booking_dto.dart           |  10 +-
 comwell_key_app/lib/services/models/user_dto.dart  |   2 +-
 comwell_key_app/lib/utils/phone_utils.dart         |   7 +-
 25 files changed, 395 insertions(+), 259 deletions(-)

Diff

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 7d95bc1e..2a96ed75 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
@@ -14,15 +14,15 @@ BookingDTO _$BookingDTOFromJson(Map json) => BookingDTO(
confirmationNumber: json['confirmationNumber'] as String,
hmsConfirmationNumber: json['hmsConfirmationNumber'] as String,
dayIn: json['dayIn'] as String,
- dayOut: json['dayOut'] as String,
- cancelTime: json['cancelTime'] as String,
+ dayOut: json['dayOut'] as String?,
+ cancelTime: json['cancelTime'] as String?,
status: json['status'] as String,
- isCancelled: json['isCancelled'] as bool,
- bookTime: json['bookTime'] as String,
+ isCancelled: json['isCancelled'] as bool?,
+ bookTime: json['bookTime'] as String?,
roomType: json['roomType'] as String,
adults: (json['adults'] as num).toInt(),
children: (json['children'] as num).toInt(),
- totalCharge: json['totalCharge'] as num,
+ totalCharge: json['totalCharge'] as num?,
balance: json['balance'] as num?,
maskedCardNumber: json['maskedCardNumber'] as String?,
);
diff --git a/comwell_key_app/lib/.generated/services/models/user_dto.g.dart b/comwell_key_app/lib/.generated/services/models/user_dto.g.dart
index bd8e6e18..8b296faa 100644
--- a/comwell_key_app/lib/.generated/services/models/user_dto.g.dart
+++ b/comwell_key_app/lib/.generated/services/models/user_dto.g.dart
@@ -22,7 +22,7 @@ UserDto _$UserDtoFromJson(Map json) => UserDto(
addressCity: json['addressCity'] as String,
addressCountry: json['addressCountry'] as String,
points: (json['points'] as num?)?.toInt(),
- locale: json['locale'] as String,
+ locale: json['locale'] as String?,
);
Map<String, dynamic> _$UserDtoToJson(UserDto instance) => <String, dynamic>{
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 c31d37be..13139b5b 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
@@ -16,7 +16,7 @@ part 'booking_details_state.dart';
class BookingDetailsBloc
extends Bloc<BookingDetailsEvent, BookingDetailsState> {
- final Booking booking;
+ late Booking booking;
final BookingDetailsRepository bookingDetailsRepository;
final ProfileRepository profileRepository;
@@ -29,9 +29,10 @@ class BookingDetailsBloc
}) : super(BookingDetailsState.initial(booking)) {
on<InitialEvent>((event, emit) async {
try {
+ emit(state.loading());
await checkIfHouseKeepingOrdered(emit);
await checkMobileKeys(emit);
- await getBookingDetails();
+ booking = await getBookingDetails(emit);
} catch (e, st) {
if (kDebugMode) print("err=$e, $st");
emit(state.setupError());
@@ -47,9 +48,16 @@ class BookingDetailsBloc
});
}
- Future<Booking> getBookingDetails() async {
- final bookingDetails = await profileRepository.getBookingDetails(booking.confirmationId);
- return bookingDetails;
+ Future<Booking> getBookingDetails(Emitter<BookingDetailsState> emit) async {
+ try {
+ final bookingDetails = await profileRepository.getBookingDetails(booking.confirmationId);
+ emit(state.copyWith(status: BookingDetailsStatus.main));
+ return bookingDetails;
+ } catch (e) {
+ if (kDebugMode) print("err=$e");
+ emit(state.setupError());
+ rethrow;
+ }
}
Future<void> checkMobileKeys(Emitter<BookingDetailsState> emit) async {
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 645a1848..4828f296 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
@@ -6,13 +6,15 @@ class BookingDetailsState extends Equatable {
final MobileKeysKey? key;
final List<MobileKeysKey> keys;
final Iterable<Guest> guests;
+ final bool isLoading;
const BookingDetailsState._(
{required this.status,
required this.key,
required this.keys,
required this.isHouseKeepingOrdered,
- required this.guests});
+ required this.guests,
+ required this.isLoading});
BookingDetailsState.initial(Booking booking)
: this._(
@@ -20,7 +22,8 @@ class BookingDetailsState extends Equatable {
key: null,
keys: [],
isHouseKeepingOrdered: false,
- guests: booking.guests);
+ guests: booking.guests,
+ isLoading: false);
BookingDetailsState setupError() =>
copyWith(status: BookingDetailsStatus.setupError);
BookingDetailsState updateKeys(List<MobileKeysKey> keys) =>
@@ -30,11 +33,12 @@ class BookingDetailsState extends Equatable {
isHouseKeepingOrdered: true);
BookingDetailsState updateGuests(Iterable<Guest> guests) =>
copyWith(status: BookingDetailsStatus.guestsUpdated, guests: guests);
+ BookingDetailsState loading() => copyWith(status: BookingDetailsStatus.loading);
BookingDetailsState main() => copyWith(status: BookingDetailsStatus.main);
@override
- List<Object?> get props => [status, guests];
+ List<Object?> get props => [status, guests, isLoading];
BookingDetailsState copyWith({
BookingDetailsStatus? status,
@@ -42,6 +46,7 @@ class BookingDetailsState extends Equatable {
List<MobileKeysKey>? keys,
bool? isHouseKeepingOrdered,
Iterable<Guest>? guests,
+ bool? isLoading,
}) {
return BookingDetailsState._(
status: status ?? this.status,
@@ -50,12 +55,13 @@ class BookingDetailsState extends Equatable {
isHouseKeepingOrdered:
isHouseKeepingOrdered ?? this.isHouseKeepingOrdered,
guests: guests ?? this.guests,
+ isLoading: isLoading ?? this.isLoading,
);
}
@override
String toString() {
- return "BookingDetailsState(status=$status, key=$key, keys=$keys, isHouseKeepingOrdered=$isHouseKeepingOrdered)";
+ return "BookingDetailsState(status=$status, key=$key, keys=$keys, isHouseKeepingOrdered=$isHouseKeepingOrdered, isLoading=$isLoading)";
}
}
@@ -65,5 +71,6 @@ enum BookingDetailsStatus {
keysUpdated,
guestsUpdated,
main,
- houseKeepingOrdered
+ houseKeepingOrdered,
+ loading,
}
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 dac11c18..6aaa2cdd 100644
--- a/comwell_key_app/lib/booking_details/booking_details_page.dart
+++ b/comwell_key_app/lib/booking_details/booking_details_page.dart
@@ -5,6 +5,7 @@ import 'package:comwell_key_app/common/components/bottom_sheet_widget.dart';
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
import 'package:comwell_key_app/booking_details/components/housekeeping_button.dart';
import 'package:comwell_key_app/booking_details/components/practical_information_button.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -21,133 +22,151 @@ class BookingDetailsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final theme = Theme.of(context);
return BlocConsumer<BookingDetailsBloc, BookingDetailsState>(
listener: (context, state) {},
builder: (context, state) {
final cubit = context.read<BookingDetailsBloc>();
+
+ print("state: ${cubit.booking.reservationStatus}");
+
if (state.status == BookingDetailsStatus.initial) {
cubit.add(InitialEvent());
}
return Scaffold(
- extendBodyBehindAppBar: true,
- backgroundColor: sandColor[40],
- appBar: const ComwellAppBar(),
- body: Stack(
- children: [
- Container(
- decoration: const BoxDecoration(
- image: DecorationImage(
- image: AssetImage('assets/images/booking_background.png'),
- fit: BoxFit.cover,
- ),
+ extendBodyBehindAppBar: true,
+ backgroundColor: sandColor[40],
+ appBar: const ComwellAppBar(),
+ body: Builder(
+ builder: (context) {
+ if (state.status == BookingDetailsStatus.loading) {
+ return Center(
+ child: CircularProgressIndicator(),
+ );
+ } else {
+ return _buildBookingDetailsPage(context, state, cubit);
+ }
+ },
+ ));
+ },
+ );
+ }
+
+ Widget _buildBookingDetailsPage(BuildContext context,
+ BookingDetailsState state, BookingDetailsBloc cubit) {
+ final theme = Theme.of(context);
+ return Stack(
+ children: [
+ Container(
+ decoration: const BoxDecoration(
+ image: DecorationImage(
+ image: AssetImage('assets/images/booking_background.png'),
+ fit: BoxFit.cover,
+ ),
+ ),
+ ),
+ Container(
+ decoration: const BoxDecoration(
+ gradient: LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [
+ Colors.black26,
+ Colors.black54,
+ ],
+ ),
+ ),
+ ),
+ Stack(
+ alignment: Alignment.center,
+ children: [
+ SafeArea(
+ child: ShareButton(guests: state.guests),
+ ),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ const Spacer(),
+ if (cubit.booking.roomNumber != '')
+ _buildRoomNumberContainer(context, theme, cubit),
+ _buildBookingDetails(context, state, cubit, theme),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: Divider(color: Colors.grey[400]),
),
- ),
- Container(
- decoration: const BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: [
- Colors.black26,
- Colors.black54,
- ],
- ),
+ const SizedBox(height: 10),
+ if (state.keys.isNotEmpty && cubit.booking.roomNumber != '')
+ const UnlockRoomButton()
+ else if (cubit.booking.reservationStatus ==
+ ReservationStatus.preregistered)
+ const CheckInButton(),
+ if (cubit.booking.reservationStatus ==
+ ReservationStatus.newreservation)
+ const PreregisterButton(),
+ const SizedBox(
+ height: 100,
),
- ),
- Stack(
- alignment: Alignment.center,
- children: [
- SafeArea(
- child: ShareButton(guests: state.guests),
+ ],
+ ),
+ BottomSheetWidget(
+ widgetChildren: [
+ cubit.booking.roomNumber != ''
+ ? HousekeepingButton(
+ key: ValueKey(state.isHouseKeepingOrdered),
+ roomNumber: cubit.booking.roomNumber)
+ : const SizedBox(),
+ const SizedBox(height: 20),
+ const CheckOutButton(),
+ const SizedBox(height: 20),
+ Text("booking_details_page_practical_information".tr()),
+ const SizedBox(height: 20),
+ Row(children: [
+ Expanded(
+ child: AspectRatio(
+ aspectRatio: 175 / 220,
+ child: PracticalInformationButton(
+ iconPath: "assets/icons/ic_bed.svg",
+ title:
+ "booking_details_page_hotel_information_button_title"
+ .tr(),
+ subtitle:
+ "booking_details_page_hotel_information_button_subtitle"
+ .tr(),
+ onClick: () {
+ context.pushNamed(AppRoutes.hotelInformation.name);
+ }),
+ ),
),
- Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- const Spacer(),
- if (cubit.booking.roomNumber != '')
- _buildRoomNumberContainer(context, theme, cubit),
- _buildBookingDetails(context, state, cubit, theme),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: Divider(color: Colors.grey[400]),
- ),
- const SizedBox(height: 10),
- if (state.keys.isNotEmpty &&
- cubit.booking.roomNumber != '')
- const UnlockRoomButton()
- else
- const CheckInButton(),
- const SizedBox(
- height: 100,
- ),
- ],
+ const SizedBox(width: 8),
+ Expanded(
+ child: AspectRatio(
+ aspectRatio: 175 / 220,
+ child: PracticalInformationButton(
+ iconPath: "assets/icons/ic_telephone.svg",
+ title:
+ "booking_details_page_contact_button_title".tr(),
+ subtitle:
+ "booking_details_page_contact_button_subtitle"
+ .tr(),
+ onClick: () {
+ context.pushNamed(AppRoutes.contact.name);
+ }),
+ ),
),
- BottomSheetWidget(
- widgetChildren: [
- cubit.booking.roomNumber != ''
- ? HousekeepingButton(
- key: ValueKey(state.isHouseKeepingOrdered),
- roomNumber: cubit.booking.roomNumber)
- : const SizedBox(),
- const SizedBox(height: 20),
- const CheckOutButton(),
- const SizedBox(height: 20),
- Text("booking_details_page_practical_information".tr()),
- const SizedBox(height: 20),
- Row(children: [
- Expanded(
- child: AspectRatio(
- aspectRatio: 175 / 220,
- child: PracticalInformationButton(
- iconPath: "assets/icons/ic_bed.svg",
- title:
- "booking_details_page_hotel_information_button_title"
- .tr(),
- subtitle:
- "booking_details_page_hotel_information_button_subtitle"
- .tr(),
- onClick: () {
- context.pushNamed(
- AppRoutes.hotelInformation.name);
- }),
- ),
- ),
- const SizedBox(width: 8),
- Expanded(
- child: AspectRatio(
- aspectRatio: 175 / 220,
- child: PracticalInformationButton(
- iconPath: "assets/icons/ic_telephone.svg",
- title:
- "booking_details_page_contact_button_title"
- .tr(),
- subtitle:
- "booking_details_page_contact_button_subtitle"
- .tr(),
- onClick: () {
- context.pushNamed(AppRoutes.contact.name);
- }),
- ),
- ),
- ]),
- const SizedBox(height: 16),
- Text('rooms'.tr()),
- const SizedBox(height: 16),
- const PreregisterButton(),
- const SizedBox(height: 16),
- Text('room_keys'.tr()),
- const SizedBox(height: 400),
- ],
- )
- ],
- )
- ],
- ),
- );
- },
+ ]),
+ const SizedBox(height: 16),
+ Text('rooms'.tr()),
+ const SizedBox(height: 16),
+ const PreregisterButton(),
+ const SizedBox(height: 16),
+ Text('room_keys'.tr()),
+ const SizedBox(height: 400),
+ ],
+ )
+ ],
+ )
+ ],
);
}
@@ -162,7 +181,6 @@ class BookingDetailsPage extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(32),
border: Border.all(color: Colors.white, width: 2),
-
),
child: Text(
'room_prefix'.tr(args: [cubit.booking.roomNumber]),
@@ -178,7 +196,6 @@ class BookingDetailsPage extends StatelessWidget {
Widget _buildBookingDetails(BuildContext context, BookingDetailsState state,
BookingDetailsBloc cubit, ThemeData theme) {
-
return InkWell(
onTap: () {
context.pushNamed(AppRoutes.myBooking.name, extra: cubit.booking);
diff --git a/comwell_key_app/lib/booking_details/components/preregister_button.dart b/comwell_key_app/lib/booking_details/components/preregister_button.dart
index 503ecdc0..e8708a99 100644
--- a/comwell_key_app/lib/booking_details/components/preregister_button.dart
+++ b/comwell_key_app/lib/booking_details/components/preregister_button.dart
@@ -14,50 +14,53 @@ class PreregisterButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final bloc = context.read<BookingDetailsBloc>();
- return ElevatedButton(
- onPressed: () {
- context.pushNamed(AppRoutes.preregistration.name,
- extra: bloc.booking);
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: sandColor[80],
- textStyle: const TextStyle(
- color: Colors.white,
- fontSize: 16,
- fontWeight: FontWeight.w600,
+ return Container(
+ margin: const EdgeInsets.symmetric(horizontal: 10),
+ child: ElevatedButton(
+ onPressed: () {
+ context.pushNamed(AppRoutes.preregistration.name,
+ extra: bloc.booking);
+ },
+ style: ElevatedButton.styleFrom(
+ backgroundColor: sandColor[80],
+ textStyle: const TextStyle(
+ color: Colors.white,
+ fontSize: 16,
+ fontWeight: FontWeight.w600,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(30),
+ ),
),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(30),
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 8.0),
- child: Row(
- children: [
- SvgPicture.asset("assets/icons/ic_exit.svg"),
- const SizedBox(width: 16),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- "prepare_room".tr(),
- style: Theme
- .of(context)
- .textTheme
- .titleMedium
- ?.copyWith(color: Colors.white),
- ),
- Text(
- "jump_line_text".tr(),
- style: Theme
- .of(context)
- .textTheme
- .bodySmall
- ?.copyWith(color: Colors.white),
- ),
- ],
- )
- ],
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 8.0),
+ child: Row(
+ children: [
+ SvgPicture.asset("assets/icons/ic_exit.svg"),
+ const SizedBox(width: 16),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ "prepare_room".tr(),
+ style: Theme
+ .of(context)
+ .textTheme
+ .titleMedium
+ ?.copyWith(color: Colors.white),
+ ),
+ Text(
+ "jump_line_text".tr(),
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodySmall
+ ?.copyWith(color: Colors.white),
+ ),
+ ],
+ )
+ ],
+ ),
),
),
);
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 2a0dc4ff..0a6f621e 100644
--- a/comwell_key_app/lib/check_in/check_in_repository.dart
+++ b/comwell_key_app/lib/check_in/check_in_repository.dart
@@ -63,7 +63,7 @@ class CheckInRepository {
startDate: DateTime.now(),
endDate: DateTime.now(),
status: BookingStatus.current,
- reservationStatus: ReservationStatus.newReservation,
+ reservationStatus: ReservationStatus.newreservation,
image: "",
hotelName: "hotelName",
roomType: "roomType",
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 9b07733c..d46855d1 100644
--- a/comwell_key_app/lib/my_booking/my_booking_page.dart
+++ b/comwell_key_app/lib/my_booking/my_booking_page.dart
@@ -88,7 +88,7 @@ class MyBookingPage extends StatelessWidget {
isScrollControlled: true,
context: context,
builder: (context) => BalanceBottomSheet(
- balance: booking.totalCharge,
+ balance: booking.totalCharge ?? 0,
userName: booking.booker.name,
booking: booking,
items: [
diff --git a/comwell_key_app/lib/overview/models/booking.dart b/comwell_key_app/lib/overview/models/booking.dart
index 48fab78e..ce9096a9 100644
--- a/comwell_key_app/lib/overview/models/booking.dart
+++ b/comwell_key_app/lib/overview/models/booking.dart
@@ -20,7 +20,7 @@ class Booking extends Equatable {
final DateTime bookingDate;
final bool digitalCard;
final Iterable<Guest> guests;
- final num totalCharge;
+ final num? totalCharge;
final num? balance;
final String? maskedCardNumber;
@@ -140,17 +140,23 @@ class Booking extends Equatable {
}
enum ReservationStatus {
- checkedIn,
- checkedOut,
+ checkedin,
+ checkedout,
cancelled,
- noShow,
- newReservation,
+ noshow,
+ newreservation,
preregistered,
unknown;
static ReservationStatus fromString(String value) {
- return ReservationStatus.values
- .firstWhere((status) => status.name == value);
+ print("value: ${value.toLowerCase()}");
+ if (value.toLowerCase() == 'new') {
+ return ReservationStatus.newreservation;
+ }
+ final status = ReservationStatus.values.firstWhere(
+ (status) => status.name.toLowerCase() == value.toLowerCase());
+ print("status: $status");
+ return status;
}
}
diff --git a/comwell_key_app/lib/overview/repository/overview_repository.dart b/comwell_key_app/lib/overview/repository/overview_repository.dart
index 5bbbd0b0..df9c0fa3 100644
--- a/comwell_key_app/lib/overview/repository/overview_repository.dart
+++ b/comwell_key_app/lib/overview/repository/overview_repository.dart
@@ -53,7 +53,7 @@ class OverviewRepository {
totalCharge: 12345,
balance: 0,
maskedCardNumber: "1234567890");
- return dto.toBooking(user.id, BookingStatus.current, ReservationStatus.newReservation);
+ return dto.toBooking(user.id, BookingStatus.current, ReservationStatus.newreservation);
}
}
@@ -64,7 +64,7 @@ final mockBookings = [1, 2, 3].map((i) => Booking(
startDate: DateTime.now(),
endDate: DateTime.now(),
status: BookingStatus.current,
- reservationStatus: ReservationStatus.newReservation,
+ reservationStatus: ReservationStatus.newreservation,
image: "assets/images/no_current_bookings_background.jpeg",
hotelName: "hotelName$i",
roomType: "roomType$i",
diff --git a/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart b/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart
index ab463007..0d951972 100644
--- a/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart
+++ b/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart
@@ -177,7 +177,7 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
Future.delayed(const Duration(seconds: 3), () {
emit(state.copyWith(loading: false));
if (!context.mounted) return;
- context.pushReplacementNamed(AppRoutes.bookingDetails.name);
+ context.pushReplacementNamed(AppRoutes.bookingDetails.name, extra: booking);
});
}
@@ -197,6 +197,16 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
// Not implemented
}
+ void onPhoneNumberChanged(String phoneNumber) {
+ phoneNumberTextController.text = phoneNumber;
+ print("isPhoneNumberValid: $isPhoneNumberValid");
+ emit(state.copyWith(isPhoneNumberValid: isPhoneNumberValid));
+ }
+
+ void onCountryCodeSelected(CountryCode countryCode) {
+ countryCode = countryCode;
+ }
+
bool onBackClicked() {
if (_isAnimating) return true;
final hasPage = pageController.page != null;
@@ -252,12 +262,19 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
bool get isCityValid => cityTextController.text.isNotEmpty;
+ bool get isPhoneNumberValid => phoneNumberTextController.text.isNotEmpty && phoneNumberTextController.text.length > 9 && phoneNumberTextController.text.length < 16;
+
+ bool get isFirstNameValid => firstNameTextController.text.isNotEmpty;
+
+ bool get isLastNameValid => lastNameTextController.text.isNotEmpty;
+
+
bool get canContinue {
int page = pageController.page?.ceil() ?? 0;
final preregPage = PreregistrationPage.fromIndex(page);
switch (preregPage) {
case PreregistrationPage.profile:
- return true;
+ return isFirstNameValid && isLastNameValid && isPhoneNumberValid;
case PreregistrationPage.address:
return isAddressValid || isPostalCodeValid || isCityValid;
case PreregistrationPage.payment:
diff --git a/comwell_key_app/lib/pregistration/bloc/preregistration_state.dart b/comwell_key_app/lib/pregistration/bloc/preregistration_state.dart
index 5d17409e..707f2afd 100644
--- a/comwell_key_app/lib/pregistration/bloc/preregistration_state.dart
+++ b/comwell_key_app/lib/pregistration/bloc/preregistration_state.dart
@@ -15,6 +15,10 @@ class PreregistrationState extends Equatable {
final int numOfExtras;
final int extrasTotalPrice;
final bool termsAndConditionsAccepted;
+ final bool isPhoneNumberValid;
+ final bool isFirstNameValid;
+ final bool isLastNameValid;
+
PreregistrationState({
required this.loading,
@@ -27,6 +31,9 @@ class PreregistrationState extends Equatable {
this.error,
this.phoneNumber,
this.countryCode,
+ this.isPhoneNumberValid = false,
+ this.isFirstNameValid = false,
+ this.isLastNameValid = false,
});
@override
@@ -41,6 +48,9 @@ class PreregistrationState extends Equatable {
extrasTotalPrice,
termsAndConditionsAccepted,
forceUpdate,
+ isPhoneNumberValid,
+ isFirstNameValid,
+ isLastNameValid,
];
PreregistrationState copyWith({
@@ -54,6 +64,9 @@ class PreregistrationState extends Equatable {
String? buttonTextStringId,
bool? termsAndConditionsAccepted,
bool forceUpdate = false,
+ bool? isPhoneNumberValid,
+ bool? isFirstNameValid,
+ bool? isLastNameValid,
}) {
return PreregistrationState(
forceUpdate: forceUpdate ? !this.forceUpdate : this.forceUpdate,
@@ -66,6 +79,9 @@ class PreregistrationState extends Equatable {
extrasTotalPrice: extrasTotalPrice ?? this.extrasTotalPrice,
error: error,
phoneNumber: phoneNumber ?? this.phoneNumber,
- countryCode: countryCode);
+ countryCode: countryCode,
+ isPhoneNumberValid: isPhoneNumberValid ?? this.isPhoneNumberValid,
+ isFirstNameValid: isFirstNameValid ?? this.isFirstNameValid,
+ isLastNameValid: isLastNameValid ?? this.isLastNameValid);
}
}
diff --git a/comwell_key_app/lib/pregistration/pages/prereg_profile_page.dart b/comwell_key_app/lib/pregistration/pages/prereg_profile_page.dart
index fde6780c..1b4d76af 100644
--- a/comwell_key_app/lib/pregistration/pages/prereg_profile_page.dart
+++ b/comwell_key_app/lib/pregistration/pages/prereg_profile_page.dart
@@ -1,5 +1,5 @@
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
-import 'package:comwell_key_app/profile_settings/components/comwell_text_field.dart';
+import 'package:comwell_key_app/common/components/comwell_text_field.dart';
import 'package:comwell_key_app/profile_settings/components/intl_phone_field.dart';
import 'package:comwell_key_app/pregistration/bloc/preregistration_cubit.dart';
import 'package:comwell_key_app/pregistration/bloc/preregistration_state.dart';
@@ -16,28 +16,45 @@ class PreregProfilePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
+ final cubit = context.read<PreregistrationCubit>();
return BlocBuilder<PreregistrationCubit, PreregistrationState>(
- builder: (context, state) {
- if (state.loading) {
- return const Center(child: CircularProgressIndicator());
- } else if (state.user != null) {
- return _buildProfilePage(theme, state, context);
- } else {
- return Center(
- child: Text(
- "generic_error".tr(),
- style: theme.textTheme.headlineLarge,
- ),
- );
- }
- },
- );
+ builder: (context, state) {
+ if (state.loading) {
+ return const Center(child: CircularProgressIndicator());
+ }
+ if (state.user != null) {
+ print("firstName: ${cubit.isFirstNameValid}");
+ print("lastName: ${cubit.isLastNameValid}");
+ print("phoneNumber: ${cubit.isPhoneNumberValid}");
+ return _buildProfilePage(theme, state, context);
+ }
+
+ return Center(
+ child: Text(
+ "generic_error".tr(),
+ style: theme.textTheme.headlineLarge,
+ ),
+ );
+ });
}
Widget _buildProfilePage(
ThemeData theme, PreregistrationState state, BuildContext context) {
final cubit = context.read<PreregistrationCubit>();
+ final firstNameErrorMessage =
+ !cubit.isFirstNameValid && state.missingInformation
+ ? "generic_information_required".tr()
+ : null;
+ final lastNameErrorMessage =
+ !cubit.isLastNameValid && state.missingInformation
+ ? "generic_information_required".tr()
+ : null;
+ final phoneNumberErrorMessage =
+ !cubit.isPhoneNumberValid && state.missingInformation
+ ? "generic_information_required".tr()
+ : null;
+
return ListView(children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -50,20 +67,33 @@ class PreregProfilePage extends StatelessWidget {
),
const SizedBox(height: 36),
ComwellTextField(
+ key: const Key("firstName"),
fieldName: "profile_settings_firstname".tr(),
initialValue: state.user!.firstName,
readOnly: false,
controller: cubit.firstNameTextController,
+ errorMessage: firstNameErrorMessage,
+ onChanged: (value) {
+ cubit.firstNameTextController.text = value;
+ cubit.emit(state.copyWith(forceUpdate: true));
+ },
),
const SizedBox(height: 8),
ComwellTextField(
+ key: const Key("lastName"),
fieldName: "profile_settings_lastname".tr(),
initialValue: state.user!.lastName,
readOnly: false,
controller: cubit.lastNameTextController,
+ errorMessage: lastNameErrorMessage,
+ onChanged: (value) {
+ cubit.lastNameTextController.text = value;
+ cubit.emit(state.copyWith(forceUpdate: true));
+ },
),
const SizedBox(height: 8),
ComwellTextField(
+ key: const Key("email"),
fieldName: "profile_settings_email".tr(),
initialValue: state.user!.email,
readOnly: true,
@@ -71,13 +101,18 @@ class PreregProfilePage extends StatelessWidget {
),
const SizedBox(height: 8),
IntlPhoneField(
+ key: const Key("phone"),
title: "profile_settings_phone".tr(),
phoneNumber: cubit.phoneNumber!,
countryCode: cubit.countryCode!,
controller: cubit.phoneNumberTextController,
readOnly: false,
- onChanged: (CountryCode countryCode) {
- cubit.countryCode = countryCode;
+ errorMessage: phoneNumberErrorMessage,
+ onCountryCodeSelected: (CountryCode countryCode) {
+ cubit.onCountryCodeSelected(countryCode);
+ },
+ onPhoneNumberChanged: (String phoneNumber) {
+ cubit.onPhoneNumberChanged(phoneNumber);
},
onSubmitted: (_) {},
),
diff --git a/comwell_key_app/lib/profile/profile_page.dart b/comwell_key_app/lib/profile/profile_page.dart
index 88ecfa17..76a664a4 100644
--- a/comwell_key_app/lib/profile/profile_page.dart
+++ b/comwell_key_app/lib/profile/profile_page.dart
@@ -21,7 +21,8 @@ class ProfilePage extends StatelessWidget {
body: BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
if (state.isLoading) {
- return const Center(child: CircularProgressIndicator());
+ return const
+ Center(child: CircularProgressIndicator());
} else if (state.error != null) {
return const ErrorPageWidget();
} else {
diff --git a/comwell_key_app/lib/profile/profile_repository.dart b/comwell_key_app/lib/profile/profile_repository.dart
index 9abf6336..bb8612ff 100644
--- a/comwell_key_app/lib/profile/profile_repository.dart
+++ b/comwell_key_app/lib/profile/profile_repository.dart
@@ -42,9 +42,12 @@ class ProfileRepository {
}
Future<Booking> getBookingDetails(String bookingId) async {
+ user = await fetchProfileSettings();
final response = await api.getBookingDetails(bookingId);
await db.bookingsDao.insertBookings(BookingsDTO(current: [response], past: [], cancelled: []));
- return response.toBooking(user.id, BookingStatus.current, ReservationStatus.newReservation);
+ final booking = response.toBooking(user.id, BookingStatus.current, ReservationStatus.fromString(response.status));
+ print("booking: ${booking}");
+ return booking;
}
Future<User> fetchProfileSettings() async {
diff --git a/comwell_key_app/lib/profile_settings/components/intl_phone_field.dart b/comwell_key_app/lib/profile_settings/components/intl_phone_field.dart
index b230ee5c..a3243201 100644
--- a/comwell_key_app/lib/profile_settings/components/intl_phone_field.dart
+++ b/comwell_key_app/lib/profile_settings/components/intl_phone_field.dart
@@ -10,7 +10,9 @@ class IntlPhoneField extends StatefulWidget {
final TextEditingController controller;
final bool readOnly;
final void Function(String)? onSubmitted;
- final void Function(CountryCode)? onChanged;
+ final void Function(CountryCode)? onCountryCodeSelected;
+ final void Function(String)? onPhoneNumberChanged;
+ final String? errorMessage;
const IntlPhoneField({
required this.title,
required this.phoneNumber,
@@ -18,7 +20,9 @@ class IntlPhoneField extends StatefulWidget {
required this.controller,
this.readOnly = false,
this.onSubmitted,
- this.onChanged,
+ this.onCountryCodeSelected,
+ this.errorMessage,
+ this.onPhoneNumberChanged,
super.key,
});
@@ -63,7 +67,7 @@ class IntlPhoneFieldState extends State<IntlPhoneField> {
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
CountryCodePicker(
- onChanged: widget.onChanged,
+ onChanged: widget.onCountryCodeSelected,
initialSelection: widget.countryCode.toString(),
showFlag: false,
favorite: const [
@@ -92,12 +96,18 @@ class IntlPhoneFieldState extends State<IntlPhoneField> {
readOnly: widget.readOnly,
style: theme.textTheme.headlineSmall,
onSubmitted: widget.onSubmitted,
+ onChanged: widget.onPhoneNumberChanged,
keyboardType:
const TextInputType.numberWithOptions(signed: true),
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
],
decoration: InputDecoration(
+ errorText: widget.errorMessage,
+ errorStyle: Theme.of(context)
+ .textTheme
+ .bodySmall
+ ?.copyWith(color: const Color(0xFFEB0026)),
border: InputBorder.none,
label: Text(widget.title,
style: _isFocused
diff --git a/comwell_key_app/lib/profile_settings/cubit/profile_settings_cubit.dart b/comwell_key_app/lib/profile_settings/cubit/profile_settings_cubit.dart
index bee06b5f..93e33822 100644
--- a/comwell_key_app/lib/profile_settings/cubit/profile_settings_cubit.dart
+++ b/comwell_key_app/lib/profile_settings/cubit/profile_settings_cubit.dart
@@ -43,7 +43,7 @@ class ProfileSettingsCubit extends Cubit<ProfileSettingsState> {
firstNameController.text = user.firstName;
lastNameController.text = user.lastName;
phoneNumberController.text = phoneNumber!;
-
+
emit(ProfileSettingsState(isLoading: false, user: user, error: null));
} catch (e) {
emit(ProfileSettingsState(isLoading: false, user: null, error: Error()));
@@ -63,7 +63,6 @@ class ProfileSettingsCubit extends Cubit<ProfileSettingsState> {
}
}
-
//TODO: Add this to the comwell signup page when backend is ready
void updateBirthDate(DateTime birthDate) {
if (state.user != null) {
@@ -78,11 +77,32 @@ class ProfileSettingsCubit extends Cubit<ProfileSettingsState> {
emit(state.userLoaded(user: updatedUser));
}
- void updateProfile(User user) async {
- emit(ProfileSettingsState(isLoading: true, user: user, error: null));
+ void updateProfile() async {
+ emit(ProfileSettingsState(isLoading: true, user: state.user, error: null));
try {
- await profileSettingsRepository.updateUser(user);
- emit(ProfileSettingsState(isLoading: false, user: user, error: null));
+ final phoneNumber = concatCountryCodeAndPhoneNumber(
+ countryCode!, phoneNumberController.text);
+
+ final updatedUser = state.user!.copyWith(
+ id: state.user!.id,
+ firstName: firstNameController.text,
+ lastName: lastNameController.text,
+ email: state.user!.email,
+ phoneNumber: phoneNumber,
+ birthDate: state.user!.birthDate,
+ address: state.user!.address,
+ shopperReference: state.user!.shopperReference,
+ points: state.user!.points,
+ addressCountry: state.user!.addressCountry,
+ gender: state.user!.gender,
+ clubId: state.user!.clubId,
+ clubLevel: state.user!.clubLevel,
+ clubLevelName: state.user!.clubLevelName,
+ );
+
+ print("updatedUser: ${updatedUser.phoneNumber}");
+ await profileSettingsRepository.updateUser(updatedUser);
+ emit(ProfileSettingsState(isLoading: false, user: updatedUser, error: null));
} catch (e) {
debugPrint("error in cubit: $e");
emit(ProfileSettingsState(isLoading: false, user: null, error: Error()));
diff --git a/comwell_key_app/lib/profile_settings/profile_settings_page.dart b/comwell_key_app/lib/profile_settings/profile_settings_page.dart
index a64326b9..ffd122a1 100644
--- a/comwell_key_app/lib/profile_settings/profile_settings_page.dart
+++ b/comwell_key_app/lib/profile_settings/profile_settings_page.dart
@@ -1,4 +1,4 @@
- import 'package:comwell_key_app/authentication/authentication_repository.dart';
+import 'package:comwell_key_app/authentication/authentication_repository.dart';
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
import 'package:comwell_key_app/common/components/generic_dialog.dart';
import 'package:comwell_key_app/login/auth.dart';
@@ -21,7 +21,6 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
class ProfileSettingsPage extends StatelessWidget {
-
const ProfileSettingsPage({super.key});
@override
@@ -94,11 +93,11 @@ class ProfileSettingsPage extends StatelessWidget {
}),
const SizedBox(height: 8),
ComwellTextField(
- fieldName: "profile_settings_email".tr(),
- initialValue: state.user!.email,
- readOnly: true,
- controller: TextEditingController(text: state.user!.email),
- ),
+ fieldName: "profile_settings_email".tr(),
+ initialValue: state.user!.email,
+ readOnly: true,
+ controller: TextEditingController(text: state.user!.email),
+ ),
const SizedBox(height: 8),
IntlPhoneField(
title: "profile_settings_phone".tr(),
@@ -117,7 +116,7 @@ class ProfileSettingsPage extends StatelessWidget {
"${state.user!.address.street}, ${state.user!.address.city}, ${state.user!.address.zipCode}, ${state.user!.address.country}",
trailingIcon: "assets/icons/edit-alt.svg",
onTap: () async {
- final response = await showModalBottomSheet<Address>(
+ final response = await showModalBottomSheet<Address>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.white,
@@ -144,24 +143,7 @@ class ProfileSettingsPage extends StatelessWidget {
Center(
child: OutlinedButton(
onPressed: () {
- cubit.updateProfile(
- User(
- id: state.user!.id,
- firstName: cubit.firstNameController.text,
- lastName: cubit.lastNameController.text,
- email: state.user!.email,
- phoneNumber: cubit.phoneNumberController.text,
- birthDate: state.user!.birthDate,
- address: state.user!.address,
- shopperReference: state.user!.shopperReference,
- points: state.user!.points,
- addressCountry: state.user!.addressCountry,
- gender: state.user!.gender,
- clubId: state.user!.clubId,
- clubLevel: state.user!.clubLevel,
- clubLevelName: state.user!.clubLevelName,
- ),
- );
+ cubit.updateProfile();
},
style: OutlinedButton.styleFrom(
backgroundColor: Colors.black,
@@ -213,9 +195,9 @@ class ProfileSettingsPage extends StatelessWidget {
);
}
- Future<dynamic> openChangePasswordModal(BuildContext context, Auth authEnum) {
+ Future<dynamic> openChangePasswordModal(BuildContext context, Auth authEnum) {
return showCupertinoModalBottomSheet(
- enableDrag: false,
+ enableDrag: false,
backgroundColor: Colors.orange,
topRadius: const Radius.circular(30),
elevation: 5,
@@ -230,7 +212,10 @@ class ProfileSettingsPage extends StatelessWidget {
child: SizedBox(
height: 700,
width: 400,
- child: AzureB2CWidget(authEnum: authEnum, authenticationRepository: locator<AuthenticationRepository>()),
+ child: AzureB2CWidget(
+ authEnum: authEnum,
+ authenticationRepository:
+ locator<AuthenticationRepository>()),
),
),
);
diff --git a/comwell_key_app/lib/profile_settings/repostiory/profile_settings_repository.dart b/comwell_key_app/lib/profile_settings/repostiory/profile_settings_repository.dart
index 7365106c..303845c5 100644
--- a/comwell_key_app/lib/profile_settings/repostiory/profile_settings_repository.dart
+++ b/comwell_key_app/lib/profile_settings/repostiory/profile_settings_repository.dart
@@ -20,6 +20,8 @@ class ProfileSettingsRepository {
final responseDto = UserDto.fromJson(data);
final user = responseDto.toUser();
await db.userDAO.saveUser(responseDto);
+
+ print("user: ${user}");
return user;
}
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index 5034eddc..dbe22646 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -82,6 +82,7 @@ class Api {
Future<Response<dynamic>> fetchProfileSettings() async {
print("fetching profile settings");
final response = await dio.get(ApiEndpoints.getGuestProfile);
+ print("response=$response");
return response;
}
diff --git a/comwell_key_app/lib/services/mappers/booking_mapper.dart b/comwell_key_app/lib/services/mappers/booking_mapper.dart
index d4e7e4ce..d67cafb0 100644
--- a/comwell_key_app/lib/services/mappers/booking_mapper.dart
+++ b/comwell_key_app/lib/services/mappers/booking_mapper.dart
@@ -6,7 +6,7 @@ import 'package:comwell_key_app/services/models/booking_dto.dart';
extension BookingDTOMapper on BookingDTO {
Booking toBooking(int userId, BookingStatus status, ReservationStatus reservationStatus) {
final startDate = DateTime.parse(dayIn);
- final endDate = DateTime.parse(dayOut);
+ final endDate = DateTime.parse(dayOut!);
return Booking(
id: confirmationNumber,
confirmationId: confirmationNumber,
@@ -18,7 +18,7 @@ extension BookingDTOMapper on BookingDTO {
image: "assets/images/no_current_bookings_background.jpeg",
hotelName: "Hotel $hotelCode",
roomType: roomType,
- totalCharge: totalCharge,
+ totalCharge: totalCharge ?? 0,
children: children,
booker: Guest(name: "$firstName $lastName", id: "$userId"),
adults: adults,
diff --git a/comwell_key_app/lib/services/mappers/bookings_mapper.dart b/comwell_key_app/lib/services/mappers/bookings_mapper.dart
index 8ba12669..194f34ca 100644
--- a/comwell_key_app/lib/services/mappers/bookings_mapper.dart
+++ b/comwell_key_app/lib/services/mappers/bookings_mapper.dart
@@ -6,9 +6,9 @@ import 'package:comwell_key_app/services/models/bookings_dto.dart';
extension BookingsMapper on BookingsDTO {
Bookings toBookings(int userId) {
return Bookings(
- current: current.toBookings(userId, BookingStatus.current, ReservationStatus.newReservation),
- past: past.toBookings(userId, BookingStatus.past, ReservationStatus.newReservation),
- cancelled: cancelled.toBookings(userId, BookingStatus.cancelled, ReservationStatus.newReservation),
+ current: current.toBookings(userId, BookingStatus.current, ReservationStatus.newreservation),
+ past: past.toBookings(userId, BookingStatus.past, ReservationStatus.newreservation),
+ cancelled: cancelled.toBookings(userId, BookingStatus.cancelled, ReservationStatus.newreservation),
);
}
}
diff --git a/comwell_key_app/lib/services/models/booking_dto.dart b/comwell_key_app/lib/services/models/booking_dto.dart
index 95ef0826..cf4e1bed 100644
--- a/comwell_key_app/lib/services/models/booking_dto.dart
+++ b/comwell_key_app/lib/services/models/booking_dto.dart
@@ -12,15 +12,15 @@ class BookingDTO {
final String confirmationNumber;
final String hmsConfirmationNumber;
final String dayIn;
- final String dayOut;
- final String cancelTime;
+ final String? dayOut;
+ final String? cancelTime;
final String status;
- final bool isCancelled;
- final String bookTime;
+ final bool? isCancelled;
+ final String? bookTime;
final String roomType;
final int adults;
final int children;
- final num totalCharge;
+ final num? totalCharge;
final num? balance;
final String? maskedCardNumber;
diff --git a/comwell_key_app/lib/services/models/user_dto.dart b/comwell_key_app/lib/services/models/user_dto.dart
index 9c3d512a..9836237e 100644
--- a/comwell_key_app/lib/services/models/user_dto.dart
+++ b/comwell_key_app/lib/services/models/user_dto.dart
@@ -20,7 +20,7 @@ class UserDto {
final String addressCity;
final String addressCountry;
final int? points;
- final String locale;
+ final String? locale;
UserDto({
required this.id,
diff --git a/comwell_key_app/lib/utils/phone_utils.dart b/comwell_key_app/lib/utils/phone_utils.dart
index eb007d2e..5b02ef28 100644
--- a/comwell_key_app/lib/utils/phone_utils.dart
+++ b/comwell_key_app/lib/utils/phone_utils.dart
@@ -2,13 +2,18 @@
import 'package:country_code_picker/country_code_picker.dart';
(CountryCode, String) getCountryCodeFromPhoneNumber(String phoneNumber) {
+
+ if (phoneNumber.isEmpty) {
+ return (CountryCode.fromDialCode('+45'), '');
+ }
+
final countryCode = phoneNumber.length == 13
? CountryCode.fromDialCode(phoneNumber.substring(0, 4))
: CountryCode.fromDialCode(phoneNumber.substring(0, 3));
final cleanedPhoneNumber = phoneNumber.substring(countryCode.dialCode!.length);
- print("cleanedPhoneNumber: $cleanedPhoneNumber");
+
return (countryCode, cleanedPhoneNumber);
}