Fixes reported from APK field testing: DO/Product scan mode was inconsistent between the camera drawer and documents screen (now one shared provider, with an orange/green color cue); unconfirmed scans leaked into history with placeholder data before the user tapped confirm (backend now gates GET /documents on a new `confirmed` column, flipped only by PUT); and Product Scan ran the GPU classifier twice, once at upload and again on review (now a single pass at upload, persisted and read directly by the editor). Also removes the unused "Hubungkan ke PO" field and fabricated PO/SO/DO placeholder values from the Product Scan flow, closes out the per-document-polling and save-recovery tasks (6.1/6.3), and splits several touched files to stay under the repo's 256-line guideline. Full detail in docs/iteration-log.md and backend/docs/iteration-log.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
151 lines
4.8 KiB
Dart
151 lines
4.8 KiB
Dart
library editor_screen;
|
|
|
|
import 'package:dio/dio.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../../config/app_config.dart';
|
|
import '../../models/document_model.dart';
|
|
import '../../main.dart'; // To access localStorageProvider
|
|
import '../documents/pending_documents_provider.dart';
|
|
import '../../core/network/api_client.dart';
|
|
import '../../core/network/api_exception.dart';
|
|
import 'document_save_action.dart';
|
|
import 'widgets/header_details_card.dart';
|
|
import 'widgets/shipment_details_card.dart';
|
|
import 'widgets/location_details_card.dart';
|
|
import 'widgets/items_list_card.dart';
|
|
import 'widgets/confirmation_dialog.dart';
|
|
|
|
part 'editor_logic.dart';
|
|
|
|
class EditorScreen extends ConsumerStatefulWidget {
|
|
final String? pendingId;
|
|
|
|
const EditorScreen({super.key, this.pendingId});
|
|
|
|
@override
|
|
ConsumerState<EditorScreen> createState() => _EditorScreenState();
|
|
}
|
|
|
|
class _EditorScreenState extends ConsumerState<EditorScreen> with EditorLogic {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadDocumentData();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_tanggalCtrl.dispose();
|
|
_noPoCtrl.dispose();
|
|
_noSoCtrl.dispose();
|
|
_noDoCtrl.dispose();
|
|
_kepadaYthCtrl.dispose();
|
|
_orderUntukCtrl.dispose();
|
|
_alamatCtrl.dispose();
|
|
_platTrukCtrl.dispose();
|
|
_namaDriverCtrl.dispose();
|
|
_namaPenerimaCtrl.dispose();
|
|
_latitudeCtrl.dispose();
|
|
_longitudeCtrl.dispose();
|
|
for (var ctrls in _itemControllers) {
|
|
ctrls['sku']?.dispose();
|
|
ctrls['nama']?.dispose();
|
|
ctrls['banyak']?.dispose();
|
|
ctrls['jumlah']?.dispose();
|
|
}
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (_document == null) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Tinjau Data')),
|
|
body: const Center(child: Text('Dokumen tidak ditemukan atau masih diproses')),
|
|
);
|
|
}
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Tinjau & Edit Data'),
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.arrow_back),
|
|
onPressed: () => context.pop(),
|
|
),
|
|
),
|
|
body: SingleChildScrollView(
|
|
padding: AppConfig.screenPadding,
|
|
child: Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Container(
|
|
padding: AppConfig.paddingLarge,
|
|
decoration: BoxDecoration(
|
|
color: AppConfig.primaryColor.withOpacity(0.05),
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadiusMedium),
|
|
border: Border.all(color: AppConfig.primaryColor.withOpacity(0.2)),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
const Icon(Icons.info_outline, color: AppConfig.primaryColor),
|
|
const SizedBox(width: AppConfig.spaceMedium),
|
|
Expanded(
|
|
child: Text(
|
|
'Tinjau dan edit data hasil ekstraksi di bawah ini untuk memastikan keakuratannya sebelum konfirmasi.',
|
|
style: AppConfig.bodyMedium.copyWith(color: AppConfig.primaryColor),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: AppConfig.spaceXL),
|
|
|
|
HeaderDetailsCard(
|
|
tanggalCtrl: _tanggalCtrl,
|
|
noPoCtrl: _noPoCtrl,
|
|
noSoCtrl: _noSoCtrl,
|
|
noDoCtrl: _noDoCtrl,
|
|
),
|
|
const SizedBox(height: AppConfig.spaceLarge),
|
|
|
|
ShipmentDetailsCard(
|
|
kepadaYthCtrl: _kepadaYthCtrl,
|
|
orderUntukCtrl: _orderUntukCtrl,
|
|
alamatCtrl: _alamatCtrl,
|
|
platTrukCtrl: _platTrukCtrl,
|
|
namaDriverCtrl: _namaDriverCtrl,
|
|
),
|
|
const SizedBox(height: AppConfig.spaceLarge),
|
|
|
|
LocationDetailsCard(
|
|
latitudeCtrl: _latitudeCtrl,
|
|
longitudeCtrl: _longitudeCtrl,
|
|
),
|
|
const SizedBox(height: AppConfig.spaceLarge),
|
|
|
|
ItemsListCard(
|
|
itemControllers: _itemControllers,
|
|
onRemoveItem: _removeItem,
|
|
onAddItem: () => _addItem(),
|
|
),
|
|
const SizedBox(height: AppConfig.spaceXL),
|
|
|
|
ElevatedButton(
|
|
onPressed: _showConfirmationDialog,
|
|
style: ElevatedButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(vertical: 18),
|
|
),
|
|
child: const Text('Simpan & Konfirmasi'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|