
Updates the sign-in API endpoint to `/simpos/v1/sign_in`. Captures the `set-cookie` header from successful sign-in responses and stores it as a `sessionId`. Persists the session ID using secure storage and includes it in subsequent API requests via the `Cookie` header for improved session management. Extends the `AuthModel` to include the new `sessionId` field. Enables navigation from the reception list to a new reception details page, passing the selected reception's ID. Refactors the `StockPickingCard` into a dedicated component and adds loading indicators to the reception list.
117 lines
4.8 KiB
Dart
117 lines
4.8 KiB
Dart
import 'package:barcode_scanner/backend/schema/stock_picking/stock_picking_model.dart';
|
|
import 'package:barcode_scanner/components/components.dart';
|
|
import 'package:barcode_scanner/pages/operation/reception/reception_page_model.dart';
|
|
import 'package:barcode_scanner/router/go_secure_router_builder.dart';
|
|
import 'package:barcode_scanner/themes/app_theme.dart';
|
|
import 'package:flutter/scheduler.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ReceptionPage extends ConsumerStatefulWidget {
|
|
const ReceptionPage({super.key});
|
|
|
|
@override
|
|
ConsumerState<ReceptionPage> createState() => _ReceptionPageState();
|
|
}
|
|
|
|
class _ReceptionPageState extends ConsumerState<ReceptionPage> {
|
|
final globalKey = GlobalKey<ScaffoldState>();
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
SchedulerBinding.instance.addPostFrameCallback((_) {
|
|
ref.read(receptionPageModelProvider.notifier).getUserConnected();
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppTheme.of(context).primaryBackground,
|
|
key: globalKey,
|
|
drawer: DrawerComponent(isOperationExpanded: true),
|
|
appBar: MainAppbarComponent(
|
|
scaffoledKey: globalKey,
|
|
title: "Réceptions",
|
|
subTitle: "Opérations d'Entrepôt",
|
|
),
|
|
body: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: ListView(
|
|
children: [
|
|
const SizedBox(height: 16),
|
|
QuickActionComponent(),
|
|
const SizedBox(height: 16),
|
|
Consumer(
|
|
builder: (_, WidgetRef ref, _) {
|
|
final state = ref.watch(receptionPageModelProvider);
|
|
if (state.loadingReceptions) {
|
|
return Center(child: LoadingProgressComponent());
|
|
}
|
|
return Card(
|
|
color: AppTheme.of(context).secondaryBackground,
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
side: BorderSide(color: AppTheme.of(context).alternate),
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsets.all(16),
|
|
child: Column(
|
|
spacing: 10,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Réceptions',
|
|
style: AppTheme.of(
|
|
context,
|
|
).bodyMedium.copyWith(fontWeight: FontWeight.bold),
|
|
),
|
|
state.receptions?.result?.records?.isEmpty == true
|
|
? Text('No data')
|
|
: ListView.builder(
|
|
physics: NeverScrollableScrollPhysics(),
|
|
primary: true,
|
|
shrinkWrap: true,
|
|
itemCount:
|
|
(state.receptions?.result?.records ??
|
|
<StockPickingRecordModel>[])
|
|
.length,
|
|
itemBuilder: (context, index) {
|
|
final reception =
|
|
state.receptions?.result?.records![index];
|
|
return GestureDetector(
|
|
onTap: () {
|
|
final id = reception?.id;
|
|
if (id == null) return;
|
|
ReceptionDetailsRoute(
|
|
receptionId: id,
|
|
).push(context);
|
|
},
|
|
child: StockPickingCard(
|
|
reference: reception?.name ?? '',
|
|
from: reception?.locationId?.completeName,
|
|
to: reception
|
|
?.locationDestId
|
|
?.completeName,
|
|
contact:
|
|
reception?.partnerId?.displayName,
|
|
origin: reception?.origin,
|
|
status: reception?.state,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|