6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 9c2064d8
Changed files
.../received_shared_booking_state.freezed.dart | 274 +++++++++++++++++++++ .../received_shared_booking_route.g.dart | 48 ++++ .../bloc/received_shared_booking_cubit.dart | 40 +++ .../bloc/received_shared_booking_state.dart | 12 + .../received_shared_booking_route.dart | 48 ++++ .../received_shared_booking_screen.dart | 61 +++++ .../received_shared_room_screen.dart | 35 +++ .../cubit/received_shared_booking_cubit.dart | 41 --- .../cubit/received_shared_booking_state.dart | 26 -- .../received_shared_booking_page.dart | 60 ----- .../received_shared_booking_route.dart | 23 -- .../cubit/received_shared_room_cubit.dart | 38 --- .../cubit/received_shared_room_state.dart | 28 --- .../received_shared_room_page.dart | 33 --- .../received_shared_room_route.dart | 23 -- comwell_key_app/lib/routing/app_router.dart | 21 +- comwell_key_app/lib/routing/app_routes.dart | 5 +- 17 files changed, 522 insertions(+), 294 deletions(-)
Diff
diff --git a/comwell_key_app/lib/.generated/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.freezed.dart b/comwell_key_app/lib/.generated/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.freezed.dart
new file mode 100644
index 00000000..8f7170e9
--- /dev/null
+++ b/comwell_key_app/lib/.generated/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.freezed.dart
@@ -0,0 +1,274 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// coverage:ignore-file
+// ignore_for_file: type=lint
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
+
+part of '../../../../../presentation/screens/received_shared_booking/bloc/received_shared_booking_state.dart';
+
+// **************************************************************************
+// FreezedGenerator
+// **************************************************************************
+
+// dart format off
+T _$identity<T>(T value) => value;
+/// @nodoc
+mixin _$ReceivedSharedBookingState {
+
+ bool get isLoading; AppError get error;
+/// Create a copy of ReceivedSharedBookingState
+/// with the given fields replaced by the non-null parameter values.
+@JsonKey(includeFromJson: false, includeToJson: false)
+@pragma('vm:prefer-inline')
+$ReceivedSharedBookingStateCopyWith<ReceivedSharedBookingState> get copyWith => _$ReceivedSharedBookingStateCopyWithImpl<ReceivedSharedBookingState>(this as ReceivedSharedBookingState, _$identity);
+
+
+
+@override
+bool operator ==(Object other) {
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is ReceivedSharedBookingState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error));
+}
+
+
+@override
+int get hashCode => Object.hash(runtimeType,isLoading,error);
+
+@override
+String toString() {
+ return 'ReceivedSharedBookingState(isLoading: $isLoading, error: $error)';
+}
+
+
+}
+
+/// @nodoc
+abstract mixin class $ReceivedSharedBookingStateCopyWith<$Res> {
+ factory $ReceivedSharedBookingStateCopyWith(ReceivedSharedBookingState value, $Res Function(ReceivedSharedBookingState) _then) = _$ReceivedSharedBookingStateCopyWithImpl;
+@useResult
+$Res call({
+ bool isLoading, AppError error
+});
+
+
+
+
+}
+/// @nodoc
+class _$ReceivedSharedBookingStateCopyWithImpl<$Res>
+ implements $ReceivedSharedBookingStateCopyWith<$Res> {
+ _$ReceivedSharedBookingStateCopyWithImpl(this._self, this._then);
+
+ final ReceivedSharedBookingState _self;
+ final $Res Function(ReceivedSharedBookingState) _then;
+
+/// Create a copy of ReceivedSharedBookingState
+/// with the given fields replaced by the non-null parameter values.
+@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? error = null,}) {
+ return _then(_self.copyWith(
+isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
+as bool,error: null == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
+as AppError,
+ ));
+}
+
+}
+
+
+/// Adds pattern-matching-related methods to [ReceivedSharedBookingState].
+extension ReceivedSharedBookingStatePatterns on ReceivedSharedBookingState {
+/// A variant of `map` that fallback to returning `orElse`.
+///
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case final Subclass value:
+/// return ...;
+/// case _:
+/// return orElse();
+/// }
+/// ```
+
+@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ReceivedSharedBookingState value)? $default,{required TResult orElse(),}){
+final _that = this;
+switch (_that) {
+case _ReceivedSharedBookingState() when $default != null:
+return $default(_that);case _:
+ return orElse();
+
+}
+}
+/// A `switch`-like method, using callbacks.
+///
+/// Callbacks receives the raw object, upcasted.
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case final Subclass value:
+/// return ...;
+/// case final Subclass2 value:
+/// return ...;
+/// }
+/// ```
+
+@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ReceivedSharedBookingState value) $default,){
+final _that = this;
+switch (_that) {
+case _ReceivedSharedBookingState():
+return $default(_that);case _:
+ throw StateError('Unexpected subclass');
+
+}
+}
+/// A variant of `map` that fallback to returning `null`.
+///
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case final Subclass value:
+/// return ...;
+/// case _:
+/// return null;
+/// }
+/// ```
+
+@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ReceivedSharedBookingState value)? $default,){
+final _that = this;
+switch (_that) {
+case _ReceivedSharedBookingState() when $default != null:
+return $default(_that);case _:
+ return null;
+
+}
+}
+/// A variant of `when` that fallback to an `orElse` callback.
+///
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case Subclass(:final field):
+/// return ...;
+/// case _:
+/// return orElse();
+/// }
+/// ```
+
+@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, AppError error)? $default,{required TResult orElse(),}) {final _that = this;
+switch (_that) {
+case _ReceivedSharedBookingState() when $default != null:
+return $default(_that.isLoading,_that.error);case _:
+ return orElse();
+
+}
+}
+/// A `switch`-like method, using callbacks.
+///
+/// As opposed to `map`, this offers destructuring.
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case Subclass(:final field):
+/// return ...;
+/// case Subclass2(:final field2):
+/// return ...;
+/// }
+/// ```
+
+@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, AppError error) $default,) {final _that = this;
+switch (_that) {
+case _ReceivedSharedBookingState():
+return $default(_that.isLoading,_that.error);case _:
+ throw StateError('Unexpected subclass');
+
+}
+}
+/// A variant of `when` that fallback to returning `null`
+///
+/// It is equivalent to doing:
+/// ```dart
+/// switch (sealedClass) {
+/// case Subclass(:final field):
+/// return ...;
+/// case _:
+/// return null;
+/// }
+/// ```
+
+@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, AppError error)? $default,) {final _that = this;
+switch (_that) {
+case _ReceivedSharedBookingState() when $default != null:
+return $default(_that.isLoading,_that.error);case _:
+ return null;
+
+}
+}
+
+}
+
+/// @nodoc
+
+
+class _ReceivedSharedBookingState implements ReceivedSharedBookingState {
+ const _ReceivedSharedBookingState({this.isLoading = false, this.error = AppError.none});
+
+
+@override@JsonKey() final bool isLoading;
+@override@JsonKey() final AppError error;
+
+/// Create a copy of ReceivedSharedBookingState
+/// with the given fields replaced by the non-null parameter values.
+@override @JsonKey(includeFromJson: false, includeToJson: false)
+@pragma('vm:prefer-inline')
+_$ReceivedSharedBookingStateCopyWith<_ReceivedSharedBookingState> get copyWith => __$ReceivedSharedBookingStateCopyWithImpl<_ReceivedSharedBookingState>(this, _$identity);
+
+
+
+@override
+bool operator ==(Object other) {
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is _ReceivedSharedBookingState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error));
+}
+
+
+@override
+int get hashCode => Object.hash(runtimeType,isLoading,error);
+
+@override
+String toString() {
+ return 'ReceivedSharedBookingState(isLoading: $isLoading, error: $error)';
+}
+
+
+}
+
+/// @nodoc
+abstract mixin class _$ReceivedSharedBookingStateCopyWith<$Res> implements $ReceivedSharedBookingStateCopyWith<$Res> {
+ factory _$ReceivedSharedBookingStateCopyWith(_ReceivedSharedBookingState value, $Res Function(_ReceivedSharedBookingState) _then) = __$ReceivedSharedBookingStateCopyWithImpl;
+@override @useResult
+$Res call({
+ bool isLoading, AppError error
+});
+
+
+
+
+}
+/// @nodoc
+class __$ReceivedSharedBookingStateCopyWithImpl<$Res>
+ implements _$ReceivedSharedBookingStateCopyWith<$Res> {
+ __$ReceivedSharedBookingStateCopyWithImpl(this._self, this._then);
+
+ final _ReceivedSharedBookingState _self;
+ final $Res Function(_ReceivedSharedBookingState) _then;
+
+/// Create a copy of ReceivedSharedBookingState
+/// with the given fields replaced by the non-null parameter values.
+@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? error = null,}) {
+ return _then(_ReceivedSharedBookingState(
+isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
+as bool,error: null == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
+as AppError,
+ ));
+}
+
+
+}
+
+// dart format on
diff --git a/comwell_key_app/lib/.generated/presentation/screens/received_shared_booking/received_shared_booking_route.g.dart b/comwell_key_app/lib/.generated/presentation/screens/received_shared_booking/received_shared_booking_route.g.dart
new file mode 100644
index 00000000..812d689a
--- /dev/null
+++ b/comwell_key_app/lib/.generated/presentation/screens/received_shared_booking/received_shared_booking_route.g.dart
@@ -0,0 +1,48 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of '../../../../presentation/screens/received_shared_booking/received_shared_booking_route.dart';
+
+// **************************************************************************
+// GoRouterGenerator
+// **************************************************************************
+
+List<RouteBase> get $appRoutes => [$receivedSharedBookingRoute];
+
+RouteBase get $receivedSharedBookingRoute => GoRouteData.$route(
+ path: '/share-room',
+ factory: $ReceivedSharedBookingRoute._fromState,
+);
+
+mixin $ReceivedSharedBookingRoute on GoRouteData {
+ static ReceivedSharedBookingRoute _fromState(GoRouterState state) =>
+ ReceivedSharedBookingRoute(
+ sharingId: state.uri.queryParameters['sharing-id'] ?? "",
+ hotelCode: state.uri.queryParameters['hotel-code'] ?? "",
+ sharingType: state.uri.queryParameters['sharing-type'] ?? "",
+ );
+
+ ReceivedSharedBookingRoute get _self => this as ReceivedSharedBookingRoute;
+
+ @override
+ String get location => GoRouteData.$location(
+ '/share-room',
+ queryParams: {
+ if (_self.sharingId != "") 'sharing-id': _self.sharingId,
+ if (_self.hotelCode != "") 'hotel-code': _self.hotelCode,
+ if (_self.sharingType != "") 'sharing-type': _self.sharingType,
+ },
+ );
+
+ @override
+ void go(BuildContext context) => context.go(location);
+
+ @override
+ Future<T?> push<T>(BuildContext context) => context.push<T>(location);
+
+ @override
+ void pushReplacement(BuildContext context) =>
+ context.pushReplacement(location);
+
+ @override
+ void replace(BuildContext context) => context.replace(location);
+}
diff --git a/comwell_key_app/lib/presentation/screens/received_shared_booking/bloc/received_shared_booking_cubit.dart b/comwell_key_app/lib/presentation/screens/received_shared_booking/bloc/received_shared_booking_cubit.dart
new file mode 100644
index 00000000..a48dae74
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/received_shared_booking/bloc/received_shared_booking_cubit.dart
@@ -0,0 +1,40 @@
+import 'package:comwell_key_app/domain/models/app_error.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/presentation/base/base_cubit.dart';
+import 'package:comwell_key_app/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.dart';
+
+import '../../../../booking_details/booking_details_repository.dart';
+import '../../../../share/share_booking_repository.dart';
+
+class ReceivedSharedBookingCubit extends BaseCubit<ReceivedSharedBookingState> {
+ final String sharingId;
+ final String hotelCode;
+ late final String hmsConfirmationNumber;
+ late final Booking booking;
+
+ final ShareBookingRepository _shareBookingRepository;
+ final BookingDetailsRepository _bookingDetailsRepository;
+
+ ReceivedSharedBookingCubit(
+ this._shareBookingRepository,
+ this._bookingDetailsRepository, {
+ required this.sharingId,
+ required this.hotelCode,
+ }) : super(const ReceivedSharedBookingState()) {
+ init();
+ }
+
+ Future<void> init() async {
+ try {
+ safeEmit(state.copyWith(isLoading: true));
+ final response = await _shareBookingRepository.consumeRoomSharingLink(sharingId, hotelCode);
+ hmsConfirmationNumber = response.confirmationNumber;
+ booking = await _bookingDetailsRepository.getBookingDetails(hmsConfirmationNumber, hotelCode);
+ } catch (e, st) {
+ logError(e, st);
+ safeEmit(state.copyWith(error: AppError.unknown(e.toString())));
+ } finally {
+ safeEmit(state.copyWith(isLoading: false));
+ }
+ }
+}
diff --git a/comwell_key_app/lib/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.dart b/comwell_key_app/lib/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.dart
new file mode 100644
index 00000000..f259d591
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.dart
@@ -0,0 +1,12 @@
+import 'package:comwell_key_app/domain/models/app_error.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
+
+part '../../../../.generated/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.freezed.dart';
+
+@freezed
+abstract class ReceivedSharedBookingState with _$ReceivedSharedBookingState {
+ const factory ReceivedSharedBookingState({
+ @Default(false) bool isLoading,
+ @Default(AppError.none) AppError error,
+ }) = _ReceivedSharedBookingState;
+}
\ No newline at end of file
diff --git a/comwell_key_app/lib/presentation/screens/received_shared_booking/received_shared_booking_route.dart b/comwell_key_app/lib/presentation/screens/received_shared_booking/received_shared_booking_route.dart
new file mode 100644
index 00000000..ed0c733d
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/received_shared_booking/received_shared_booking_route.dart
@@ -0,0 +1,48 @@
+import 'package:comwell_key_app/presentation/screens/received_shared_booking/received_shared_room_screen.dart';
+import 'package:comwell_key_app/utils/locator.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+import 'package:comwell_key_app/presentation/navigation/transitions/slide_in_transition.dart';
+import 'package:comwell_key_app/presentation/screens/received_shared_booking/bloc/received_shared_booking_cubit.dart';
+import 'package:comwell_key_app/presentation/screens/received_shared_booking/received_shared_booking_screen.dart';
+
+import '../../../routing/app_routes.dart';
+
+part '../../../.generated/presentation/screens/received_shared_booking/received_shared_booking_route.g.dart';
+
+@TypedGoRoute<ReceivedSharedBookingRoute>(path: AppRoutes.receiveSharedBooking)
+class ReceivedSharedBookingRoute extends GoRouteData with $ReceivedSharedBookingRoute {
+ final String sharingId;
+ final String hotelCode;
+ final String sharingType;
+
+ ReceivedSharedBookingRoute({
+ this.sharingId = "",
+ this.hotelCode = "",
+ this.sharingType = "",
+ });
+
+ @override
+ Page<void> buildPage(BuildContext context, GoRouterState state) {
+ return SlideInTransition(
+ state: state,
+ child: BlocProvider(
+ create: (context) => ReceivedSharedBookingCubit(
+ locator(),
+ locator(),
+ hotelCode: hotelCode,
+ sharingId: sharingId,
+ ),
+ child: Builder(
+ builder: (context) {
+ if (sharingType == "RoomDistribution") {
+ return const ReceivedSharedRoomPage();
+ }
+ return const ReceivedSharedBookingScreen();
+ },
+ ),
+ ),
+ );
+ }
+}
diff --git a/comwell_key_app/lib/presentation/screens/received_shared_booking/received_shared_booking_screen.dart b/comwell_key_app/lib/presentation/screens/received_shared_booking/received_shared_booking_screen.dart
new file mode 100644
index 00000000..70ba9b8d
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/received_shared_booking/received_shared_booking_screen.dart
@@ -0,0 +1,61 @@
+import 'package:comwell_key_app/common/components/comwell_error_widget.dart';
+import 'package:comwell_key_app/common/components/shimmer_loader/share_room_shimmer_loader.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/l10n_utils.dart';
+import 'package:comwell_key_app/utils/templates/share_booking_base_template.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:comwell_key_app/presentation/screens/received_shared_booking/bloc/received_shared_booking_cubit.dart';
+import 'package:comwell_key_app/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.dart';
+import 'package:go_router/go_router.dart';
+
+class ReceivedSharedBookingScreen extends StatelessWidget {
+ const ReceivedSharedBookingScreen({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return BlocBuilder<ReceivedSharedBookingCubit, ReceivedSharedBookingState>(
+ builder: (context, state) {
+ final cubit = context.read<ReceivedSharedBookingCubit>();
+ if (state.isLoading) {
+ return const ShareRoomShimmerLoader();
+ }
+ if (state.error.isError) {
+ return Scaffold(
+ body: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ ComwellErrorWidget(
+ title: context.strings.share_booking_error_title,
+ subtitle: context.strings.share_booking_error_subtitle,
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 32.0),
+ child: ElevatedButton(
+ onPressed: () {
+ context.go(AppRoutes.overview);
+ },
+ child: Text(
+ context.strings.home_page,
+ style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.white),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+ return ShareBookingBaseTemplate(
+ booking: cubit.booking,
+ onClicked: () {
+ context.go(AppRoutes.overview);
+ },
+ isShared: true,
+ isLoading: state.isLoading,
+ error: state.error.isError ? Error() : null,
+ );
+ },
+ );
+ }
+}
diff --git a/comwell_key_app/lib/presentation/screens/received_shared_booking/received_shared_room_screen.dart b/comwell_key_app/lib/presentation/screens/received_shared_booking/received_shared_room_screen.dart
new file mode 100644
index 00000000..51f8f657
--- /dev/null
+++ b/comwell_key_app/lib/presentation/screens/received_shared_booking/received_shared_room_screen.dart
@@ -0,0 +1,35 @@
+import 'package:comwell_key_app/choose_share_room/pages/share_room_base_page_template.dart';
+import 'package:comwell_key_app/common/components/shimmer_loader/share_room_shimmer_loader.dart';
+import 'package:comwell_key_app/presentation/screens/received_shared_booking/bloc/received_shared_booking_cubit.dart';
+import 'package:comwell_key_app/presentation/screens/received_shared_booking/bloc/received_shared_booking_state.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:go_router/go_router.dart';
+
+class ReceivedSharedRoomPage extends StatelessWidget {
+ const ReceivedSharedRoomPage({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return BlocBuilder<ReceivedSharedBookingCubit, ReceivedSharedBookingState>(
+ builder: (context, state) {
+ final cubit = context.read<ReceivedSharedBookingCubit>();
+ if (state.isLoading) {
+ return const ShareRoomShimmerLoader();
+ }
+ if (state.error.isError) {
+ return Center(child: Text(state.error.toString()));
+ }
+
+ return ShareRoomBasePageTemplate(
+ booking: cubit.booking,
+ onClicked: () {
+ context.go(AppRoutes.overview);
+ },
+ isShared: true,
+ );
+ },
+ );
+ }
+}
diff --git a/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_cubit.dart b/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_cubit.dart
deleted file mode 100644
index 2d16ab7c..00000000
--- a/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_cubit.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-import 'package:bloc/bloc.dart';
-import 'package:comwell_key_app/booking_details/booking_details_repository.dart';
-import 'package:comwell_key_app/overview/models/booking.dart';
-import 'package:comwell_key_app/received_shared_booking/cubit/received_shared_booking_state.dart';
-import 'package:comwell_key_app/share/share_booking_repository.dart';
-import 'package:flutter/material.dart';
-
-class ReceivedSharedBookingCubit extends Cubit<ReceivedSharedBookingState> {
- final String sharingId;
- final String hotelCode;
- late String hmsConfirmationNumber;
- late Booking booking;
-
- final ShareBookingRepository _shareBookingRepository;
- final BookingDetailsRepository _bookingDetailsRepository;
-
- ReceivedSharedBookingCubit(
- this._shareBookingRepository,
- this._bookingDetailsRepository, {
- required this.sharingId,
- required this.hotelCode,
- }) : super(const ReceivedSharedBookingState.loading()) {
- init();
- }
-
- void init() async {
- emit(const ReceivedSharedBookingState.loading());
-
- try {
- final response = await _shareBookingRepository.consumeRoomSharingLink(sharingId, hotelCode);
- hmsConfirmationNumber = response.confirmationNumber;
-
- booking = await _bookingDetailsRepository.getBookingDetails(hmsConfirmationNumber, hotelCode);
-
- emit(const ReceivedSharedBookingState.loaded());
- } catch (e) {
- debugPrint("Error consuming room sharing link: $e");
- emit(ReceivedSharedBookingState.error(e is Error ? e : Error()));
- }
- }
-}
diff --git a/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_state.dart b/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_state.dart
deleted file mode 100644
index 835a7eb0..00000000
--- a/comwell_key_app/lib/received_shared_booking/cubit/received_shared_booking_state.dart
+++ /dev/null
@@ -1,26 +0,0 @@
-import 'package:equatable/equatable.dart';
-
-class ReceivedSharedBookingState extends Equatable {
- final bool isLoading;
- final Error? error;
-
- const ReceivedSharedBookingState({required this.isLoading, required this.error});
-
- const ReceivedSharedBookingState.initial() : this(isLoading: false, error: null);
-
- const ReceivedSharedBookingState.loading() : this(isLoading: true, error: null);
-
- const ReceivedSharedBookingState.error(Error error) : this(isLoading: false, error: error);
-
- const ReceivedSharedBookingState.loaded() : this(isLoading: false, error: null);
-
- @override
- List<Object?> get props => [isLoading, error];
-
- ReceivedSharedBookingState copyWith({
- bool? isLoading,
- Error? error,
- }) {
- return ReceivedSharedBookingState(isLoading: isLoading ?? this.isLoading, error: error ?? this.error);
- }
-}
diff --git a/comwell_key_app/lib/received_shared_booking/received_shared_booking_page.dart b/comwell_key_app/lib/received_shared_booking/received_shared_booking_page.dart
deleted file mode 100644
index b8c663a3..00000000
--- a/comwell_key_app/lib/received_shared_booking/received_shared_booking_page.dart
+++ /dev/null
@@ -1,60 +0,0 @@
-import 'package:comwell_key_app/common/components/comwell_error_widget.dart';
-import 'package:comwell_key_app/common/components/shimmer_loader/share_room_shimmer_loader.dart';
-import 'package:comwell_key_app/received_shared_booking/cubit/received_shared_booking_cubit.dart';
-import 'package:comwell_key_app/received_shared_booking/cubit/received_shared_booking_state.dart';
-import 'package:comwell_key_app/routing/app_routes.dart';
-import 'package:comwell_key_app/utils/l10n_utils.dart';
-import 'package:comwell_key_app/utils/templates/share_booking_base_template.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:go_router/go_router.dart';
-
-class ReceivedSharedBookingPage extends StatelessWidget {
- const ReceivedSharedBookingPage({super.key});
-
- @override
- Widget build(BuildContext context) {
- return BlocBuilder<ReceivedSharedBookingCubit, ReceivedSharedBookingState>(
- builder: (context, state) {
- final cubit = context.read<ReceivedSharedBookingCubit>();
- if (state.isLoading) {
- return const ShareRoomShimmerLoader();
- }
- if (state.error != null) {
- return Scaffold(
- body: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- ComwellErrorWidget(
- title: context.strings.share_booking_error_title,
- subtitle: context.strings.share_booking_error_subtitle,
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 32.0),
- child: ElevatedButton(
- onPressed: () {
- context.go(AppRoutes.overview);
- },
- child: Text(context.strings.home_page,
- style: Theme.of(context)
- .textTheme
- .bodyMedium
- ?.copyWith(color: Colors.white))),
- )
- ],
- ),
- );
- }
- return ShareBookingBaseTemplate(
- booking: cubit.booking,
- onClicked: () {
- context.go(AppRoutes.overview);
- },
- isShared: true,
- isLoading: state.isLoading,
- error: state.error);
- },
- );
- }
-}
diff --git a/comwell_key_app/lib/received_shared_booking/received_shared_booking_route.dart b/comwell_key_app/lib/received_shared_booking/received_shared_booking_route.dart
deleted file mode 100644
index 27f2363b..00000000
--- a/comwell_key_app/lib/received_shared_booking/received_shared_booking_route.dart
+++ /dev/null
@@ -1,23 +0,0 @@
-import 'package:comwell_key_app/received_shared_booking/cubit/received_shared_booking_cubit.dart';
-import 'package:comwell_key_app/received_shared_booking/received_shared_booking_page.dart';
-import 'package:comwell_key_app/routing/app_routes.dart';
-import 'package:comwell_key_app/utils/locator.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:go_router/go_router.dart';
-
-final receivedSharedBookingRoute = GoRoute(
- path: AppRoutes.receivedSharedBooking,
- builder: (context, state) {
- final sharingId = state.uri.queryParameters['sharingId'];
- final hotelCode = state.uri.queryParameters['hotelCode'];
- return BlocProvider(
- create: (context) => ReceivedSharedBookingCubit(
- locator(),
- locator(),
- sharingId: sharingId ?? '',
- hotelCode: hotelCode ?? '',
- ),
- child: const ReceivedSharedBookingPage(),
- );
- },
-);
diff --git a/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_cubit.dart b/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_cubit.dart
deleted file mode 100644
index bca026e5..00000000
--- a/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_cubit.dart
+++ /dev/null
@@ -1,38 +0,0 @@
-import 'package:comwell_key_app/booking_details/booking_details_repository.dart';
-import 'package:comwell_key_app/overview/models/booking.dart';
-import 'package:comwell_key_app/received_shared_room/cubit/received_shared_room_state.dart';
-import 'package:comwell_key_app/share/share_booking_repository.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-
-class ReceivedSharedRoomCubit extends Cubit<ReceivedSharedRoomState> {
- final String sharingId;
- final String hotelCode;
- late String hmsConfirmationNumber;
- late Booking booking;
-
- final ShareBookingRepository _shareBookingRepository;
- final BookingDetailsRepository _bookingDetailsRepository;
-
- ReceivedSharedRoomCubit(
- this._shareBookingRepository,
- this._bookingDetailsRepository, {
- required this.sharingId,
- required this.hotelCode,
- }) : super(const ReceivedSharedRoomState.loading()) {
- init();
- }
-
- void init() async {
- emit(const ReceivedSharedRoomState.loading());
- try {
- final response = await _shareBookingRepository.consumeRoomSharingLink(sharingId, hotelCode);
- hmsConfirmationNumber = response.confirmationNumber;
-
- booking = await _bookingDetailsRepository.getBookingDetails(hmsConfirmationNumber, hotelCode);
-
- emit(const ReceivedSharedRoomState.loaded());
- } catch (e) {
- emit(ReceivedSharedRoomState.error(e is Error ? e : Error()));
- }
- }
-}
diff --git a/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_state.dart b/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_state.dart
deleted file mode 100644
index 6a3d463a..00000000
--- a/comwell_key_app/lib/received_shared_room/cubit/received_shared_room_state.dart
+++ /dev/null
@@ -1,28 +0,0 @@
-
-import 'package:equatable/equatable.dart';
-
-class ReceivedSharedRoomState extends Equatable {
- final Error? error;
- final bool isLoading;
-
-
- const ReceivedSharedRoomState({this.error, required this.isLoading});
-
- const ReceivedSharedRoomState.initial() : this(error: null, isLoading: false);
-
- const ReceivedSharedRoomState.loading() : this(error: null, isLoading: true);
-
- const ReceivedSharedRoomState.error(Error error) : this(error: error, isLoading: false);
-
- const ReceivedSharedRoomState.loaded() : this(error: null, isLoading: false);
-
- @override
- List<Object?> get props => [error, isLoading];
-
- ReceivedSharedRoomState copyWith({
- Error? error,
- bool? isLoading,
- }) {
- return ReceivedSharedRoomState(error: error ?? this.error, isLoading: isLoading ?? this.isLoading);
- }
-}
\ No newline at end of file
diff --git a/comwell_key_app/lib/received_shared_room/received_shared_room_page.dart b/comwell_key_app/lib/received_shared_room/received_shared_room_page.dart
deleted file mode 100644
index f77c6262..00000000
--- a/comwell_key_app/lib/received_shared_room/received_shared_room_page.dart
+++ /dev/null
@@ -1,33 +0,0 @@
-import 'package:comwell_key_app/choose_share_room/pages/share_room_base_page_template.dart';
-import 'package:comwell_key_app/common/components/shimmer_loader/share_room_shimmer_loader.dart';
-import 'package:comwell_key_app/received_shared_room/cubit/received_shared_room_cubit.dart';
-import 'package:comwell_key_app/received_shared_room/cubit/received_shared_room_state.dart';
-import 'package:comwell_key_app/routing/app_routes.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:go_router/go_router.dart';
-
-class ReceivedSharedRoomPage extends StatelessWidget {
- const ReceivedSharedRoomPage({super.key});
-
- @override
- Widget build(BuildContext context) {
- return BlocBuilder<ReceivedSharedRoomCubit, ReceivedSharedRoomState>(
- builder: (context, state) {
- final cubit = context.read<ReceivedSharedRoomCubit>();
- if (state.isLoading) {
- return const ShareRoomShimmerLoader();
- }
- if (state.error != null) {
- return Center(child: Text(state.error.toString()));
- }
-
- return ShareRoomBasePageTemplate(
- booking: cubit.booking,
- onClicked: () {
- context.go(AppRoutes.overview);
- },
- isShared: true);
- });
- }
-}
diff --git a/comwell_key_app/lib/received_shared_room/received_shared_room_route.dart b/comwell_key_app/lib/received_shared_room/received_shared_room_route.dart
deleted file mode 100644
index a47a3e35..00000000
--- a/comwell_key_app/lib/received_shared_room/received_shared_room_route.dart
+++ /dev/null
@@ -1,23 +0,0 @@
-import 'package:comwell_key_app/received_shared_room/cubit/received_shared_room_cubit.dart';
-import 'package:comwell_key_app/received_shared_room/received_shared_room_page.dart';
-import 'package:comwell_key_app/routing/app_routes.dart';
-import 'package:comwell_key_app/utils/locator.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:go_router/go_router.dart';
-
-final receivedSharedRoomRoute = GoRoute(
- path: AppRoutes.receivedSharedRoom,
- builder: (context, state) {
- final sharingId = state.uri.queryParameters['sharingId'];
- final hotelCode = state.uri.queryParameters['hotelCode'];
- return BlocProvider(
- create: (context) => ReceivedSharedRoomCubit(
- locator(),
- locator(),
- sharingId: sharingId ?? '',
- hotelCode: hotelCode ?? '',
- ),
- child: const ReceivedSharedRoomPage(),
- );
- },
-);
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 2a7f051a..e7c7e642 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -18,8 +18,6 @@ import 'package:comwell_key_app/presentation/screens/past_cancelled_booking_deta
import 'package:comwell_key_app/presentation/screens/webview/webview_route.dart';
import 'package:comwell_key_app/profile/profile_route.dart';
import 'package:comwell_key_app/profile_settings/profile_settings_route.dart';
-import 'package:comwell_key_app/received_shared_booking/received_shared_booking_route.dart';
-import 'package:comwell_key_app/received_shared_room/received_shared_room_route.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/routing/go_router_observer.dart';
import 'package:comwell_key_app/share/share_booking_route.dart';
@@ -30,6 +28,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import '../presentation/screens/login/login_route.dart';
import '../presentation/screens/onboarding/onboarding_routes.dart';
+import '../presentation/screens/received_shared_booking/received_shared_booking_route.dart';
import '../utils/locator.dart';
final _rootNavigatorKey = GlobalKey<NavigatorState>();
@@ -48,21 +47,6 @@ final router = GoRouter(
final isLoggedIn = authRepo.isLoggedIn;
final isException = authExceptions.contains(state.matchedLocation);
- if (state.uri.host == 'share-room') {
- final sharingType = state.uri.queryParameters['sharingType'];
-
- final Uri uri;
- if (sharingType == 'RoomDistribution') {
- uri = Uri(path: AppRoutes.receivedSharedRoom, queryParameters: state.uri.queryParameters);
- } else {
- uri = Uri(
- path: AppRoutes.receivedSharedBooking,
- queryParameters: state.uri.queryParameters,
- );
- }
- return uri.toString();
- }
-
if (isException) {
return null;
}
@@ -103,7 +87,6 @@ final router = GoRouter(
findBookingRoute,
shareBookingRoute,
forceUpdateRoute,
- receivedSharedBookingRoute,
bookingDetailsWithIdRoute,
findBookingLoadingRoute,
myBookingRoute,
@@ -115,6 +98,6 @@ final router = GoRouter(
...checkOutRoutes,
upSalesRoute,
roomInfoRoute,
- receivedSharedRoomRoute,
+ $receivedSharedBookingRoute,
],
);
diff --git a/comwell_key_app/lib/routing/app_routes.dart b/comwell_key_app/lib/routing/app_routes.dart
index 551fc0c8..ff401c1d 100644
--- a/comwell_key_app/lib/routing/app_routes.dart
+++ b/comwell_key_app/lib/routing/app_routes.dart
@@ -12,8 +12,7 @@ abstract class AppRoutes {
static const onboardingBluetooth = "/onboarding/bluetooth";
static const onboardingNotification = "/onboarding/notification";
static const onboardingUsageTracking = "/onboarding/usage-tracking";
- static const receivedSharedRoom = "/received-shared-room";
- static const receivedSharedBooking = "/received-shared-booking";
+ static const receiveSharedBooking = "/share-room";
static const checkOutSuccess = "/checkout-success";
static const paymentProcessing = "/payment-processing";
static const profile = "/profile";
@@ -40,7 +39,7 @@ abstract class AppRoutes {
static const upSalesProcessing = "/up-sales-processing";
static const chooseShareRoom = "/choose-share-room";
static const roomInfo = "/room-info";
- static const shareRoom = "/share-room";
+ static const shareRoom = "/send-share-room";
static const forceUpdate = "/force-update";
static const upSalesError = "/up-sales-error";
static const sharedBooking = "/shared-booking";