From da030764119a2352200f74c920399978b004cb43 Mon Sep 17 00:00:00 2001 From: Stephane Date: Fri, 30 May 2025 22:31:20 +0300 Subject: [PATCH] Change DA to MGA --- lib/Views/newCommand.dart | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/Views/newCommand.dart b/lib/Views/newCommand.dart index 725a4fe..4a7530b 100644 --- a/lib/Views/newCommand.dart +++ b/lib/Views/newCommand.dart @@ -45,7 +45,7 @@ class _NouvelleCommandePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: const CustomAppBar(title: 'Nouvelle Commande'), - drawer: CustomDrawer(), + drawer: CustomDrawer(), body: Column( children: [ // Header avec logo et titre @@ -126,7 +126,7 @@ class _NouvelleCommandePageState extends State { ], ), ), - + // Contenu principal Expanded( child: SingleChildScrollView( @@ -221,7 +221,8 @@ class _NouvelleCommandePageState extends State { if (value == null || value.isEmpty) { return 'Veuillez entrer un email'; } - if (!RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(value)) { + if (!RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$') + .hasMatch(value)) { return 'Veuillez entrer un email valide'; } return null; @@ -297,7 +298,7 @@ class _NouvelleCommandePageState extends State { itemBuilder: (context, index) { final product = _products[index]; final quantity = _quantites[product.id] ?? 0; - + return Card( margin: const EdgeInsets.symmetric(vertical: 8), elevation: 2, @@ -316,7 +317,7 @@ class _NouvelleCommandePageState extends State { color: Colors.blue.shade50, borderRadius: BorderRadius.circular(8), ), - child: const Icon(Icons.shopping_bag, + child: const Icon(Icons.shopping_bag, color: Colors.blue), ), title: Text( @@ -328,7 +329,7 @@ class _NouvelleCommandePageState extends State { children: [ const SizedBox(height: 4), Text( - '${product.price.toStringAsFixed(2)} DA', + '${product.price.toStringAsFixed(2)} MGA', style: TextStyle( color: Colors.green.shade700, fontWeight: FontWeight.w600, @@ -364,12 +365,14 @@ class _NouvelleCommandePageState extends State { ), Text( quantity.toString(), - style: const TextStyle(fontWeight: FontWeight.bold), + style: const TextStyle( + fontWeight: FontWeight.bold), ), IconButton( icon: const Icon(Icons.add, size: 18), onPressed: () { - if (product.stock == null || quantity < product.stock!) { + if (product.stock == null || + quantity < product.stock!) { setState(() { _quantites[product.id!] = quantity + 1; }); @@ -397,7 +400,7 @@ class _NouvelleCommandePageState extends State { Widget _buildCartSection() { final itemsInCart = _quantites.entries.where((e) => e.value > 0).toList(); - + if (itemsInCart.isEmpty) { return Card( elevation: 4, @@ -454,9 +457,10 @@ class _NouvelleCommandePageState extends State { child: const Icon(Icons.shopping_bag, size: 20), ), title: Text(product.name), - subtitle: Text('${entry.value} x ${product.price.toStringAsFixed(2)} DA'), + subtitle: Text( + '${entry.value} x ${product.price.toStringAsFixed(2)} MGA'), trailing: Text( - '${(entry.value * product.price).toStringAsFixed(2)} DA', + '${(entry.value * product.price).toStringAsFixed(2)} MGA', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.blue.shade800, @@ -499,7 +503,7 @@ class _NouvelleCommandePageState extends State { style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), Text( - '${total.toStringAsFixed(2)} DA', + '${total.toStringAsFixed(2)} MGA', style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, @@ -559,11 +563,11 @@ class _NouvelleCommandePageState extends State { // Calculer le total et préparer les détails double total = 0; final details = []; - + for (final entry in itemsInCart) { final product = _products.firstWhere((p) => p.id == entry.key); total += entry.value * product.price; - + details.add(DetailCommande( commandeId: 0, // Valeur temporaire, sera remplacée dans la transaction produitId: product.id!, @@ -585,7 +589,7 @@ class _NouvelleCommandePageState extends State { try { // Enregistrer la commande dans la base de données await _database.createCommandeComplete(client, commande, details); - + Get.snackbar( 'Succès', 'Votre commande a été enregistrée', @@ -593,13 +597,12 @@ class _NouvelleCommandePageState extends State { backgroundColor: Colors.green, colorText: Colors.white, ); - + // Réinitialiser le formulaire _formKey.currentState!.reset(); setState(() { _quantites.clear(); }); - } catch (e) { Get.snackbar( 'Erreur', @@ -620,4 +623,4 @@ class _NouvelleCommandePageState extends State { _adresseController.dispose(); super.dispose(); } -} \ No newline at end of file +}