feat: Allow pre-filling order creation forms with reorder data and update reorder navigation to directly open relevant order pages.
This commit is contained in:
@@ -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<String, dynamic> data) {
|
||||
ClientHomeSheets.showOrderFormSheet(
|
||||
context,
|
||||
data,
|
||||
onSubmit: (Map<String, dynamic> 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<String, dynamic> populatedData = Map<String, dynamic>.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user