From ba1d7a626428e0880f3c790e305522cc650f2d1e Mon Sep 17 00:00:00 2001 From: mandreshope Date: Thu, 31 Jul 2025 14:25:03 +0300 Subject: [PATCH] refactor: Refines reception validation and quick actions Allows reception validation regardless of its synchronization status, enabling more flexible use cases. Simplifies the quick actions available on the reception list page by removing the 'Add' and 'Scan' buttons, retaining only the 'Search' option. Adds vertical spacing before the search button within the QuickActionComponent for improved visual layout. --- lib/components/quick_action_component.dart | 4 +- .../reception/reception_details_page.dart | 39 ++++++++----------- .../operation/reception/reception_page.dart | 6 +-- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/lib/components/quick_action_component.dart b/lib/components/quick_action_component.dart index 43ee5ae..44b32ec 100644 --- a/lib/components/quick_action_component.dart +++ b/lib/components/quick_action_component.dart @@ -114,7 +114,8 @@ class QuickActionComponent extends StatelessWidget { ), const SizedBox(height: 12), ], - if (onTapSearch != null) + if (onTapSearch != null) ...[ + const SizedBox(height: 12), SizedBox( width: double.maxFinite, child: OutlineButtonComponent( @@ -124,6 +125,7 @@ class QuickActionComponent extends StatelessWidget { onPressed: onTapSearch, ), ), + ], ], ), ), diff --git a/lib/pages/operation/reception/reception_details_page.dart b/lib/pages/operation/reception/reception_details_page.dart index e5efaec..20a83fb 100644 --- a/lib/pages/operation/reception/reception_details_page.dart +++ b/lib/pages/operation/reception/reception_details_page.dart @@ -55,28 +55,23 @@ class _ReceptionDetailsPageState extends ConsumerState { const SizedBox(height: 16), if (reception?.isDone == false) ...[ QuickActionComponent( - onTapValidateReception: reception?.synchronized == false - ? () { - ref - .read( - receptionDetailsPageModelProvider - .notifier, - ) - .validate( - receptionId: widget.receptionId, - onSuccess: () { - Toast.showSuccess( - 'Réception validée avec succès.', - ); - }, - onError: () { - Toast.showError( - 'Connexion impossible. Les données seront synchronisées plus tard.', - ); - }, - ); - } - : null, + onTapValidateReception: () { + ref + .read(receptionDetailsPageModelProvider.notifier) + .validate( + receptionId: widget.receptionId, + onSuccess: () { + Toast.showSuccess( + 'Réception validée avec succès.', + ); + }, + onError: () { + Toast.showError( + 'Connexion impossible. Les données seront synchronisées plus tard.', + ); + }, + ); + }, validateReceptionLoading: state.validateLoading, syncReceptionLoading: state.saveLoading, onTapSyncReception: reception?.synchronized == false diff --git a/lib/pages/operation/reception/reception_page.dart b/lib/pages/operation/reception/reception_page.dart index bf49635..0849eac 100644 --- a/lib/pages/operation/reception/reception_page.dart +++ b/lib/pages/operation/reception/reception_page.dart @@ -48,11 +48,7 @@ class _ReceptionPageState extends ConsumerState { child: ListView( children: [ const SizedBox(height: 16), - QuickActionComponent( - onTapAdd: () {}, - onTapScan: () {}, - onTapSearch: () {}, - ), + QuickActionComponent(onTapSearch: () {}), const SizedBox(height: 16), Consumer( builder: (_, WidgetRef ref, _) {