refactor: Update order creation logic to use order type instead of date string
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import '../blocs/client_home_state.dart';
|
||||
import '../widgets/actions_widget.dart';
|
||||
@@ -75,15 +76,23 @@ class DashboardWidgetBuilder extends StatelessWidget {
|
||||
context,
|
||||
data,
|
||||
onSubmit: (Map<String, dynamic> submittedData) {
|
||||
final String? dateStr = submittedData['date']?.toString();
|
||||
if (dateStr == null || dateStr.isEmpty) {
|
||||
final String? typeStr = submittedData['type']?.toString();
|
||||
if (typeStr == null || typeStr.isEmpty) {
|
||||
return;
|
||||
}
|
||||
final DateTime? initialDate = DateTime.tryParse(dateStr);
|
||||
if (initialDate == null) {
|
||||
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;
|
||||
}
|
||||
Modular.to.toOrdersSpecificDate(initialDate);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user