fix
This commit is contained in:
@@ -9,40 +9,29 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:worker/core/constants/ui_constants.dart';
|
||||
import 'package:worker/core/router/app_router.dart';
|
||||
import 'package:worker/core/theme/colors.dart';
|
||||
import 'package:worker/features/account/domain/entities/address.dart';
|
||||
|
||||
/// Checkout Submit Button
|
||||
///
|
||||
/// Button that changes based on negotiation checkbox state.
|
||||
class CheckoutSubmitButton extends StatelessWidget {
|
||||
final GlobalKey<FormState> formKey;
|
||||
final bool needsNegotiation;
|
||||
final bool needsInvoice;
|
||||
final String name;
|
||||
final String phone;
|
||||
final String address;
|
||||
final String? province;
|
||||
final String? ward;
|
||||
final String paymentMethod;
|
||||
final String companyName;
|
||||
final String taxId;
|
||||
final double total;
|
||||
|
||||
const CheckoutSubmitButton({
|
||||
super.key,
|
||||
required this.formKey,
|
||||
required this.needsNegotiation,
|
||||
required this.needsInvoice,
|
||||
required this.name,
|
||||
required this.phone,
|
||||
required this.address,
|
||||
required this.province,
|
||||
required this.ward,
|
||||
required this.selectedAddress,
|
||||
required this.paymentMethod,
|
||||
required this.companyName,
|
||||
required this.taxId,
|
||||
required this.total,
|
||||
});
|
||||
|
||||
final GlobalKey<FormState> formKey;
|
||||
final bool needsNegotiation;
|
||||
final bool needsInvoice;
|
||||
final Address? selectedAddress;
|
||||
final String paymentMethod;
|
||||
final double total;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
@@ -63,6 +52,18 @@ class CheckoutSubmitButton extends StatelessWidget {
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
// Validate address is selected
|
||||
if (selectedAddress == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Vui lòng chọn địa chỉ giao hàng'),
|
||||
backgroundColor: AppColors.danger,
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (formKey.currentState?.validate() ?? false) {
|
||||
_handlePlaceOrder(context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user