Change DA to MGA
This commit is contained in:
parent
0b2512d24e
commit
da03076411
@ -45,7 +45,7 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: const CustomAppBar(title: 'Nouvelle Commande'),
|
appBar: const CustomAppBar(title: 'Nouvelle Commande'),
|
||||||
drawer: CustomDrawer(),
|
drawer: CustomDrawer(),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
// Header avec logo et titre
|
// Header avec logo et titre
|
||||||
@ -126,7 +126,7 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Contenu principal
|
// Contenu principal
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
@ -221,7 +221,8 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
if (value == null || value.isEmpty) {
|
if (value == null || value.isEmpty) {
|
||||||
return 'Veuillez entrer un email';
|
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 'Veuillez entrer un email valide';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -297,7 +298,7 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final product = _products[index];
|
final product = _products[index];
|
||||||
final quantity = _quantites[product.id] ?? 0;
|
final quantity = _quantites[product.id] ?? 0;
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 8),
|
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
@ -316,7 +317,7 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
color: Colors.blue.shade50,
|
color: Colors.blue.shade50,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.shopping_bag,
|
child: const Icon(Icons.shopping_bag,
|
||||||
color: Colors.blue),
|
color: Colors.blue),
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
@ -328,7 +329,7 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
'${product.price.toStringAsFixed(2)} DA',
|
'${product.price.toStringAsFixed(2)} MGA',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.green.shade700,
|
color: Colors.green.shade700,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
@ -364,12 +365,14 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
quantity.toString(),
|
quantity.toString(),
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.add, size: 18),
|
icon: const Icon(Icons.add, size: 18),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (product.stock == null || quantity < product.stock!) {
|
if (product.stock == null ||
|
||||||
|
quantity < product.stock!) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_quantites[product.id!] = quantity + 1;
|
_quantites[product.id!] = quantity + 1;
|
||||||
});
|
});
|
||||||
@ -397,7 +400,7 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
|
|
||||||
Widget _buildCartSection() {
|
Widget _buildCartSection() {
|
||||||
final itemsInCart = _quantites.entries.where((e) => e.value > 0).toList();
|
final itemsInCart = _quantites.entries.where((e) => e.value > 0).toList();
|
||||||
|
|
||||||
if (itemsInCart.isEmpty) {
|
if (itemsInCart.isEmpty) {
|
||||||
return Card(
|
return Card(
|
||||||
elevation: 4,
|
elevation: 4,
|
||||||
@ -454,9 +457,10 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
child: const Icon(Icons.shopping_bag, size: 20),
|
child: const Icon(Icons.shopping_bag, size: 20),
|
||||||
),
|
),
|
||||||
title: Text(product.name),
|
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(
|
trailing: Text(
|
||||||
'${(entry.value * product.price).toStringAsFixed(2)} DA',
|
'${(entry.value * product.price).toStringAsFixed(2)} MGA',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.blue.shade800,
|
color: Colors.blue.shade800,
|
||||||
@ -499,7 +503,7 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${total.toStringAsFixed(2)} DA',
|
'${total.toStringAsFixed(2)} MGA',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@ -559,11 +563,11 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
// Calculer le total et préparer les détails
|
// Calculer le total et préparer les détails
|
||||||
double total = 0;
|
double total = 0;
|
||||||
final details = <DetailCommande>[];
|
final details = <DetailCommande>[];
|
||||||
|
|
||||||
for (final entry in itemsInCart) {
|
for (final entry in itemsInCart) {
|
||||||
final product = _products.firstWhere((p) => p.id == entry.key);
|
final product = _products.firstWhere((p) => p.id == entry.key);
|
||||||
total += entry.value * product.price;
|
total += entry.value * product.price;
|
||||||
|
|
||||||
details.add(DetailCommande(
|
details.add(DetailCommande(
|
||||||
commandeId: 0, // Valeur temporaire, sera remplacée dans la transaction
|
commandeId: 0, // Valeur temporaire, sera remplacée dans la transaction
|
||||||
produitId: product.id!,
|
produitId: product.id!,
|
||||||
@ -585,7 +589,7 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
try {
|
try {
|
||||||
// Enregistrer la commande dans la base de données
|
// Enregistrer la commande dans la base de données
|
||||||
await _database.createCommandeComplete(client, commande, details);
|
await _database.createCommandeComplete(client, commande, details);
|
||||||
|
|
||||||
Get.snackbar(
|
Get.snackbar(
|
||||||
'Succès',
|
'Succès',
|
||||||
'Votre commande a été enregistrée',
|
'Votre commande a été enregistrée',
|
||||||
@ -593,13 +597,12 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
backgroundColor: Colors.green,
|
backgroundColor: Colors.green,
|
||||||
colorText: Colors.white,
|
colorText: Colors.white,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Réinitialiser le formulaire
|
// Réinitialiser le formulaire
|
||||||
_formKey.currentState!.reset();
|
_formKey.currentState!.reset();
|
||||||
setState(() {
|
setState(() {
|
||||||
_quantites.clear();
|
_quantites.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Get.snackbar(
|
Get.snackbar(
|
||||||
'Erreur',
|
'Erreur',
|
||||||
@ -620,4 +623,4 @@ class _NouvelleCommandePageState extends State<NouvelleCommandePage> {
|
|||||||
_adresseController.dispose();
|
_adresseController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user