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:
Achintha Isuru
2026-02-22 01:37:49 -05:00
parent 036920377e
commit 3aab5bfc26
11 changed files with 272 additions and 119 deletions

View File

@@ -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;
}
}
}