Browse Source

ajout panier

master
Stephane 4 months ago
parent
commit
a23321274a
  1. 530
      lib/pages/commande_item_validation.dart
  2. 121
      lib/pages/commandes_screen.dart

530
lib/pages/commande_item_validation.dart

@ -6,7 +6,8 @@ class ValidateAddItemsPage extends StatefulWidget {
final int commandeId; final int commandeId;
final String numeroCommande; final String numeroCommande;
final List<dynamic> newItems; // Nouveaux articles à ajouter final List<dynamic> newItems; // Nouveaux articles à ajouter
final Map<String, dynamic>? commandeDetails; // Détails de la commande existante final Map<String, dynamic>?
commandeDetails; // Détails de la commande existante
const ValidateAddItemsPage({ const ValidateAddItemsPage({
Key? key, Key? key,
@ -88,14 +89,17 @@ class _ValidateAddItemsPageState extends State<ValidateAddItemsPage> {
// Calculer le total des articles existants // Calculer le total des articles existants
double _calculateExistingItemsTotal() { double _calculateExistingItemsTotal() {
if (widget.commandeDetails == null || widget.commandeDetails!['items'] == null) { if (widget.commandeDetails == null ||
widget.commandeDetails!['items'] == null) {
return 0.0; return 0.0;
} }
double total = 0.0; double total = 0.0;
for (var item in widget.commandeDetails!['items']) { for (var item in widget.commandeDetails!['items']) {
// Correction: utiliser 'menu_prix_actuel' au lieu de 'menu_prix' // Correction: utiliser 'menu_prix_actuel' au lieu de 'menu_prix'
double prix = _parsePrice(item['menu_prix_actuel'] ?? item['prix_unitaire']); double prix = _parsePrice(
item['menu_prix_actuel'] ?? item['prix_unitaire'],
);
int quantite = item['quantite'] ?? 1; int quantite = item['quantite'] ?? 1;
total += prix * quantite; total += prix * quantite;
} }
@ -112,10 +116,14 @@ class _ValidateAddItemsPageState extends State<ValidateAddItemsPage> {
} }
int _getTotalExistingArticles() { int _getTotalExistingArticles() {
if (widget.commandeDetails == null || widget.commandeDetails!['items'] == null) { if (widget.commandeDetails == null ||
widget.commandeDetails!['items'] == null) {
return 0; return 0;
} }
return widget.commandeDetails!['items'].fold(0, (sum, item) => sum + (item['quantite'] ?? 1)); return widget.commandeDetails!['items'].fold(
0,
(sum, item) => sum + (item['quantite'] ?? 1),
);
} }
void _showConfirmationDialog() { void _showConfirmationDialog() {
@ -132,7 +140,9 @@ class _ValidateAddItemsPageState extends State<ValidateAddItemsPage> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text('Êtes-vous sûr de vouloir ajouter ces articles à la commande ?'), Text(
'Êtes-vous sûr de vouloir ajouter ces articles à la commande ?',
),
SizedBox(height: 16), SizedBox(height: 16),
Text( Text(
'Récapitulatif:', 'Récapitulatif:',
@ -140,7 +150,9 @@ class _ValidateAddItemsPageState extends State<ValidateAddItemsPage> {
), ),
Text('• Commande: ${widget.numeroCommande}'), Text('• Commande: ${widget.numeroCommande}'),
Text('• Nouveaux articles: ${_getTotalNewArticles()}'), Text('• Nouveaux articles: ${_getTotalNewArticles()}'),
Text('• Nouveau total: ${_calculateGrandTotal().toStringAsFixed(2)} MGA'), Text(
'• Nouveau total: ${_calculateGrandTotal().toStringAsFixed(2)} MGA',
),
], ],
), ),
actions: [ actions: [
@ -149,26 +161,30 @@ class _ValidateAddItemsPageState extends State<ValidateAddItemsPage> {
child: Text('Annuler', style: TextStyle(color: Colors.grey[600])), child: Text('Annuler', style: TextStyle(color: Colors.grey[600])),
), ),
ElevatedButton( ElevatedButton(
onPressed: _isValidating onPressed:
? null _isValidating
: () { ? null
Navigator.of(context).pop(); : () {
_validateAddItems(); Navigator.of(context).pop();
}, _validateAddItems();
},
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.green[700], backgroundColor: Colors.green[700],
foregroundColor: Colors.white, foregroundColor: Colors.white,
), ),
child: _isValidating child:
? SizedBox( _isValidating
width: 16, ? SizedBox(
height: 16, width: 16,
child: CircularProgressIndicator( height: 16,
strokeWidth: 2, child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.white), strokeWidth: 2,
), valueColor: AlwaysStoppedAnimation<Color>(
) Colors.white,
: Text('Confirmer'), ),
),
)
: Text('Confirmer'),
), ),
], ],
); );
@ -193,36 +209,36 @@ class _ValidateAddItemsPageState extends State<ValidateAddItemsPage> {
try { try {
// Préparer les données des nouveaux articles // Préparer les données des nouveaux articles
// 1. Construire la liste des items sans commande_id à lintérieur // 1. Construire la liste des items sans commande_id à lintérieur
List<Map<String, dynamic>> items = _newCartItems.map((cartItem) { List<Map<String, dynamic>> items =
return { _newCartItems.map((cartItem) {
'menu_id': cartItem.id, return {
'quantite': cartItem.quantity, 'menu_id': cartItem.id,
'commentaires': cartItem.notes.isNotEmpty ? cartItem.notes : null, 'quantite': cartItem.quantity,
}; 'commentaires': cartItem.notes.isNotEmpty ? cartItem.notes : null,
}).toList(); };
}).toList();
// 2. Construire le body correctement avec commande_id à la racine
final body = { // 2. Construire le body correctement avec commande_id à la racine
'commande_id': widget.commandeId, final body = {'commande_id': widget.commandeId, 'items': items};
'items': items,
}; print("📦 Données envoyées : ${json.encode(body)}");
print("📦 Données envoyées : ${json.encode(body)}"); // 3. Envoi vers l'API
final response = await http.post(
// 3. Envoi vers l'API Uri.parse(
final response = await http.post( 'https://restaurant.careeracademy.mg/api/commande-items/add-multiple',
Uri.parse('https://restaurant.careeracademy.mg/api/commande-items/add-multiple'), ),
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json', 'Accept': 'application/json',
}, },
body: json.encode(body), body: json.encode(body),
); );
// 4. Afficher la réponse backend // 4. Afficher la réponse backend
final responseData = jsonDecode(response.body); final responseData = jsonDecode(response.body);
print('✅ Réponse backend : $responseData'); print('✅ Réponse backend : $responseData');
if (response.statusCode == 200 || response.statusCode == 201) { if (response.statusCode == 200 || response.statusCode == 201) {
final responseData = json.decode(response.body); final responseData = json.decode(response.body);
@ -351,58 +367,57 @@ print('✅ Réponse backend : $responseData');
SizedBox(height: 16), SizedBox(height: 16),
// Résumé des articles existants // Résumé des articles existants
if (widget.commandeDetails != null && widget.commandeDetails!['items'] != null) ...[ // if (widget.commandeDetails != null && widget.commandeDetails!['items'] != null) ...[
Text( // Text(
'Articles déjà commandés:', // 'Articles déjà commandés:',
style: TextStyle( // style: TextStyle(
fontSize: 16, // fontSize: 16,
fontWeight: FontWeight.w600, // fontWeight: FontWeight.w600,
color: Colors.grey[700], // color: Colors.grey[700],
), // ),
), // ),
SizedBox(height: 8), // SizedBox(height: 8),
...widget.commandeDetails!['items'].map<Widget>((item) { // ...widget.commandeDetails!['items'].map<Widget>((item) {
final nom = item['menu_nom'] ?? 'Inconnu'; // final nom = item['menu_nom'] ?? 'Inconnu';
final quantite = item['quantite'] ?? 1; // final quantite = item['quantite'] ?? 1;
// Correction: utiliser 'menu_prix_actuel' au lieu de 'menu_prix' // // Correction: utiliser 'menu_prix_actuel' au lieu de 'menu_prix'
final prix = _parsePrice(item['menu_prix_actuel'] ?? item['prix_unitaire']); // final prix = _parsePrice(item['menu_prix_actuel'] ?? item['prix_unitaire']);
return Padding( // return Padding(
padding: const EdgeInsets.symmetric(vertical: 2), // padding: const EdgeInsets.symmetric(vertical: 2),
child: Row( // child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ // children: [
Expanded( // Expanded(
child: Text( // child: Text(
'$nom x$quantite', // '$nom x$quantite',
style: TextStyle(fontSize: 14, color: Colors.grey[600]), // style: TextStyle(fontSize: 14, color: Colors.grey[600]),
), // ),
), // ),
Text( // Text(
'${(prix * quantite).toStringAsFixed(2)} MGA', // '${(prix * quantite).toStringAsFixed(2)} MGA',
style: TextStyle(fontSize: 14, color: Colors.grey[600]), // style: TextStyle(fontSize: 14, color: Colors.grey[600]),
), // ),
], // ],
), // ),
); // );
}).toList(), // }).toList(),
SizedBox(height: 8), // SizedBox(height: 8),
Row( // Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ // children: [
Text( // Text(
'Sous-total existant:', // 'Sous-total existant:',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500), // style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
), // ),
Text( // Text(
'${_calculateExistingItemsTotal().toStringAsFixed(2)} MGA', // '${_calculateExistingItemsTotal().toStringAsFixed(2)} MGA',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500), // style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
), // ),
], // ],
), // ),
Divider(height: 20), // Divider(height: 20),
], // ],
Text( Text(
'Nouveaux articles à ajouter: ${_getTotalNewArticles()}', 'Nouveaux articles à ajouter: ${_getTotalNewArticles()}',
style: TextStyle( style: TextStyle(
@ -417,152 +432,168 @@ print('✅ Réponse backend : $responseData');
// Liste des nouveaux articles // Liste des nouveaux articles
Expanded( Expanded(
child: _newCartItems.isEmpty child:
? Center( _newCartItems.isEmpty
child: Column( ? Center(
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: [ mainAxisAlignment: MainAxisAlignment.center,
Icon( children: [
Icons.shopping_cart_outlined, Icon(
size: 80, Icons.shopping_cart_outlined,
color: Colors.grey[400], size: 80,
), color: Colors.grey[400],
SizedBox(height: 16), ),
Text( SizedBox(height: 16),
'Aucun nouvel article sélectionné', Text(
style: TextStyle(fontSize: 18, color: Colors.grey[600]), 'Aucun nouvel article sélectionné',
), style: TextStyle(
], fontSize: 18,
), color: Colors.grey[600],
)
: ListView.separated(
padding: EdgeInsets.all(16),
itemCount: _newCartItems.length,
separatorBuilder: (context, index) => SizedBox(height: 12),
itemBuilder: (context, index) {
final item = _newCartItems[index];
return Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.green[200]!, width: 1),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.05),
blurRadius: 5,
offset: Offset(0, 2),
), ),
], ),
), ],
child: Column( ),
crossAxisAlignment: CrossAxisAlignment.start, )
children: [ : ListView.separated(
Row( padding: EdgeInsets.all(16),
mainAxisAlignment: MainAxisAlignment.spaceBetween, itemCount: _newCartItems.length,
children: [ separatorBuilder:
Expanded( (context, index) => SizedBox(height: 12),
child: Row( itemBuilder: (context, index) {
children: [ final item = _newCartItems[index];
Icon(Icons.add_circle, color: Colors.green[600], size: 20), return Container(
SizedBox(width: 8), padding: EdgeInsets.all(16),
Expanded( decoration: BoxDecoration(
child: Text( color: Colors.white,
item.nom, borderRadius: BorderRadius.circular(12),
style: TextStyle( border: Border.all(
fontSize: 18, color: Colors.green[200]!,
fontWeight: FontWeight.bold, width: 1,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.05),
blurRadius: 5,
offset: Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
Icon(
Icons.add_circle,
color: Colors.green[600],
size: 20,
),
SizedBox(width: 8),
Expanded(
child: Text(
item.nom,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
), ),
), ),
), ],
], ),
), ),
), IconButton(
IconButton( onPressed: () => _removeItem(index),
onPressed: () => _removeItem(index), icon: Icon(
icon: Icon( Icons.delete_outline,
Icons.delete_outline, color: Colors.red,
color: Colors.red, ),
constraints: BoxConstraints(),
padding: EdgeInsets.zero,
), ),
constraints: BoxConstraints(), ],
padding: EdgeInsets.zero,
),
],
),
Text(
'${item.prix.toStringAsFixed(2)} MGA l\'unité',
style: TextStyle(
fontSize: 14,
color: Colors.grey[600],
), ),
),
if (item.notes.isNotEmpty) ...[
SizedBox(height: 8),
Text( Text(
'Notes: ${item.notes}', '${item.prix.toStringAsFixed(2)} MGA l\'unité',
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: Colors.grey[600], color: Colors.grey[600],
fontStyle: FontStyle.italic,
), ),
), ),
], if (item.notes.isNotEmpty) ...[
SizedBox(height: 16), SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Contrôles de quantité
Row(
children: [
IconButton(
onPressed: () => _updateQuantity(
index,
item.quantity - 1,
),
icon: Icon(Icons.remove),
style: IconButton.styleFrom(
backgroundColor: Colors.grey[200],
minimumSize: Size(40, 40),
),
),
SizedBox(width: 16),
Text(
item.quantity.toString(),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
SizedBox(width: 16),
IconButton(
onPressed: () => _updateQuantity(
index,
item.quantity + 1,
),
icon: Icon(Icons.add),
style: IconButton.styleFrom(
backgroundColor: Colors.grey[200],
minimumSize: Size(40, 40),
),
),
],
),
// Prix total de l'article
Text( Text(
'${(item.prix * item.quantity).toStringAsFixed(2)} MGA', 'Notes: ${item.notes}',
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 14,
fontWeight: FontWeight.bold, color: Colors.grey[600],
color: Colors.green[700], fontStyle: FontStyle.italic,
), ),
), ),
], ],
), SizedBox(height: 16),
], Row(
), mainAxisAlignment:
); MainAxisAlignment.spaceBetween,
}, children: [
), // Contrôles de quantité
Row(
children: [
IconButton(
onPressed:
() => _updateQuantity(
index,
item.quantity - 1,
),
icon: Icon(Icons.remove),
style: IconButton.styleFrom(
backgroundColor: Colors.grey[200],
minimumSize: Size(40, 40),
),
),
SizedBox(width: 16),
Text(
item.quantity.toString(),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
SizedBox(width: 16),
IconButton(
onPressed:
() => _updateQuantity(
index,
item.quantity + 1,
),
icon: Icon(Icons.add),
style: IconButton.styleFrom(
backgroundColor: Colors.grey[200],
minimumSize: Size(40, 40),
),
),
],
),
// Prix total de l'article
Text(
'${(item.prix * item.quantity).toStringAsFixed(2)} MGA',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.green[700],
),
),
],
),
],
),
);
},
),
), ),
// Récapitulatif final // Récapitulatif final
@ -577,10 +608,7 @@ print('✅ Réponse backend : $responseData');
children: [ children: [
Text( Text(
'Récapitulatif final', 'Récapitulatif final',
style: TextStyle( style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
fontSize: 20,
fontWeight: FontWeight.bold,
),
), ),
SizedBox(height: 16), SizedBox(height: 16),
Row( Row(
@ -596,7 +624,10 @@ print('✅ Réponse backend : $responseData');
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Sous-total existant:', style: TextStyle(fontSize: 16)), Text(
'Sous-total existant:',
style: TextStyle(fontSize: 16),
),
Text( Text(
'${_calculateExistingItemsTotal().toStringAsFixed(2)} MGA', '${_calculateExistingItemsTotal().toStringAsFixed(2)} MGA',
style: TextStyle(fontSize: 16), style: TextStyle(fontSize: 16),
@ -607,7 +638,10 @@ print('✅ Réponse backend : $responseData');
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Nouveaux articles:', style: TextStyle(fontSize: 16, color: Colors.green[700])), Text(
'Nouveaux articles:',
style: TextStyle(fontSize: 16, color: Colors.green[700]),
),
Text( Text(
_getTotalNewArticles().toString(), _getTotalNewArticles().toString(),
style: TextStyle(fontSize: 16, color: Colors.green[700]), style: TextStyle(fontSize: 16, color: Colors.green[700]),
@ -617,7 +651,10 @@ print('✅ Réponse backend : $responseData');
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('Sous-total nouveaux:', style: TextStyle(fontSize: 16, color: Colors.green[700])), Text(
'Sous-total nouveaux:',
style: TextStyle(fontSize: 16, color: Colors.green[700]),
),
Text( Text(
'${_calculateNewItemsTotal().toStringAsFixed(2)} MGA', '${_calculateNewItemsTotal().toStringAsFixed(2)} MGA',
style: TextStyle(fontSize: 16, color: Colors.green[700]), style: TextStyle(fontSize: 16, color: Colors.green[700]),
@ -651,9 +688,10 @@ print('✅ Réponse backend : $responseData');
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: ElevatedButton( child: ElevatedButton(
onPressed: _newCartItems.isNotEmpty && !_isValidating onPressed:
? _showConfirmationDialog _newCartItems.isNotEmpty && !_isValidating
: null, ? _showConfirmationDialog
: null,
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.green[700], backgroundColor: Colors.green[700],
foregroundColor: Colors.white, foregroundColor: Colors.white,
@ -672,7 +710,9 @@ print('✅ Réponse backend : $responseData');
height: 20, height: 20,
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 2, strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white), valueColor: AlwaysStoppedAnimation<Color>(
Colors.white,
),
), ),
), ),
SizedBox(width: 8), SizedBox(width: 8),

121
lib/pages/commandes_screen.dart

@ -140,8 +140,6 @@ class _OrdersManagementScreenState extends State<OrdersManagementScreen> {
return null; return null;
} }
Future<void> updateOrderStatus( Future<void> updateOrderStatus(
Order order, Order order,
String newStatus, { String newStatus, {
@ -289,9 +287,6 @@ class _OrdersManagementScreenState extends State<OrdersManagementScreen> {
} }
} }
List<Order> get activeOrders { List<Order> get activeOrders {
return orders return orders
.where( .where(
@ -347,7 +342,6 @@ class _OrdersManagementScreenState extends State<OrdersManagementScreen> {
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
), ),
], ],
); );
}, },
@ -356,22 +350,23 @@ class _OrdersManagementScreenState extends State<OrdersManagementScreen> {
); );
} }
Future<void> updateTableStatus(int tableId, String newStatus) async { Future<void> updateTableStatus(int tableId, String newStatus) async {
const String apiUrl = 'https://restaurant.careeracademy.mg/api/tables'; // adapte lURL si besoin const String apiUrl =
'https://restaurant.careeracademy.mg/api/tables'; // adapte lURL si besoin
final response = await http.put( final response = await http.put(
Uri.parse('$apiUrl/$tableId'), Uri.parse('$apiUrl/$tableId'),
headers: {'Content-Type': 'application/json'}, headers: {'Content-Type': 'application/json'},
body: jsonEncode({'status': newStatus}), body: jsonEncode({'status': newStatus}),
); );
if (response.statusCode != 200) { if (response.statusCode != 200) {
print('Erreur lors de la mise à jour du statut de la table'); print('Erreur lors de la mise à jour du statut de la table');
throw Exception('Erreur: ${response.body}'); throw Exception('Erreur: ${response.body}');
} else { } else {
print('✅ Table $tableId mise à jour en $newStatus'); print('✅ Table $tableId mise à jour en $newStatus');
}
} }
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -602,44 +597,37 @@ class OrderCard extends StatelessWidget {
// Header row // Header row
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Container( GestureDetector(
padding: const EdgeInsets.symmetric( onTap: onViewDetails,
horizontal: 12, child: Text(
vertical: 4, 'Table ${order.tableId}',
), style: const TextStyle(
decoration: BoxDecoration( fontSize: 18,
color: _getStatusColor(order.statut), fontWeight: FontWeight.bold,
borderRadius: BorderRadius.circular(12), color: Colors.black87,
),
child: Text(
_getStatusText(order.statut),
style: const TextStyle(
color: Colors.white,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
), ),
const SizedBox(width: 4), ),
if (order.statut == 'en_attente') ),
IconButton( Container(
icon: const Icon(Icons.add_circle_outline, size: 20, color: Colors.blue), padding: const EdgeInsets.symmetric(
tooltip: 'Ajouter un article', horizontal: 12,
onPressed: () { vertical: 4,
Navigator.push( ),
context, decoration: BoxDecoration(
MaterialPageRoute( color: _getStatusColor(order.statut),
builder: (context) => AddItemsToOrderPage( borderRadius: BorderRadius.circular(12),
commandeId: order.id, ),
numeroCommande: order.numero ?? 'Commande #${order.id}', child: Text(
), _getStatusText(order.statut),
), style: const TextStyle(
); color: Colors.white,
}, fontSize: 12,
), fontWeight: FontWeight.w500,
),
], ),
),
],
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
@ -731,7 +719,8 @@ class OrderCard extends StatelessWidget {
order.statut == 'en_preparation') order.statut == 'en_preparation')
Row( Row(
children: [ children: [
if (order.statut == 'en_attente') if (order.statut == 'en_attente' ||
order.statut == 'en_preparation')
Expanded( Expanded(
child: ElevatedButton( child: ElevatedButton(
onPressed: onPressed:
@ -741,22 +730,28 @@ class OrderCard extends StatelessWidget {
MaterialPageRoute( MaterialPageRoute(
builder: builder:
(context) => AddItemsToOrderPage( (context) => AddItemsToOrderPage(
commandId: order.id, commandeId: order.id,
numeroCommande: order.numeroCommande, numeroCommande: order.numeroCommande,
), ),
), ),
), ),
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.orange, backgroundColor: const Color.fromARGB(
255,
0,
76,
255,
),
padding: const EdgeInsets.symmetric(vertical: 12), padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
), ),
), ),
child: const Text( child: const Icon(
'Préparer', Icons.add,
style: TextStyle(color: Colors.white, fontSize: 12), color: Colors.white,
size: 16,
), ),
), ),
), ),
@ -860,8 +855,6 @@ class OrderCard extends StatelessWidget {
} }
} }
// Updated Order model to include items // Updated Order model to include items
class Order { class Order {
final int id; final int id;

Loading…
Cancel
Save