reectification
This commit is contained in:
parent
bb81798e03
commit
7d2c6f5965
@ -111,8 +111,8 @@ class _CaisseScreenState extends State<CaisseScreen> {
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔄 Redirige vers la facture
|
||||
Navigator.of(context).pushReplacement(
|
||||
// 🔄 Redirige vers la facture et attend le retour
|
||||
final result = await Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FactureScreen(
|
||||
commande: commande!,
|
||||
@ -121,6 +121,11 @@ class _CaisseScreenState extends State<CaisseScreen> {
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Quand on revient de la facture, on retourne à la page précédente avec succès
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
} else {
|
||||
_showErrorDialog('Le paiement a échoué. Veuillez réessayer.');
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../layouts/main_layout.dart';
|
||||
import '../services/pdf_impression_commande.dart';
|
||||
import 'commandes_screen.dart';
|
||||
|
||||
@ -423,12 +424,16 @@ class _ValidateAddItemsPageState extends State<ValidateAddItemsPage> {
|
||||
// Méthode pour naviguer avec succès
|
||||
void _navigateBackWithSuccess() {
|
||||
// Fermer toutes les pages précédentes et rediriger vers OrdersManagementScreen
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => OrdersManagementScreen(),
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => MainLayout(
|
||||
currentRoute: '/commandes', // ou '/tables' selon ton besoin
|
||||
child: OrdersManagementScreen(),
|
||||
),
|
||||
(Route<dynamic> route) => false, // Supprime toutes les pages précédentes
|
||||
);
|
||||
),
|
||||
(Route<dynamic> route) => false,
|
||||
);
|
||||
|
||||
|
||||
// Optionnel : petit délai pour laisser le temps à la navigation
|
||||
Future.delayed(Duration(milliseconds: 300), () {
|
||||
|
||||
@ -58,7 +58,11 @@ class _FactureScreenState extends State<FactureScreen> {
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () {
|
||||
// Retourner 2 fois en arrière (facture -> caisse -> liste commandes)
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(true); // true pour indiquer le succès
|
||||
},
|
||||
),
|
||||
title: const Text(
|
||||
'Retour',
|
||||
|
||||
@ -4,12 +4,14 @@ import 'package:itrimobe/models/tables_order.dart';
|
||||
|
||||
class CommandeCard extends StatelessWidget {
|
||||
final TableOrder commande;
|
||||
final VoidCallback onAllerCaisse;
|
||||
final Future<void> Function() onAllerCaisse; // Changé en Future<void> Function()
|
||||
final VoidCallback? onRefresh;
|
||||
|
||||
const CommandeCard({
|
||||
super.key,
|
||||
required this.commande,
|
||||
required this.onAllerCaisse,
|
||||
this.onRefresh,
|
||||
});
|
||||
|
||||
String _formatTime(DateTime dateTime) {
|
||||
@ -18,7 +20,6 @@ class CommandeCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
@ -38,7 +39,6 @@ class CommandeCard extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Header avec numéro de table et badge
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -62,7 +62,7 @@ class CommandeCard extends StatelessWidget {
|
||||
Icon(Icons.check_circle, color: Colors.white, size: 16),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
'Près à encaisser',
|
||||
'Prêt à encaisser',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
@ -77,13 +77,11 @@ class CommandeCard extends StatelessWidget {
|
||||
|
||||
SizedBox(height: 12),
|
||||
|
||||
// Informations détaillées
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.access_time, size: 16, color: Colors.grey[600]),
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
// Fixed: Pass DateTime directly, not as string
|
||||
commande.date != null ? _formatTime(commande.date!) : 'Date non disponible',
|
||||
style: TextStyle(color: Colors.grey[600], fontSize: 14),
|
||||
),
|
||||
@ -92,10 +90,8 @@ class CommandeCard extends StatelessWidget {
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
// Total et bouton
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// alignItems: MainAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -115,7 +111,15 @@ class CommandeCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
onPressed: onAllerCaisse,
|
||||
onPressed: () async {
|
||||
// Attendre que la navigation soit terminée
|
||||
await onAllerCaisse();
|
||||
|
||||
// Rafraîchir la page
|
||||
if (onRefresh != null) {
|
||||
onRefresh!();
|
||||
}
|
||||
},
|
||||
icon: Icon(Icons.point_of_sale, size: 18),
|
||||
label: Text('Aller à la caisse'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user