
Updates the `createBackorderConfirmation` API call to dynamically specify whether to create a backorder (reliquat) or not. Introduces a `toBackorder` parameter, enabling the API to handle both "with backorder" and "without backorder" scenarios based on user selection. This centralizes the backorder status setting within a single API call. Additionally, adds loading indicators to the backorder dialog buttons for improved user feedback during the confirmation process.
119 lines
4.2 KiB
Dart
119 lines
4.2 KiB
Dart
import 'package:e_scan/pages/operation/reception/reception_details_page_model.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:e_scan/components/components.dart';
|
|
import 'package:e_scan/themes/app_theme.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class DeleteCategorieDialogComponentWidget extends ConsumerWidget {
|
|
const DeleteCategorieDialogComponentWidget({
|
|
super.key,
|
|
required this.stockPickingId,
|
|
});
|
|
final int stockPickingId;
|
|
|
|
static void show(BuildContext context, {required int stockPickingId}) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (dialogContext) {
|
|
return Dialog(
|
|
elevation: 0,
|
|
insetPadding: EdgeInsets.zero,
|
|
backgroundColor: Colors.transparent,
|
|
alignment: AlignmentDirectional(
|
|
0.0,
|
|
0.0,
|
|
).resolve(Directionality.of(context)),
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
FocusScope.of(dialogContext).unfocus();
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
},
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width * .8,
|
|
child: DeleteCategorieDialogComponentWidget(
|
|
stockPickingId: stockPickingId,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final state = ref.watch(receptionDetailsPageModelProvider);
|
|
return Container(
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.of(context).primaryBackground,
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsets.all(20.0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
'Vous avez traité moins de produits que la demande initiale.',
|
|
style: AppTheme.of(context).titleSmall,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 0.0),
|
|
child: Text(
|
|
'Créer un reliquat si vous vous attendez à traiter la quantité de produits restante. Ne créez pas de reliquat si vous ne voulez pas traiter la quantité de produits restante.',
|
|
textAlign: TextAlign.center,
|
|
style: AppTheme.of(context).bodyMedium,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(0.0, 40.0, 0.0, 0.0),
|
|
child: Row(
|
|
spacing: 5,
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Expanded(
|
|
child: PrimaryButtonComponent(
|
|
loading: state.withBackorderLoading,
|
|
text: 'Créer un reliquat',
|
|
onPressed: () async {
|
|
await ref
|
|
.read(receptionDetailsPageModelProvider.notifier)
|
|
.withBackorder(
|
|
receptionId: stockPickingId,
|
|
onSuccess: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
Expanded(
|
|
child: PrimaryButtonComponent(
|
|
loading: state.withoutBackorderLoading,
|
|
backgroundColor: Colors.red,
|
|
text: 'Aucun reliquat',
|
|
onPressed: () async {
|
|
await ref
|
|
.read(receptionDetailsPageModelProvider.notifier)
|
|
.withoutBackorder(
|
|
receptionId: stockPickingId,
|
|
onSuccess: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
);
|
|
// Navigator.pop(context);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|