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:core_localization/core_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_modular/flutter_modular.dart';
|
import 'package:flutter_modular/flutter_modular.dart';
|
||||||
|
import 'package:krow_domain/krow_domain.dart';
|
||||||
import 'package:krow_core/core.dart';
|
import 'package:krow_core/core.dart';
|
||||||
import '../blocs/client_home_state.dart';
|
import '../blocs/client_home_state.dart';
|
||||||
import '../widgets/actions_widget.dart';
|
import '../widgets/actions_widget.dart';
|
||||||
@@ -75,15 +76,23 @@ class DashboardWidgetBuilder extends StatelessWidget {
|
|||||||
context,
|
context,
|
||||||
data,
|
data,
|
||||||
onSubmit: (Map<String, dynamic> submittedData) {
|
onSubmit: (Map<String, dynamic> submittedData) {
|
||||||
final String? dateStr = submittedData['date']?.toString();
|
final String? typeStr = submittedData['type']?.toString();
|
||||||
if (dateStr == null || dateStr.isEmpty) {
|
if (typeStr == null || typeStr.isEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final DateTime? initialDate = DateTime.tryParse(dateStr);
|
final OrderType orderType = OrderType.fromString(typeStr);
|
||||||
if (initialDate == null) {
|
switch (orderType) {
|
||||||
return;
|
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