diff --git a/apps/mobile/packages/core/lib/src/routing/client/navigator.dart b/apps/mobile/packages/core/lib/src/routing/client/navigator.dart index 5bcc3406..f969af72 100644 --- a/apps/mobile/packages/core/lib/src/routing/client/navigator.dart +++ b/apps/mobile/packages/core/lib/src/routing/client/navigator.dart @@ -137,36 +137,36 @@ extension ClientNavigator on IModularNavigator { /// Pushes the order creation flow entry page. /// /// This is the starting point for all order creation flows. - void toCreateOrder() { - pushNamed(ClientPaths.createOrder); + void toCreateOrder({Object? arguments}) { + pushNamed(ClientPaths.createOrder, arguments: arguments); } /// Pushes the rapid order creation flow. /// /// Quick shift creation with simplified inputs for urgent needs. - void toCreateOrderRapid() { - pushNamed(ClientPaths.createOrderRapid); + void toCreateOrderRapid({Object? arguments}) { + pushNamed(ClientPaths.createOrderRapid, arguments: arguments); } /// Pushes the one-time order creation flow. /// /// Create a shift that occurs once at a specific date and time. - void toCreateOrderOneTime() { - pushNamed(ClientPaths.createOrderOneTime); + void toCreateOrderOneTime({Object? arguments}) { + pushNamed(ClientPaths.createOrderOneTime, arguments: arguments); } /// Pushes the recurring order creation flow. /// /// Create shifts that repeat on a defined schedule (daily, weekly, etc.). - void toCreateOrderRecurring() { - pushNamed(ClientPaths.createOrderRecurring); + void toCreateOrderRecurring({Object? arguments}) { + pushNamed(ClientPaths.createOrderRecurring, arguments: arguments); } /// Pushes the permanent order creation flow. /// /// Create a long-term or permanent staffing position. - void toCreateOrderPermanent() { - pushNamed(ClientPaths.createOrderPermanent); + void toCreateOrderPermanent({Object? arguments}) { + pushNamed(ClientPaths.createOrderPermanent, arguments: arguments); } // ========================================================================== diff --git a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart index c9d91f2a..fb1da7d5 100644 --- a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart +++ b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart @@ -5,8 +5,6 @@ import 'package:flutter_modular/flutter_modular.dart'; import 'package:krow_core/core.dart'; import 'package:krow_domain/krow_domain.dart'; -import 'client_home_sheets.dart'; - /// A widget that allows clients to reorder recent shifts. class ReorderWidget extends StatelessWidget { /// Creates a [ReorderWidget]. @@ -173,29 +171,28 @@ class ReorderWidget extends StatelessWidget { } void _handleReorderPressed(BuildContext context, Map data) { - ClientHomeSheets.showOrderFormSheet( - context, - data, - onSubmit: (Map submittedData) { - final String? typeStr = submittedData['type']?.toString(); - if (typeStr == null || typeStr.isEmpty) { - return; - } - final OrderType orderType = OrderType.fromString(typeStr); - switch (orderType) { - case OrderType.recurring: - Modular.to.toCreateOrderRecurring(); - break; - case OrderType.permanent: - Modular.to.toCreateOrderPermanent(); - break; - case OrderType.oneTime: - default: - Modular.to.toCreateOrderOneTime(); - break; - } - }, - ); + // Override start date with today's date as requested + final Map populatedData = Map.from(data) + ..['startDate'] = DateTime.now(); + + final String? typeStr = populatedData['type']?.toString(); + if (typeStr == null || typeStr.isEmpty) { + return; + } + + final OrderType orderType = OrderType.fromString(typeStr); + switch (orderType) { + case OrderType.recurring: + Modular.to.toCreateOrderRecurring(arguments: populatedData); + break; + case OrderType.permanent: + Modular.to.toCreateOrderPermanent(arguments: populatedData); + break; + case OrderType.oneTime: + default: + Modular.to.toCreateOrderOneTime(arguments: populatedData); + break; + } } } diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_bloc.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_bloc.dart index 977e7823..625a2057 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_bloc.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_bloc.dart @@ -11,7 +11,9 @@ import 'one_time_order_state.dart'; /// BLoC for managing the multi-step one-time order creation form. class OneTimeOrderBloc extends Bloc - with BlocErrorHandler, SafeBloc { + with + BlocErrorHandler, + SafeBloc { OneTimeOrderBloc(this._createOneTimeOrderUseCase, this._service) : super(OneTimeOrderState.initial()) { on(_onVendorsLoaded); @@ -24,6 +26,7 @@ class OneTimeOrderBloc extends Bloc on(_onPositionRemoved); on(_onPositionUpdated); on(_onSubmitted); + on(_onInitialized); _loadVendors(); _loadHubs(); @@ -34,8 +37,10 @@ class OneTimeOrderBloc extends Bloc Future _loadVendors() async { final List? vendors = await handleErrorWithResult( action: () async { - final QueryResult result = - await _service.connector.listVendors().execute(); + final QueryResult result = await _service + .connector + .listVendors() + .execute(); return result.data.vendors .map( (dc.ListVendorsVendors vendor) => Vendor( @@ -54,11 +59,19 @@ class OneTimeOrderBloc extends Bloc } } - Future _loadRolesForVendor(String vendorId, Emitter emit) async { + Future _loadRolesForVendor( + String vendorId, + Emitter emit, + ) async { final List? roles = await handleErrorWithResult( action: () async { - final QueryResult - result = await _service.connector.listRolesByVendorId(vendorId: vendorId).execute(); + final QueryResult< + dc.ListRolesByVendorIdData, + dc.ListRolesByVendorIdVariables + > + result = await _service.connector + .listRolesByVendorId(vendorId: vendorId) + .execute(); return result.data.roles .map( (dc.ListRolesByVendorIdRoles role) => OneTimeOrderRoleOption( @@ -69,7 +82,8 @@ class OneTimeOrderBloc extends Bloc ) .toList(); }, - onError: (_) => emit(state.copyWith(roles: const [])), + onError: (_) => + emit(state.copyWith(roles: const [])), ); if (roles != null) { @@ -81,7 +95,10 @@ class OneTimeOrderBloc extends Bloc final List? hubs = await handleErrorWithResult( action: () async { final String businessId = await _service.getBusinessId(); - final QueryResult + final QueryResult< + dc.ListTeamHubsByOwnerIdData, + dc.ListTeamHubsByOwnerIdVariables + > result = await _service.connector .listTeamHubsByOwnerId(ownerId: businessId) .execute(); @@ -103,7 +120,8 @@ class OneTimeOrderBloc extends Bloc ) .toList(); }, - onError: (_) => add(const OneTimeOrderHubsLoaded([])), + onError: (_) => + add(const OneTimeOrderHubsLoaded([])), ); if (hubs != null) { @@ -115,13 +133,11 @@ class OneTimeOrderBloc extends Bloc OneTimeOrderVendorsLoaded event, Emitter emit, ) async { - final Vendor? selectedVendor = - event.vendors.isNotEmpty ? event.vendors.first : null; + final Vendor? selectedVendor = event.vendors.isNotEmpty + ? event.vendors.first + : null; emit( - state.copyWith( - vendors: event.vendors, - selectedVendor: selectedVendor, - ), + state.copyWith(vendors: event.vendors, selectedVendor: selectedVendor), ); if (selectedVendor != null) { await _loadRolesForVendor(selectedVendor.id, emit); @@ -140,8 +156,9 @@ class OneTimeOrderBloc extends Bloc OneTimeOrderHubsLoaded event, Emitter emit, ) { - final OneTimeOrderHubOption? selectedHub = - event.hubs.isNotEmpty ? event.hubs.first : null; + final OneTimeOrderHubOption? selectedHub = event.hubs.isNotEmpty + ? event.hubs.first + : null; emit( state.copyWith( hubs: event.hubs, @@ -155,12 +172,7 @@ class OneTimeOrderBloc extends Bloc OneTimeOrderHubChanged event, Emitter emit, ) { - emit( - state.copyWith( - selectedHub: event.hub, - location: event.hub.name, - ), - ); + emit(state.copyWith(selectedHub: event.hub, location: event.hub.name)); } void _onEventNameChanged( @@ -261,4 +273,29 @@ class OneTimeOrderBloc extends Bloc ), ); } + + void _onInitialized( + OneTimeOrderInitialized event, + Emitter emit, + ) { + final Map data = event.data; + final String title = data['title']?.toString() ?? ''; + final int workers = (data['workers'] as int?) ?? 1; + final DateTime? startDate = data['startDate'] as DateTime?; + + emit( + state.copyWith( + eventName: title, + date: startDate ?? DateTime.now(), + positions: [ + OneTimeOrderPosition( + role: data['roleName']?.toString() ?? '', + count: workers, + startTime: data['startTime']?.toString() ?? '09:00', + endTime: data['endTime']?.toString() ?? '17:00', + ), + ], + ), + ); + } } diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_event.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_event.dart index 7258c2d0..b6255dab 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_event.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_event.dart @@ -81,3 +81,11 @@ class OneTimeOrderPositionUpdated extends OneTimeOrderEvent { class OneTimeOrderSubmitted extends OneTimeOrderEvent { const OneTimeOrderSubmitted(); } + +class OneTimeOrderInitialized extends OneTimeOrderEvent { + const OneTimeOrderInitialized(this.data); + final Map data; + + @override + List get props => [data]; +} diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_bloc.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_bloc.dart index fbaaf3a9..afd1ff92 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_bloc.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_bloc.dart @@ -10,9 +10,11 @@ import 'permanent_order_state.dart'; /// BLoC for managing the permanent order creation form. class PermanentOrderBloc extends Bloc - with BlocErrorHandler, SafeBloc { + with + BlocErrorHandler, + SafeBloc { PermanentOrderBloc(this._createPermanentOrderUseCase, this._service) - : super(PermanentOrderState.initial()) { + : super(PermanentOrderState.initial()) { on(_onVendorsLoaded); on(_onVendorChanged); on(_onHubsLoaded); @@ -24,6 +26,7 @@ class PermanentOrderBloc extends Bloc on(_onPositionRemoved); on(_onPositionUpdated); on(_onSubmitted); + on(_onInitialized); _loadVendors(); _loadHubs(); @@ -45,8 +48,10 @@ class PermanentOrderBloc extends Bloc Future _loadVendors() async { final List? vendors = await handleErrorWithResult( action: () async { - final QueryResult result = - await _service.connector.listVendors().execute(); + final QueryResult result = await _service + .connector + .listVendors() + .execute(); return result.data.vendors .map( (dc.ListVendorsVendors vendor) => domain.Vendor( @@ -71,10 +76,13 @@ class PermanentOrderBloc extends Bloc ) async { final List? roles = await handleErrorWithResult( action: () async { - final QueryResult - result = await _service.connector - .listRolesByVendorId(vendorId: vendorId) - .execute(); + final QueryResult< + dc.ListRolesByVendorIdData, + dc.ListRolesByVendorIdVariables + > + result = await _service.connector + .listRolesByVendorId(vendorId: vendorId) + .execute(); return result.data.roles .map( (dc.ListRolesByVendorIdRoles role) => PermanentOrderRoleOption( @@ -85,7 +93,8 @@ class PermanentOrderBloc extends Bloc ) .toList(); }, - onError: (_) => emit(state.copyWith(roles: const [])), + onError: (_) => + emit(state.copyWith(roles: const [])), ); if (roles != null) { @@ -97,10 +106,13 @@ class PermanentOrderBloc extends Bloc final List? hubs = await handleErrorWithResult( action: () async { final String businessId = await _service.getBusinessId(); - final QueryResult - result = await _service.connector - .listTeamHubsByOwnerId(ownerId: businessId) - .execute(); + final QueryResult< + dc.ListTeamHubsByOwnerIdData, + dc.ListTeamHubsByOwnerIdVariables + > + result = await _service.connector + .listTeamHubsByOwnerId(ownerId: businessId) + .execute(); return result.data.teamHubs .map( (dc.ListTeamHubsByOwnerIdTeamHubs hub) => PermanentOrderHubOption( @@ -119,7 +131,8 @@ class PermanentOrderBloc extends Bloc ) .toList(); }, - onError: (_) => add(const PermanentOrderHubsLoaded([])), + onError: (_) => + add(const PermanentOrderHubsLoaded([])), ); if (hubs != null) { @@ -131,13 +144,11 @@ class PermanentOrderBloc extends Bloc PermanentOrderVendorsLoaded event, Emitter emit, ) async { - final domain.Vendor? selectedVendor = - event.vendors.isNotEmpty ? event.vendors.first : null; + final domain.Vendor? selectedVendor = event.vendors.isNotEmpty + ? event.vendors.first + : null; emit( - state.copyWith( - vendors: event.vendors, - selectedVendor: selectedVendor, - ), + state.copyWith(vendors: event.vendors, selectedVendor: selectedVendor), ); if (selectedVendor != null) { await _loadRolesForVendor(selectedVendor.id, emit); @@ -156,8 +167,9 @@ class PermanentOrderBloc extends Bloc PermanentOrderHubsLoaded event, Emitter emit, ) { - final PermanentOrderHubOption? selectedHub = - event.hubs.isNotEmpty ? event.hubs.first : null; + final PermanentOrderHubOption? selectedHub = event.hubs.isNotEmpty + ? event.hubs.first + : null; emit( state.copyWith( hubs: event.hubs, @@ -171,12 +183,7 @@ class PermanentOrderBloc extends Bloc PermanentOrderHubChanged event, Emitter emit, ) { - emit( - state.copyWith( - selectedHub: event.hub, - location: event.hub.name, - ), - ); + emit(state.copyWith(selectedHub: event.hub, location: event.hub.name)); } void _onEventNameChanged( @@ -226,7 +233,12 @@ class PermanentOrderBloc extends Bloc } else { days.add(label); } - emit(state.copyWith(permanentDays: _sortDays(days), autoSelectedDayIndex: autoIndex)); + emit( + state.copyWith( + permanentDays: _sortDays(days), + autoSelectedDayIndex: autoIndex, + ), + ); } void _onPositionAdded( @@ -325,6 +337,31 @@ class PermanentOrderBloc extends Bloc ); } + void _onInitialized( + PermanentOrderInitialized event, + Emitter emit, + ) { + final Map data = event.data; + final String title = data['title']?.toString() ?? ''; + final int workers = (data['workers'] as int?) ?? 1; + final DateTime? startDate = data['startDate'] as DateTime?; + + emit( + state.copyWith( + eventName: title, + startDate: startDate ?? DateTime.now(), + positions: [ + PermanentOrderPosition( + role: data['roleName']?.toString() ?? '', + count: workers, + startTime: data['startTime']?.toString() ?? '09:00', + endTime: data['endTime']?.toString() ?? '17:00', + ), + ], + ), + ); + } + static List _sortDays(List days) { days.sort( (String a, String b) => diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_event.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_event.dart index bcf98127..28dcbcd3 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_event.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_event.dart @@ -98,3 +98,11 @@ class PermanentOrderPositionUpdated extends PermanentOrderEvent { class PermanentOrderSubmitted extends PermanentOrderEvent { const PermanentOrderSubmitted(); } + +class PermanentOrderInitialized extends PermanentOrderEvent { + const PermanentOrderInitialized(this.data); + final Map data; + + @override + List get props => [data]; +} diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_bloc.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_bloc.dart index e1f1f6c0..bc71bd68 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_bloc.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_bloc.dart @@ -10,9 +10,11 @@ import 'recurring_order_state.dart'; /// BLoC for managing the recurring order creation form. class RecurringOrderBloc extends Bloc - with BlocErrorHandler, SafeBloc { + with + BlocErrorHandler, + SafeBloc { RecurringOrderBloc(this._createRecurringOrderUseCase, this._service) - : super(RecurringOrderState.initial()) { + : super(RecurringOrderState.initial()) { on(_onVendorsLoaded); on(_onVendorChanged); on(_onHubsLoaded); @@ -25,6 +27,7 @@ class RecurringOrderBloc extends Bloc on(_onPositionRemoved); on(_onPositionUpdated); on(_onSubmitted); + on(_onInitialized); _loadVendors(); _loadHubs(); @@ -46,8 +49,10 @@ class RecurringOrderBloc extends Bloc Future _loadVendors() async { final List? vendors = await handleErrorWithResult( action: () async { - final QueryResult result = - await _service.connector.listVendors().execute(); + final QueryResult result = await _service + .connector + .listVendors() + .execute(); return result.data.vendors .map( (dc.ListVendorsVendors vendor) => domain.Vendor( @@ -72,10 +77,13 @@ class RecurringOrderBloc extends Bloc ) async { final List? roles = await handleErrorWithResult( action: () async { - final QueryResult - result = await _service.connector - .listRolesByVendorId(vendorId: vendorId) - .execute(); + final QueryResult< + dc.ListRolesByVendorIdData, + dc.ListRolesByVendorIdVariables + > + result = await _service.connector + .listRolesByVendorId(vendorId: vendorId) + .execute(); return result.data.roles .map( (dc.ListRolesByVendorIdRoles role) => RecurringOrderRoleOption( @@ -86,7 +94,8 @@ class RecurringOrderBloc extends Bloc ) .toList(); }, - onError: (_) => emit(state.copyWith(roles: const [])), + onError: (_) => + emit(state.copyWith(roles: const [])), ); if (roles != null) { @@ -98,10 +107,13 @@ class RecurringOrderBloc extends Bloc final List? hubs = await handleErrorWithResult( action: () async { final String businessId = await _service.getBusinessId(); - final QueryResult - result = await _service.connector - .listTeamHubsByOwnerId(ownerId: businessId) - .execute(); + final QueryResult< + dc.ListTeamHubsByOwnerIdData, + dc.ListTeamHubsByOwnerIdVariables + > + result = await _service.connector + .listTeamHubsByOwnerId(ownerId: businessId) + .execute(); return result.data.teamHubs .map( (dc.ListTeamHubsByOwnerIdTeamHubs hub) => RecurringOrderHubOption( @@ -120,7 +132,8 @@ class RecurringOrderBloc extends Bloc ) .toList(); }, - onError: (_) => add(const RecurringOrderHubsLoaded([])), + onError: (_) => + add(const RecurringOrderHubsLoaded([])), ); if (hubs != null) { @@ -132,13 +145,11 @@ class RecurringOrderBloc extends Bloc RecurringOrderVendorsLoaded event, Emitter emit, ) async { - final domain.Vendor? selectedVendor = - event.vendors.isNotEmpty ? event.vendors.first : null; + final domain.Vendor? selectedVendor = event.vendors.isNotEmpty + ? event.vendors.first + : null; emit( - state.copyWith( - vendors: event.vendors, - selectedVendor: selectedVendor, - ), + state.copyWith(vendors: event.vendors, selectedVendor: selectedVendor), ); if (selectedVendor != null) { await _loadRolesForVendor(selectedVendor.id, emit); @@ -157,8 +168,9 @@ class RecurringOrderBloc extends Bloc RecurringOrderHubsLoaded event, Emitter emit, ) { - final RecurringOrderHubOption? selectedHub = - event.hubs.isNotEmpty ? event.hubs.first : null; + final RecurringOrderHubOption? selectedHub = event.hubs.isNotEmpty + ? event.hubs.first + : null; emit( state.copyWith( hubs: event.hubs, @@ -172,12 +184,7 @@ class RecurringOrderBloc extends Bloc RecurringOrderHubChanged event, Emitter emit, ) { - emit( - state.copyWith( - selectedHub: event.hub, - location: event.hub.name, - ), - ); + emit(state.copyWith(selectedHub: event.hub, location: event.hub.name)); } void _onEventNameChanged( @@ -243,7 +250,12 @@ class RecurringOrderBloc extends Bloc } else { days.add(label); } - emit(state.copyWith(recurringDays: _sortDays(days), autoSelectedDayIndex: autoIndex)); + emit( + state.copyWith( + recurringDays: _sortDays(days), + autoSelectedDayIndex: autoIndex, + ), + ); } void _onPositionAdded( @@ -344,6 +356,31 @@ class RecurringOrderBloc extends Bloc ); } + void _onInitialized( + RecurringOrderInitialized event, + Emitter emit, + ) { + final Map data = event.data; + final String title = data['title']?.toString() ?? ''; + final int workers = (data['workers'] as int?) ?? 1; + final DateTime? startDate = data['startDate'] as DateTime?; + + emit( + state.copyWith( + eventName: title, + startDate: startDate ?? DateTime.now(), + positions: [ + RecurringOrderPosition( + role: data['roleName']?.toString() ?? '', + count: workers, + startTime: data['startTime']?.toString() ?? '09:00', + endTime: data['endTime']?.toString() ?? '17:00', + ), + ], + ), + ); + } + static List _sortDays(List days) { days.sort( (String a, String b) => diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_event.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_event.dart index 3803153a..a04dbdbb 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_event.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_event.dart @@ -107,3 +107,11 @@ class RecurringOrderPositionUpdated extends RecurringOrderEvent { class RecurringOrderSubmitted extends RecurringOrderEvent { const RecurringOrderSubmitted(); } + +class RecurringOrderInitialized extends RecurringOrderEvent { + const RecurringOrderInitialized(this.data); + final Map data; + + @override + List get props => [data]; +} diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/one_time_order_page.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/one_time_order_page.dart index cbd5bb2e..899e787b 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/one_time_order_page.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/one_time_order_page.dart @@ -21,7 +21,14 @@ class OneTimeOrderPage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => Modular.get(), + create: (BuildContext context) { + final OneTimeOrderBloc bloc = Modular.get(); + final dynamic args = Modular.args.data; + if (args is Map) { + bloc.add(OneTimeOrderInitialized(args)); + } + return bloc; + }, child: BlocBuilder( builder: (BuildContext context, OneTimeOrderState state) { final OneTimeOrderBloc bloc = BlocProvider.of( diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/permanent_order_page.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/permanent_order_page.dart index 1b219108..2fb67a03 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/permanent_order_page.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/permanent_order_page.dart @@ -16,7 +16,14 @@ class PermanentOrderPage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => Modular.get(), + create: (BuildContext context) { + final PermanentOrderBloc bloc = Modular.get(); + final dynamic args = Modular.args.data; + if (args is Map) { + bloc.add(PermanentOrderInitialized(args)); + } + return bloc; + }, child: BlocBuilder( builder: (BuildContext context, PermanentOrderState state) { final PermanentOrderBloc bloc = BlocProvider.of( diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/recurring_order_page.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/recurring_order_page.dart index c731f63b..6954e826 100644 --- a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/recurring_order_page.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/recurring_order_page.dart @@ -16,7 +16,14 @@ class RecurringOrderPage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => Modular.get(), + create: (BuildContext context) { + final RecurringOrderBloc bloc = Modular.get(); + final dynamic args = Modular.args.data; + if (args is Map) { + bloc.add(RecurringOrderInitialized(args)); + } + return bloc; + }, child: BlocBuilder( builder: (BuildContext context, RecurringOrderState state) { final RecurringOrderBloc bloc = BlocProvider.of(