diff --git a/lib/pages/cart_page.dart b/lib/pages/cart_page.dart index 2d716b8..d8f53fb 100644 --- a/lib/pages/cart_page.dart +++ b/lib/pages/cart_page.dart @@ -110,7 +110,7 @@ class _CartPageState extends State { Text('• Table: ${widget.tableId}'), Text('• Personnes: ${widget.personne}'), Text('• Articles: ${_getTotalArticles()}'), - Text('• Total: ${_calculateTotal().toStringAsFixed(2)} €'), + Text('• Total: ${_calculateTotal().toStringAsFixed(2)} MGA'), ], ), actions: [ @@ -385,7 +385,7 @@ class _CartPageState extends State { ], ), Text( - '${item.prix.toStringAsFixed(2)} € l\'unité', + '${item.prix.toStringAsFixed(2)} MGA l\'unité', style: TextStyle( fontSize: 14, color: Colors.grey[600], @@ -447,7 +447,7 @@ class _CartPageState extends State { ), // Prix total de l'article Text( - '${(item.prix * item.quantity).toStringAsFixed(2)} €', + '${(item.prix * item.quantity).toStringAsFixed(2)} MGA', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, @@ -527,7 +527,7 @@ class _CartPageState extends State { ), ), Text( - '${_calculateTotal().toStringAsFixed(2)} €', + '${_calculateTotal().toStringAsFixed(2)} MGA', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, diff --git a/lib/pages/commandes_screen.dart b/lib/pages/commandes_screen.dart index b205d8f..d1c7c23 100644 --- a/lib/pages/commandes_screen.dart +++ b/lib/pages/commandes_screen.dart @@ -32,7 +32,7 @@ class _OrdersManagementScreenState extends State { // Get all orders with filtering for active ones only final response = await http.get( - Uri.parse('$baseUrl/commandes?statut=en_attente,en_preparation'), + Uri.parse('$baseUrl/commandes'), headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', @@ -309,7 +309,7 @@ class _OrdersManagementScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Table ${order.tableId} - ${order.totalTtc.toStringAsFixed(2)} €', + 'Table ${order.tableId} - ${order.totalTtc.toStringAsFixed(2)} MGA', ), const SizedBox(height: 16), const Text('Mode de paiement:'), @@ -668,7 +668,7 @@ class OrderCard extends StatelessWidget { ), ), Text( - '${(item.quantite * 8.00).toStringAsFixed(2)} €', // Placeholder price + '${(item.quantite * 8.00).toStringAsFixed(2)} MGA', // Placeholder price style: const TextStyle( fontSize: 14, color: Colors.black87, @@ -701,7 +701,7 @@ class OrderCard extends StatelessWidget { ), ), Text( - '${order.totalTtc.toStringAsFixed(2)} €', + '${order.totalTtc.toStringAsFixed(2)} MGA', style: const TextStyle( fontSize: 16, fontWeight: FontWeight.bold, diff --git a/lib/pages/menu.dart b/lib/pages/menu.dart index f4cb0f6..2be56a7 100644 --- a/lib/pages/menu.dart +++ b/lib/pages/menu.dart @@ -9,7 +9,8 @@ class MenuPage extends StatefulWidget { final int tableId; final int personne; - const MenuPage({Key? key, required this.tableId, required this.personne}) : super(key: key); + const MenuPage({Key? key, required this.tableId, required this.personne}) + : super(key: key); @override State createState() => _MenuPageState(); @@ -29,13 +30,16 @@ class _MenuPageState extends State { Future fetchCategories() async { try { - final url = Uri.parse("https://restaurant.careeracademy.mg/api/menu-categories"); + final url = Uri.parse( + "https://restaurant.careeracademy.mg/api/menu-categories", + ); final response = await http.get(url); if (response.statusCode == 200) { final jsonResponse = json.decode(response.body); - final categoriesList = (jsonResponse['data']?['categories'] ?? []) as List; + final categoriesList = + (jsonResponse['data']?['categories'] ?? []) as List; setState(() { _categories = categoriesList; @@ -54,15 +58,16 @@ class _MenuPageState extends State { Future fetchMenus(int categoryId) async { try { - final url = Uri.parse("https://restaurant.careeracademy.mg/api/menus/category/$categoryId?disponible=true"); + final url = Uri.parse( + "https://restaurant.careeracademy.mg/api/menus/category/$categoryId?disponible=true", + ); final response = await http.get(url); if (response.statusCode == 200) { final jsonResponse = json.decode(response.body); - final List menusList = jsonResponse is List - ? jsonResponse - : (jsonResponse['data'] ?? []); + final List menusList = + jsonResponse is List ? jsonResponse : (jsonResponse['data'] ?? []); setState(() { _menus = menusList; @@ -99,10 +104,7 @@ class _MenuPageState extends State { showDialog( context: context, builder: (BuildContext context) { - return AddToCartModal( - item: item, - onAddToCart: addToCart, - ); + return AddToCartModal(item: item, onAddToCart: addToCart); }, ); } @@ -112,11 +114,14 @@ class _MenuPageState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => CartPage( - tableId: widget.tableId, - personne: widget.personne, - cartItems: List.from(_cart), // Copie de la liste pour éviter les modifications - ), + builder: + (context) => CartPage( + tableId: widget.tableId, + personne: widget.personne, + cartItems: List.from( + _cart, + ), // Copie de la liste pour éviter les modifications + ), ), ).then((_) { // Optionnel: actualiser le panier au retour de la page panier @@ -163,53 +168,58 @@ class _MenuPageState extends State { if (_categories.isNotEmpty) Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: _categories.map((cat) { - return buildCategoryButton(cat['nom'], cat['id']); - }).toList(), + children: + _categories.map((cat) { + return buildCategoryButton(cat['nom'], cat['id']); + }).toList(), ) else Center(child: CircularProgressIndicator()), Expanded( - child: _menus.isNotEmpty - ? ListView.builder( - itemCount: _menus.length, - itemBuilder: (context, index) { - final item = _menus[index]; - return Card( - margin: EdgeInsets.all(8), - child: ListTile( - onTap: () => showAddToCartModal(item), // Clic sur tout l'item - leading: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: Colors.green[100], - borderRadius: BorderRadius.circular(8), + child: + _menus.isNotEmpty + ? ListView.builder( + itemCount: _menus.length, + itemBuilder: (context, index) { + final item = _menus[index]; + return Card( + margin: EdgeInsets.all(8), + child: ListTile( + onTap: + () => showAddToCartModal( + item, + ), // Clic sur tout l'item + leading: Container( + width: 60, + height: 60, + decoration: BoxDecoration( + color: Colors.green[100], + borderRadius: BorderRadius.circular(8), + ), + child: Icon( + Icons.restaurant_menu, + color: Colors.green[700], + size: 30, + ), ), - child: Icon( - Icons.restaurant_menu, - color: Colors.green[700], - size: 30, + title: Text( + item['nom'] ?? 'Nom non disponible', + style: TextStyle(fontWeight: FontWeight.bold), ), - ), - title: Text( - item['nom'] ?? 'Nom non disponible', - style: TextStyle(fontWeight: FontWeight.bold), - ), - subtitle: Text(item['commentaire'] ?? ''), - trailing: Text( - "${formatPrix(item['prix'])} €", - style: TextStyle( - color: Colors.green[700], - fontWeight: FontWeight.bold, - fontSize: 16, + subtitle: Text(item['commentaire'] ?? ''), + trailing: Text( + "${formatPrix(item['prix'])} MGA", + style: TextStyle( + color: Colors.green[700], + fontWeight: FontWeight.bold, + fontSize: 16, + ), ), ), - ), - ); - }, - ) - : Center(child: Text("Aucun menu disponible")), + ); + }, + ) + : Center(child: Text("Aucun menu disponible")), ), Container( width: double.infinity, @@ -295,9 +305,7 @@ class _AddToCartModalState extends State { @override Widget build(BuildContext context) { return Dialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), child: Container( padding: EdgeInsets.all(20), constraints: BoxConstraints(maxWidth: 400), @@ -311,10 +319,7 @@ class _AddToCartModalState extends State { children: [ Text( widget.item['nom'] ?? 'Menu', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - ), + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), IconButton( onPressed: () => Navigator.of(context).pop(), @@ -325,7 +330,7 @@ class _AddToCartModalState extends State { ], ), SizedBox(height: 16), - + // Image placeholder Container( width: double.infinity, @@ -343,13 +348,11 @@ class _AddToCartModalState extends State { SizedBox(height: 16), // Description - if (widget.item['commentaire'] != null && widget.item['commentaire'].toString().isNotEmpty) + if (widget.item['commentaire'] != null && + widget.item['commentaire'].toString().isNotEmpty) Text( widget.item['commentaire'], - style: TextStyle( - fontSize: 14, - color: Colors.grey[600], - ), + style: TextStyle(fontSize: 14, color: Colors.grey[600]), ), SizedBox(height: 16), @@ -359,13 +362,10 @@ class _AddToCartModalState extends State { children: [ Text( "Prix unitaire", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500), ), Text( - "${formatPrix(widget.item['prix'])} €", + "${formatPrix(widget.item['prix'])} MGA", style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, @@ -379,21 +379,21 @@ class _AddToCartModalState extends State { // Quantité Text( "Quantité", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500), ), SizedBox(height: 8), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ IconButton( - onPressed: _quantity > 1 ? () { - setState(() { - _quantity--; - }); - } : null, + onPressed: + _quantity > 1 + ? () { + setState(() { + _quantity--; + }); + } + : null, icon: Icon(Icons.remove), style: IconButton.styleFrom( backgroundColor: Colors.grey[200], @@ -402,10 +402,7 @@ class _AddToCartModalState extends State { SizedBox(width: 20), Text( _quantity.toString(), - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), SizedBox(width: 20), IconButton( @@ -426,10 +423,7 @@ class _AddToCartModalState extends State { // Notes Text( "Notes (optionnel)", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500), ), SizedBox(height: 8), TextField( @@ -466,7 +460,7 @@ class _AddToCartModalState extends State { ), ), Text( - "${calculateTotal().toStringAsFixed(2)} €", + "${calculateTotal().toStringAsFixed(2)} MGA", style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, @@ -486,11 +480,13 @@ class _AddToCartModalState extends State { _notesController.text, ); Navigator.of(context).pop(); - + // Afficher un snackbar de confirmation ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text("${widget.item['nom']} ajouté au panier"), + content: Text( + "${widget.item['nom']} ajouté au panier", + ), backgroundColor: Colors.green, duration: Duration(seconds: 2), ), @@ -521,4 +517,4 @@ class _AddToCartModalState extends State { ), ); } -} \ No newline at end of file +} diff --git a/lib/pages/menus_screen.dart b/lib/pages/menus_screen.dart index e949446..bb78a2c 100644 --- a/lib/pages/menus_screen.dart +++ b/lib/pages/menus_screen.dart @@ -186,7 +186,7 @@ class _MenuPageState extends State { ), subtitle: Text(item['commentaire'] ?? ''), trailing: Text( - "${formatPrix(item['prix'])} €", + "${formatPrix(item['prix'])} MGA", style: TextStyle( color: Colors.green[700], fontWeight: FontWeight.bold, @@ -345,7 +345,7 @@ class _AddToCartModalState extends State { style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500), ), Text( - "${formatPrix(widget.item['prix'])} €", + "${formatPrix(widget.item['prix'])} MGA", style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, @@ -440,7 +440,7 @@ class _AddToCartModalState extends State { ), ), Text( - "${calculateTotal().toStringAsFixed(2)} €", + "${calculateTotal().toStringAsFixed(2)} MGA", style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold,