order success
This commit is contained in:
@@ -56,10 +56,11 @@ class CheckoutPage extends HookConsumerWidget {
|
||||
// Payment method (will be set to first payment term name from API)
|
||||
final paymentMethod = useState<String>('');
|
||||
|
||||
// Price negotiation
|
||||
final needsNegotiation = useState<bool>(false);
|
||||
// Price negotiation (ignore_pricing_rule in API)
|
||||
final ignorePricingRule = useState<bool>(false);
|
||||
|
||||
final needsContract = useState(false);
|
||||
// Contract request (contract_request in API)
|
||||
final contractRequest = useState<bool>(false);
|
||||
|
||||
// Watch API provider for payment terms
|
||||
final paymentTermsListAsync = ref.watch(paymentTermsListProvider);
|
||||
@@ -145,8 +146,8 @@ class CheckoutPage extends HookConsumerWidget {
|
||||
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
|
||||
// Payment Method Section (hidden if negotiation is checked)
|
||||
if (!needsNegotiation.value)
|
||||
// Payment Method Section (hidden if price negotiation is checked)
|
||||
if (!ignorePricingRule.value)
|
||||
paymentTermsListAsync.when(
|
||||
data: (paymentTerms) {
|
||||
// Set default payment method to first term if not set
|
||||
@@ -220,7 +221,7 @@ class CheckoutPage extends HookConsumerWidget {
|
||||
),
|
||||
),
|
||||
|
||||
if (!needsNegotiation.value)
|
||||
if (!ignorePricingRule.value)
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
|
||||
// Discount Code Section
|
||||
@@ -240,7 +241,7 @@ class CheckoutPage extends HookConsumerWidget {
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
|
||||
// Price Negotiation Section
|
||||
PriceNegotiationSection(needsNegotiation: needsNegotiation),
|
||||
PriceNegotiationSection(ignorePricingRule: ignorePricingRule),
|
||||
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
|
||||
@@ -256,9 +257,9 @@ class CheckoutPage extends HookConsumerWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: needsContract.value,
|
||||
value: contractRequest.value,
|
||||
onChanged: (value) {
|
||||
needsContract.value = value ?? false;
|
||||
contractRequest.value = value ?? false;
|
||||
},
|
||||
activeColor: AppColors.warning,
|
||||
),
|
||||
@@ -308,7 +309,8 @@ class CheckoutPage extends HookConsumerWidget {
|
||||
// Place Order Button
|
||||
CheckoutSubmitButton(
|
||||
formKey: formKey,
|
||||
needsNegotiation: needsNegotiation.value,
|
||||
ignorePricingRule: ignorePricingRule.value,
|
||||
contractRequest: contractRequest.value,
|
||||
needsInvoice: needsInvoice.value,
|
||||
selectedAddress: selectedAddress.value,
|
||||
paymentMethod: paymentMethod.value,
|
||||
|
||||
@@ -20,7 +20,8 @@ class CheckoutSubmitButton extends HookConsumerWidget {
|
||||
const CheckoutSubmitButton({
|
||||
super.key,
|
||||
required this.formKey,
|
||||
required this.needsNegotiation,
|
||||
required this.ignorePricingRule,
|
||||
required this.contractRequest,
|
||||
required this.needsInvoice,
|
||||
required this.selectedAddress,
|
||||
required this.paymentMethod,
|
||||
@@ -30,7 +31,8 @@ class CheckoutSubmitButton extends HookConsumerWidget {
|
||||
});
|
||||
|
||||
final GlobalKey<FormState> formKey;
|
||||
final bool needsNegotiation;
|
||||
final bool ignorePricingRule;
|
||||
final bool contractRequest;
|
||||
final bool needsInvoice;
|
||||
final Address? selectedAddress;
|
||||
final String paymentMethod;
|
||||
@@ -62,7 +64,7 @@ class CheckoutSubmitButton extends HookConsumerWidget {
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: needsNegotiation
|
||||
backgroundColor: ignorePricingRule
|
||||
? AppColors.warning
|
||||
: AppColors.primaryBlue,
|
||||
foregroundColor: Colors.white,
|
||||
@@ -73,7 +75,7 @@ class CheckoutSubmitButton extends HookConsumerWidget {
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
needsNegotiation ? 'Gửi yêu cầu đàm phán' : 'Đặt hàng',
|
||||
ignorePricingRule ? 'Gửi yêu cầu đàm phán' : 'Đặt hàng',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -122,7 +124,8 @@ class CheckoutSubmitButton extends HookConsumerWidget {
|
||||
deliveryAddress: deliveryAddressData,
|
||||
paymentMethod: paymentMethod,
|
||||
needsInvoice: needsInvoice,
|
||||
needsNegotiation: needsNegotiation,
|
||||
ignorePricingRule: ignorePricingRule,
|
||||
contractRequest: contractRequest,
|
||||
notes: notes,
|
||||
).future);
|
||||
|
||||
@@ -131,7 +134,7 @@ class CheckoutSubmitButton extends HookConsumerWidget {
|
||||
result['orderId'] as String? ??
|
||||
'DH${DateTime.now().millisecondsSinceEpoch.toString().substring(7)}';
|
||||
|
||||
if (needsNegotiation) {
|
||||
if (ignorePricingRule) {
|
||||
// Navigate to order success page with negotiation flag
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
@@ -13,8 +13,8 @@ import 'package:worker/core/theme/colors.dart';
|
||||
/// Allows user to request price negotiation instead of direct order.
|
||||
class PriceNegotiationSection extends HookWidget {
|
||||
|
||||
const PriceNegotiationSection({super.key, required this.needsNegotiation});
|
||||
final ValueNotifier<bool> needsNegotiation;
|
||||
const PriceNegotiationSection({super.key, required this.ignorePricingRule});
|
||||
final ValueNotifier<bool> ignorePricingRule;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -29,9 +29,9 @@ class PriceNegotiationSection extends HookWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: needsNegotiation.value,
|
||||
value: ignorePricingRule.value,
|
||||
onChanged: (value) {
|
||||
needsNegotiation.value = value ?? false;
|
||||
ignorePricingRule.value = value ?? false;
|
||||
},
|
||||
activeColor: AppColors.warning,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user