From 27f00e43a731c0197187b2fa8d11cc55e5bf6206 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Fri, 28 Feb 2025 12:36:26 +0800 Subject: [PATCH] update --- .../arm64-v8a/configure_fingerprint.bin | 24 +++--- .../armeabi-v7a/configure_fingerprint.bin | 24 +++--- .../k6q1g3c4/x86/configure_fingerprint.bin | 24 +++--- .../k6q1g3c4/x86_64/configure_fingerprint.bin | 24 +++--- lib/main.dart | 6 ++ lib/pages/add_category_page.dart | 10 ++- lib/pages/add_generics_page.dart | 28 ++++++- lib/pages/add_manufactorer.dart | 82 +++++++++++++++++++ lib/pages/add_medicine_page.dart | 6 +- lib/pages/add_stock_page.dart | 2 +- lib/pages/delete_stock_page.dart | 2 +- lib/pages/main_page.dart | 10 ++- lib/tables/ref_categories.dart | 36 ++++++-- lib/tables/ref_generic_names.dart | 60 ++++++++------ lib/widgets/dropdown_widget.dart | 18 ++-- 15 files changed, 252 insertions(+), 104 deletions(-) create mode 100644 lib/pages/add_manufactorer.dart diff --git a/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/configure_fingerprint.bin b/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/configure_fingerprint.bin index d22ff67..058aa0a 100644 --- a/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/configure_fingerprint.bin +++ b/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/configure_fingerprint.bin @@ -2,27 +2,27 @@ C/C++ Structured Logz x v/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/additional_project_files.txtC A -?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  ϳ2  2w +?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  ߶2  2w u -s/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/android_gradle_build.json  ϳ2 Ǖ2| +s/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/android_gradle_build.json  ߶2 Ǖ2| z -x/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/android_gradle_build_mini.json  ϳ2 򕂎2i +x/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/android_gradle_build_mini.json  ߶2 򕂎2i g -e/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/build.ninja  ϳ2 2m +e/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/build.ninja  ට2 2m k -i/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/build.ninja.txt  ϳ2r +i/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/build.ninja.txt  ට2r p -n/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/build_file_index.txt  ϳ2 ^ 2s +n/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/build_file_index.txt  ට2 ^ 2s q -o/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/compile_commands.json  ϳ2w +o/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/compile_commands.json  ට2w u -s/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/compile_commands.json.bin  ϳ2 } +s/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/compile_commands.json.bin  ට2 } { -y/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/metadata_generation_command.txt  ϳ2 +y/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/metadata_generation_command.txt  ට2  2p n -l/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/prefab_config.json  ϳ2  ( 2u +l/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/prefab_config.json  ට2  ( 2u s -q/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/symbol_folder_index.txt  ϳ2  h 2b +q/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/arm64-v8a/symbol_folder_index.txt  ට2  h 2b ` -^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  ϳ2  ȼ2 \ No newline at end of file +^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  ට2  ȼ2 \ No newline at end of file diff --git a/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/configure_fingerprint.bin b/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/configure_fingerprint.bin index 3e12eaa..b785511 100644 --- a/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/configure_fingerprint.bin +++ b/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/configure_fingerprint.bin @@ -2,27 +2,27 @@ C/C++ Structured Log| z x/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/additional_project_files.txtC A -?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2y +?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  ÷2  2y w -u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/android_gradle_build.json  2 2~ +u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/android_gradle_build.json  ÷2 2~ | -z/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/android_gradle_build_mini.json  2 2k +z/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/android_gradle_build_mini.json  ÷2 2k i -g/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/build.ninja  2 2o +g/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/build.ninja  ÷2 2o m -k/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/build.ninja.txt  2t +k/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/build.ninja.txt  ÷2t r -p/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/build_file_index.txt  2 ^ 2u +p/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/build_file_index.txt  ÷2 ^ 2u s -q/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/compile_commands.json  2y +q/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/compile_commands.json  ÷2y w -u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/compile_commands.json.bin  2  +u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/compile_commands.json.bin  ÷2  } -{/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/metadata_generation_command.txt  2 +{/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/metadata_generation_command.txt  ÷2  2r p -n/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/prefab_config.json  2  ( 2w +n/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/prefab_config.json  ÷2  ( 2w u -s/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/symbol_folder_index.txt  2  j 2b +s/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/armeabi-v7a/symbol_folder_index.txt  ķ2  j 2b ` -^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file +^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  ķ2  ȼ2 \ No newline at end of file diff --git a/android/app/.cxx/Debug/k6q1g3c4/x86/configure_fingerprint.bin b/android/app/.cxx/Debug/k6q1g3c4/x86/configure_fingerprint.bin index 756fb5b..24010ea 100644 --- a/android/app/.cxx/Debug/k6q1g3c4/x86/configure_fingerprint.bin +++ b/android/app/.cxx/Debug/k6q1g3c4/x86/configure_fingerprint.bin @@ -2,27 +2,27 @@ C/C++ Structured Logt r p/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/additional_project_files.txtC A -?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2q +?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2q o -m/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/android_gradle_build.json  2 2v +m/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/android_gradle_build.json  2 2v t -r/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/android_gradle_build_mini.json  2 2c +r/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/android_gradle_build_mini.json  2 2c a -_/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/build.ninja  2 2g +_/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/build.ninja  2 2g e -c/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/build.ninja.txt  2l +c/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/build.ninja.txt  2l j -h/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/build_file_index.txt  2 ^ 2m +h/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/build_file_index.txt  2 ^ 2m k -i/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/compile_commands.json  2q +i/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/compile_commands.json  2q o -m/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/compile_commands.json.bin  2 w +m/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/compile_commands.json.bin  2 w u -s/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/metadata_generation_command.txt  2 +s/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/metadata_generation_command.txt  2  2j h -f/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/prefab_config.json  2  ( 2o +f/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/prefab_config.json  2  ( 2o m -k/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/symbol_folder_index.txt  2  b 2b +k/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86/symbol_folder_index.txt  2  b 2b ` -^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file +^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file diff --git a/android/app/.cxx/Debug/k6q1g3c4/x86_64/configure_fingerprint.bin b/android/app/.cxx/Debug/k6q1g3c4/x86_64/configure_fingerprint.bin index 11934a9..bc71260 100644 --- a/android/app/.cxx/Debug/k6q1g3c4/x86_64/configure_fingerprint.bin +++ b/android/app/.cxx/Debug/k6q1g3c4/x86_64/configure_fingerprint.bin @@ -2,27 +2,27 @@ C/C++ Structured Logw u s/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/additional_project_files.txtC A -?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2t +?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2t r -p/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/android_gradle_build.json  2 2y +p/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/android_gradle_build.json  2 2y w -u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/android_gradle_build_mini.json  2 2f +u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/android_gradle_build_mini.json  2 2f d -b/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/build.ninja  2 2j +b/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/build.ninja  2 2j h -f/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/build.ninja.txt  2o +f/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/build.ninja.txt  2o m -k/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/build_file_index.txt  2 ^ 2p +k/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/build_file_index.txt  2 ^ 2p n -l/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/compile_commands.json  2t +l/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/compile_commands.json  2t r -p/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/compile_commands.json.bin  2 z +p/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/compile_commands.json.bin  2 z x -v/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/metadata_generation_command.txt  2 +v/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/metadata_generation_command.txt  2  2m k -i/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/prefab_config.json  2  ( 2r +i/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/prefab_config.json  2  ( 2r p -n/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/symbol_folder_index.txt  2  e 2b +n/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/Debug/k6q1g3c4/x86_64/symbol_folder_index.txt  2  e 2b ` -^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file +^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index d39819c..2ca3e01 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:pharmacy_mobile/auth/auth_gate.dart'; import 'package:pharmacy_mobile/pages/add_category_page.dart'; import 'package:pharmacy_mobile/pages/add_generics_page.dart'; +import 'package:pharmacy_mobile/pages/add_manufactorer.dart'; import 'package:pharmacy_mobile/pages/add_medicine_page.dart'; import 'package:pharmacy_mobile/pages/add_stock_page.dart'; import 'package:pharmacy_mobile/pages/add_type_page.dart'; @@ -53,6 +54,11 @@ final _router = GoRouter( path: '/main', builder: (context, state) => const MainPage(), ), + GoRoute( + name: 'addmanufactorer', + path: '/addmanufactorer', + builder: (context, state) => const AddManufactorerPage(), + ), GoRoute( name: 'addmedicines', path: '/addmedicines', diff --git a/lib/pages/add_category_page.dart b/lib/pages/add_category_page.dart index ac9b0f9..0e2ad95 100644 --- a/lib/pages/add_category_page.dart +++ b/lib/pages/add_category_page.dart @@ -29,16 +29,20 @@ class _AddCategoryPageState extends State { try { if (await InternetConnectionChecker.instance.hasConnection) { - await _refCategories.postCategory(_categoryController.text.toUpperCase()); + final post = await _refCategories.postCategory(_categoryController.text.toUpperCase()); - if (mounted) { - showNotification(context, 'Category Saved', true); + if (post && mounted) { + showNotification(context, 'Category saved', true); WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { context.push('/main'); } }); + } else { + if (mounted) { + showNotification(context, 'Category not saved', false); + } } } else { if (mounted) { diff --git a/lib/pages/add_generics_page.dart b/lib/pages/add_generics_page.dart index dddebeb..417f334 100644 --- a/lib/pages/add_generics_page.dart +++ b/lib/pages/add_generics_page.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:gap/gap.dart'; import 'package:flutter/material.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; @@ -51,6 +53,11 @@ class _AddGenericsPageState extends State { } } + Future _checkExisting() async { + final uuid = await _refGenericNames.getUUID(_nameController.text); + return uuid.isNotEmpty; + } + void autoRun() async { if (await InternetConnectionChecker.instance.hasConnection) { _getList(); @@ -76,18 +83,31 @@ class _AddGenericsPageState extends State { try { if (await InternetConnectionChecker.instance.hasConnection) { + final existing = await _checkExisting(); + + if (existing && mounted) { + showNotification(context, 'Generic Name already existing', false); + return; + } + _categoryUUID = await _refCategories.getUUID(_selectedCategory); + log('_selectedCategory: $_selectedCategory'); + log('_categoryUUID: $_categoryUUID'); - await _refGenericNames.postGeneric(_nameController.text, _categoryUUID); + final post = await _refGenericNames.postGeneric(_nameController.text, _categoryUUID); - if (mounted) { - showNotification(context, 'Generic Name Saved', true); + if (post && mounted) { + showNotification(context, 'Generic name saved', true); WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { context.push('/main'); } }); + } else { + if (mounted) { + showNotification(context, 'Generic name not saved', false); + } } } else { if (mounted) { @@ -172,7 +192,7 @@ class _AddGenericsPageState extends State { list: _categoryList, listTitle: 'category_name', onChanged: _updateCategory, - value: _selectedCategory, + // value: _selectedCategory, ), const Gap(32), if (_isLoading) diff --git a/lib/pages/add_manufactorer.dart b/lib/pages/add_manufactorer.dart new file mode 100644 index 0000000..0f66b26 --- /dev/null +++ b/lib/pages/add_manufactorer.dart @@ -0,0 +1,82 @@ +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:internet_connection_checker/internet_connection_checker.dart'; +import 'package:pharmacy_mobile/widgets/button_widget.dart'; +import 'package:pharmacy_mobile/widgets/form_border_widget2.dart'; +import 'package:pharmacy_mobile/widgets/input_widget.dart'; +import 'package:pharmacy_mobile/widgets/page_background_widget.dart'; +import 'package:pharmacy_mobile/widgets/text_widget.dart'; +import 'package:pharmacy_mobile/widgets/title_widget.dart'; + +class AddManufactorerPage extends StatefulWidget { + const AddManufactorerPage({super.key}); + + @override + State createState() => _AddManufactorerPageState(); +} + +class _AddManufactorerPageState extends State { + final _formKey = GlobalKey(); + final _nameController = TextEditingController(); + final _addressController = TextEditingController(); + + late bool _isLoading = false; + + void saveManufactorer() async { + setState(() => _isLoading = true); + + if (await InternetConnectionChecker.instance.hasConnection) { + // final existing = await _checkExisting(); + } + + setState(() => _isLoading = false); + } + + @override + void dispose() { + _nameController.dispose(); + _addressController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: PageBackgroundWidget( + child: Center( + child: Column( + children: [ + const Gap(96), + const TitleWidget( + firstTextSize: 14, + secondTextSize: 24, + logoSize: 90, + ), + const Gap(32), + const TextWidget( + text: 'Add Manufactorer', + title: true, + ), + const Gap(16), + FormBorderWidget2( + color: 'blue', + child: Form( + key: _formKey, + child: Column( + children: [ + InputWidget(label: 'Name', controller: _nameController), + const Gap(16), + InputWidget(label: 'Address', controller: _addressController), + const Gap(32), + if (_isLoading) + const Center(child: CircularProgressIndicator(color: Colors.white)) + else + ButtonWidget(text: 'Add', onPressed: saveManufactorer) + ], + ))) + ], + ), + )), + ); + } +} diff --git a/lib/pages/add_medicine_page.dart b/lib/pages/add_medicine_page.dart index a7d6a9d..13d2893 100644 --- a/lib/pages/add_medicine_page.dart +++ b/lib/pages/add_medicine_page.dart @@ -284,7 +284,7 @@ class _AddMedicinePageState extends State { list: _genericNameList, listTitle: 'generic_name', onChanged: _updateGeneric, - value: _selectedGeneric, + // value: _selectedGeneric, ), const Gap(8), Padding( @@ -297,7 +297,7 @@ class _AddMedicinePageState extends State { list: _typeList, listTitle: 'type_name', onChanged: _updateType, - value: _selectedType, + // value: _selectedType, ), const Gap(16), DropDownWidget( @@ -305,7 +305,7 @@ class _AddMedicinePageState extends State { list: _manufactorerList, listTitle: 'manufactorer_name', onChanged: _updateManufactorer, - value: _selectedManufactorer, + // value: _selectedManufactorer, ), const Gap(16), InputWidget(label: 'Barcode', controller: _barcodeController), diff --git a/lib/pages/add_stock_page.dart b/lib/pages/add_stock_page.dart index 2d86533..a7b88cc 100644 --- a/lib/pages/add_stock_page.dart +++ b/lib/pages/add_stock_page.dart @@ -140,7 +140,7 @@ class _AddStockPageState extends State with WidgetsBindingObserver list: _medicineList, listTitle: 'medicine_name', onChanged: _updateMedicine, - value: _selectedMedicine, + // value: _selectedMedicine, ), Row( mainAxisAlignment: MainAxisAlignment.end, diff --git a/lib/pages/delete_stock_page.dart b/lib/pages/delete_stock_page.dart index 7c6e815..0982326 100644 --- a/lib/pages/delete_stock_page.dart +++ b/lib/pages/delete_stock_page.dart @@ -143,7 +143,7 @@ class _DeleteStockPageState extends State { list: _stockList, listTitle: 'medicine_name', onChanged: _updateStock, - value: _selectedStock, + // value: _selectedStock, ), const Gap(16), InputWidget(label: 'Quantity', controller: _quantityController, onChanged: _setQuantity), diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index 61819c6..a03b4ff 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -33,7 +33,7 @@ class _MainPageState extends State { resizeToAvoidBottomInset: false, body: SingleChildScrollView( child: PageBackgroundWidget( - height: MediaQuery.of(context).size.height + 400, + height: MediaQuery.of(context).size.height + 500, page: 'menu', child: Center( child: Column( @@ -50,6 +50,14 @@ class _MainPageState extends State { title: true, ), const Gap(16), + MenuWidget( + icon: FontAwesomeIcons.circlePlus, + text: 'Add Manufactorer', + description: 'Add Manufactorer to the record', + onPressed: () => {context.push('/addmanufactorer')}, + color: 'blue', + ), + const Gap(16), MenuWidget( icon: FontAwesomeIcons.circlePlus, text: 'Add Type', diff --git a/lib/tables/ref_categories.dart b/lib/tables/ref_categories.dart index 8dfab27..5ba4d12 100644 --- a/lib/tables/ref_categories.dart +++ b/lib/tables/ref_categories.dart @@ -5,22 +5,40 @@ class RefCategories { final SupabaseClient _supabase = Supabase.instance.client; Future getList() async { - final data = await _supabase.from('ref_categories').select('category_name').order('category_name', ascending: true); - return data.toList(); + try { + final data = + await _supabase.from('ref_categories').select('category_name').order('category_name', ascending: true); + return data.toList(); + } catch (e) { + return []; + } } Future getUUID(String name) async { - final data = await _supabase.from('ref_categories').select('ref_categories_uuid').eq('category_name', name); - return data.first['ref_categories_uuid']; + try { + final data = await _supabase.from('ref_categories').select('ref_categories_uuid').eq('category_name', name); + return data.first['ref_categories_uuid']; + } catch (e) { + return ''; + } } Future getName(String uuid) async { - final data = await _supabase.from('ref_categories').select('category_name').eq('ref_categories_uuid', uuid); - return data.first['category_name']; + try { + final data = await _supabase.from('ref_categories').select('category_name').eq('ref_categories_uuid', uuid); + return data.first['category_name']; + } catch (e) { + return ''; + } } - Future postCategory(String name) async { - final categoryUUID = Uuid().v4(); - await _supabase.from('ref_categories').insert({'ref_categories_uuid': categoryUUID, 'category_name': name}); + Future postCategory(String name) async { + try { + final categoryUUID = Uuid().v4(); + await _supabase.from('ref_categories').insert({'ref_categories_uuid': categoryUUID, 'category_name': name}); + return true; + } catch (e) { + return false; + } } } diff --git a/lib/tables/ref_generic_names.dart b/lib/tables/ref_generic_names.dart index c3e2b9c..02abfc6 100644 --- a/lib/tables/ref_generic_names.dart +++ b/lib/tables/ref_generic_names.dart @@ -5,42 +5,52 @@ class RefGenericNames { final SupabaseClient _supabase = Supabase.instance.client; Future getList() async { - final data = - await _supabase.from('ref_generic_names').select('generic_name').order('generic_name', ascending: true); - return data.toList(); + try { + final data = + await _supabase.from('ref_generic_names').select('generic_name').order('generic_name', ascending: true); + return data.toList(); + } catch (e) { + return []; + } } Future getCategoryUUID(name) async { - final data = await _supabase.from('ref_generic_names').select('ref_categories_uuid').eq('generic_name', name); - return data.first['ref_categories_uuid'].toString(); + try { + final data = await _supabase.from('ref_generic_names').select('ref_categories_uuid').eq('generic_name', name); + return data.first['ref_categories_uuid'].toString(); + } catch (e) { + return ''; + } } Future getUUID(name) async { - final data = await _supabase.from('ref_generic_names').select('ref_generic_names_uuid').eq('generic_name', name); - return data.first['ref_generic_names_uuid'].toString(); + try { + final data = await _supabase.from('ref_generic_names').select('ref_generic_names_uuid').eq('generic_name', name); + return data.first['ref_generic_names_uuid'].toString(); + } catch (e) { + return ''; + } } - Future postGeneric(String name, String uuid) async { - final genericUUID = Uuid().v4(); + Future postGeneric(String name, String uuid) async { + try { + final genericUUID = Uuid().v4(); - await _supabase - .from('ref_generic_names') - .insert({'ref_generic_names_uuid': genericUUID, 'generic_name': name, 'ref_categories_uuid': uuid}); + await _supabase + .from('ref_generic_names') + .insert({'ref_generic_names_uuid': genericUUID, 'generic_name': name, 'ref_categories_uuid': uuid}); + return true; + } catch (e) { + return false; + } } Future getSample() async { - final data = await _supabase.from('ref_generic_names').select('''generic_name, ref_categories(category_name)'''); - return data.toList(); + try { + final data = await _supabase.from('ref_generic_names').select('''generic_name, ref_categories(category_name)'''); + return data.toList(); + } catch (e) { + return []; + } } } - - -// let { data: ref_generic_names, error } = await supabase -// .from('ref_generic_names') -// .select(` -// some_column, -// other_table ( -// foreign_key -// ) -// `) - \ No newline at end of file diff --git a/lib/widgets/dropdown_widget.dart b/lib/widgets/dropdown_widget.dart index 8f70b10..bd52297 100644 --- a/lib/widgets/dropdown_widget.dart +++ b/lib/widgets/dropdown_widget.dart @@ -9,15 +9,15 @@ class DropDownWidget extends StatelessWidget { final List list; final String listTitle; final OnChangedCallback onChanged; - final String value; + // final String value; - const DropDownWidget( - {super.key, - required this.label, - required this.list, - required this.listTitle, - required this.onChanged, - required this.value}); + const DropDownWidget({ + super.key, + required this.label, + required this.list, + required this.listTitle, + required this.onChanged, + }); @override Widget build(BuildContext context) { return Column( @@ -41,7 +41,7 @@ class DropDownWidget extends StatelessWidget { for (var item in list) DropdownMenuEntry( label: item[listTitle].toString(), - value: value, + value: item[listTitle].toString(), style: ButtonStyle( foregroundColor: WidgetStateProperty.all(const Color.fromRGBO(10, 10, 10, 1)), textStyle: WidgetStateProperty.all(