added cache for distributors

This commit is contained in:
Patrick Alvin Alcala 2025-04-22 11:33:46 +08:00
parent 77fae74302
commit f2fdfc644a
6 changed files with 70 additions and 4 deletions

View file

@ -63,7 +63,7 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
late List _supplierList = [];
late String _selectedManufacturer = '';
late String _selectedDistributor = '';
late final String _selectedSupplier = '';
late String _selectedSupplier = '';
late String uuid = '';
late bool imageUploaded = false;
late String imageUrl = '';
@ -206,6 +206,10 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
_selectedDistributor = distributor;
}
void _updateSupplier(dynamic supplier) {
_selectedSupplier = supplier;
}
Future<void> _scanBarcode() async {
// String? barcode = await SimpleBarcodeScanner.scanBarcode(
// context,
@ -238,8 +242,8 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
final medDistributorUUID = await _refDistributors.getUUID(_selectedDistributor);
final medSupplierUUID = await _refSuppliers.getUUID(_selectedSupplier);
final posted = await _refMedicines.postMedicine(
uuid, medName, medManufacturerUUID, medGenericUUID, medTypeUUID, encrpytedBarcode, medDistributorUUID, medSupplierUUID);
final posted = await _refMedicines.postMedicine(uuid, medName, medManufacturerUUID, medGenericUUID, medTypeUUID,
encrpytedBarcode, medDistributorUUID, medSupplierUUID);
if (posted) {
if (mounted) {
@ -357,7 +361,7 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
color: 'green',
child: Form(
key: _formKey,
child: DropdownWrapperMultiWidget(list: _genericNameList, text: 'Data', children: [
child: DropdownWrapperMultiWidget(list: _supplierList, text: 'Data', children: [
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
InputFormWidget(label: 'Name', controller: _nameController),
const Gap(16),
@ -394,6 +398,13 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
onChanged: _updateDistributor,
),
const Gap(16),
DropDownWidget(
label: 'Supplier',
list: _supplierList,
listTitle: 'supplier_name',
onChanged: _updateSupplier,
),
const Gap(16),
InputFormWidget(label: 'Barcode', controller: _barcodeController),
ScanbarcodeWidget(onTap: _scanBarcode),
const Gap(16),