barcode_scanner/lib/components/quick_action_component.dart
your-name 61252a3aa9 feat: Implements reception validation process
Introduces the ability to validate a stock reception by sending updated move line quantities to the backend.

This includes:
- Adding a new API call to update stock picking move lines.
- Integrating a "Validate Reception" button within the quick actions component on the reception details page.
- Implementing the logic to gather move line data and call the new API endpoint.
- Enhancing error messages on the scan page for products not expected in the current reception.
- Improving type safety for API response data.
2025-07-31 01:07:48 +03:00

110 lines
3.6 KiB
Dart

import 'package:e_scan/components/components.dart';
import 'package:e_scan/themes/app_theme.dart';
import 'package:flutter/material.dart';
class QuickActionComponent extends StatelessWidget {
const QuickActionComponent({
super.key,
this.onTapAdd,
this.onTapScan,
this.onTapSearch,
this.onTapValidateReception,
});
final VoidCallback? onTapAdd;
final VoidCallback? onTapScan;
final VoidCallback? onTapSearch;
final VoidCallback? onTapValidateReception;
@override
Widget build(BuildContext context) {
return Card(
elevation: 0,
color: AppTheme.of(context).secondaryBackground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(color: AppTheme.of(context).alternate),
),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
'Actions Rapides',
style: AppTheme.of(
context,
).bodyMedium.copyWith(fontWeight: FontWeight.bold),
),
const Spacer(),
// Container(
// padding: const EdgeInsets.symmetric(
// horizontal: 10,
// vertical: 4,
// ),
// decoration: BoxDecoration(
// color: AppTheme.of(context).alternate,
// borderRadius: BorderRadius.circular(20),
// ),
// child: Text(
// '3 en attente',
// style: AppTheme.of(context).bodySmall,
// ),
// ),
],
),
if (onTapValidateReception != null) ...[
const SizedBox(height: 16),
SizedBox(
width: double.maxFinite,
child: PrimaryButtonComponent(
centered: true,
leading: Icon(Icons.save, color: AppTheme.of(context).white),
text: 'Valider la réception',
onPressed: onTapValidateReception,
),
),
],
if (onTapAdd != null) ...[
const SizedBox(height: 16),
SizedBox(
width: double.maxFinite,
child: PrimaryButtonComponent(
centered: true,
leading: Icon(Icons.add, color: AppTheme.of(context).white),
text: 'Nouvelle Réception',
onPressed: onTapAdd,
),
),
],
if (onTapScan != null) ...[
const SizedBox(height: 12),
SizedBox(
width: double.maxFinite,
child: OutlineButtonComponent(
centered: true,
leading: const Icon(Icons.qr_code_scanner),
text: 'Scanner Code-Barres',
onPressed: onTapScan,
),
),
const SizedBox(height: 12),
],
if (onTapSearch != null)
SizedBox(
width: double.maxFinite,
child: OutlineButtonComponent(
centered: true,
leading: const Icon(Icons.search),
text: 'Rechercher Existant',
onPressed: onTapSearch,
),
),
],
),
),
);
}
}