From 0fa5a85d7907d885b26eb22543d4d211f825155e Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Fri, 12 Dec 2025 17:29:03 +0530 Subject: [PATCH] fixed issues --- .../dashboard/dashboard_controller.dart | 1 + lib/helpers/services/api_endpoints.dart | 4 ++-- lib/helpers/services/api_service.dart | 12 ++++++++++-- lib/helpers/services/storage/local_storage.dart | 11 +++++------ lib/helpers/theme/theme_editor_widget.dart | 7 ++++++- lib/helpers/widgets/my_custom_skeleton.dart | 8 +++++--- .../user_document_filter_bottom_sheet.dart | 16 +++++++++------- .../expense/reimbursement_bottom_sheet.dart | 2 +- lib/view/employees/employee_detail_screen.dart | 1 + pubspec.yaml | 2 +- 10 files changed, 41 insertions(+), 23 deletions(-) diff --git a/lib/controller/dashboard/dashboard_controller.dart b/lib/controller/dashboard/dashboard_controller.dart index 022e89c..ad0b041 100644 --- a/lib/controller/dashboard/dashboard_controller.dart +++ b/lib/controller/dashboard/dashboard_controller.dart @@ -228,6 +228,7 @@ class DashboardController extends GetxController { fetchMasterData(), fetchCollectionOverview(), fetchPurchaseInvoiceOverview(), + fetchTodaysAttendance(projectId), ]); } diff --git a/lib/helpers/services/api_endpoints.dart b/lib/helpers/services/api_endpoints.dart index bc8df7a..fa12d19 100644 --- a/lib/helpers/services/api_endpoints.dart +++ b/lib/helpers/services/api_endpoints.dart @@ -1,9 +1,9 @@ class ApiEndpoints { - static const String baseUrl = "https://stageapi.marcoaiot.com/api"; + // static const String baseUrl = "https://stageapi.marcoaiot.com/api"; // static const String baseUrl = "https://api.marcoaiot.com/api"; // static const String baseUrl = "https://devapi.marcoaiot.com/api"; // static const String baseUrl = "https://mapi.marcoaiot.com/api"; - // static const String baseUrl = "https://api.onfieldwork.com/api"; + static const String baseUrl = "https://api.onfieldwork.com/api"; static const String getMasterCurrencies = "/Master/currencies/list"; diff --git a/lib/helpers/services/api_service.dart b/lib/helpers/services/api_service.dart index 0ef2005..59db63f 100644 --- a/lib/helpers/services/api_service.dart +++ b/lib/helpers/services/api_service.dart @@ -114,6 +114,12 @@ class ApiService { level: LogLevel.debug); if (body.isEmpty) { + if (response.statusCode == 204) { + _log("Successful operation with 204 No Content for [$label]"); + return returnFullResponse + ? {'success': true, 'message': 'No Content'} + : null; + } _log("Empty response body for [$label]"); return null; } @@ -127,8 +133,10 @@ class ApiService { return null; } - // Handle non-200 or failure scenarios - if (response.statusCode != 200 || + // Define success status codes: 200 OK, 201 Created. + const successCodes = [200, 201]; + // Handle non-success scenarios + if (!successCodes.contains(response.statusCode) || decryptedJson is! Map || decryptedJson['success'] != true) { final message = decryptedJson is Map diff --git a/lib/helpers/services/storage/local_storage.dart b/lib/helpers/services/storage/local_storage.dart index d71d514..d65ecd2 100644 --- a/lib/helpers/services/storage/local_storage.dart +++ b/lib/helpers/services/storage/local_storage.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:on_field_work/controller/project_controller.dart'; import 'package:on_field_work/helpers/services/auth_service.dart'; import 'package:on_field_work/helpers/services/localizations/language.dart'; import 'package:on_field_work/helpers/theme/theme_customizer.dart'; @@ -139,6 +138,7 @@ class LocalStorage { print("Logout API error: $e"); } + // Remove all stored values await removeLoggedInUser(); await removeToken(_jwtTokenKey); await removeToken(_refreshTokenKey); @@ -147,16 +147,15 @@ class LocalStorage { await removeMpinToken(); await removeIsMpin(); await removeMenus(); - await removeRecentTenantId(); + await removeRecentTenantId(); await preferences.remove("mpin_verified"); await preferences.remove(_languageKey); await preferences.remove(_themeCustomizerKey); await preferences.remove('selectedProjectId'); - if (Get.isRegistered()) { - Get.find().clearProjects(); - } - + // ❗ Clear all GetX controllers + Get.deleteAll(force: true); + // Navigate to login Get.offAllNamed('/auth/login-option'); } diff --git a/lib/helpers/theme/theme_editor_widget.dart b/lib/helpers/theme/theme_editor_widget.dart index 2e12a95..a12a9d4 100644 --- a/lib/helpers/theme/theme_editor_widget.dart +++ b/lib/helpers/theme/theme_editor_widget.dart @@ -18,7 +18,12 @@ class ThemeOption { final List themeOptions = [ ThemeOption( - "Theme 1", Colors.red, Colors.red, Colors.red, ColorThemeType.red), + "Theme 1", + const Color(0xFFC92226), + const Color(0xFFC92226), + const Color(0xFFC92226), + ColorThemeType.red, + ), ThemeOption( "Theme 2", const Color(0xFF49BF3C), diff --git a/lib/helpers/widgets/my_custom_skeleton.dart b/lib/helpers/widgets/my_custom_skeleton.dart index f3f6eed..b448d49 100644 --- a/lib/helpers/widgets/my_custom_skeleton.dart +++ b/lib/helpers/widgets/my_custom_skeleton.dart @@ -1068,8 +1068,10 @@ static Widget _buildDetailRowSkeleton({ } static Widget documentSkeletonLoader() { - return Column( - children: List.generate(5, (index) { + return ListView.builder( + padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 0), + itemCount: 5, + itemBuilder: (context, index) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -1160,7 +1162,7 @@ static Widget _buildDetailRowSkeleton({ ), ], ); - }), + }, ); } diff --git a/lib/model/document/user_document_filter_bottom_sheet.dart b/lib/model/document/user_document_filter_bottom_sheet.dart index 3ce1c5b..7697c0b 100644 --- a/lib/model/document/user_document_filter_bottom_sheet.dart +++ b/lib/model/document/user_document_filter_bottom_sheet.dart @@ -35,11 +35,13 @@ class _UserDocumentFilterBottomSheetState if (filterData == null) return const SizedBox.shrink(); final hasFilters = [ - filterData.uploadedBy, - filterData.documentCategory, - filterData.documentType, - filterData.documentTag, - ].any((list) => list.isNotEmpty); + filterData.uploadedBy, + filterData.documentCategory, + filterData.documentType, + filterData.documentTag, + ].any((list) => list.isNotEmpty) || + docController.startDate.value != null || + docController.endDate.value != null; return BaseBottomSheet( title: 'Filter Documents', @@ -53,8 +55,8 @@ class _UserDocumentFilterBottomSheetState 'documentTypeIds': docController.selectedType.toList(), 'documentTagIds': docController.selectedTag.toList(), 'isUploadedAt': docController.isUploadedAt.value, - 'startDate': docController.startDate.value, - 'endDate': docController.endDate.value, + 'startDate': docController.startDate.value?.toIso8601String(), + 'endDate': docController.endDate.value?.toIso8601String(), if (docController.isVerified.value != null) 'isVerified': docController.isVerified.value, }; diff --git a/lib/model/expense/reimbursement_bottom_sheet.dart b/lib/model/expense/reimbursement_bottom_sheet.dart index c1d0e13..7f8ada9 100644 --- a/lib/model/expense/reimbursement_bottom_sheet.dart +++ b/lib/model/expense/reimbursement_bottom_sheet.dart @@ -41,7 +41,7 @@ class ReimbursementBottomSheet extends StatefulWidget { class _ReimbursementBottomSheetState extends State { final ExpenseDetailController controller = - Get.find(); + Get.put(ExpenseDetailController()); final TextEditingController commentCtrl = TextEditingController(); final TextEditingController txnCtrl = TextEditingController(); diff --git a/lib/view/employees/employee_detail_screen.dart b/lib/view/employees/employee_detail_screen.dart index 7a8b185..4797c71 100644 --- a/lib/view/employees/employee_detail_screen.dart +++ b/lib/view/employees/employee_detail_screen.dart @@ -526,6 +526,7 @@ class _EmployeeDetailPageState extends State with UIMixin { label: MyText( 'Assign to Project', fontSize: 14, + color: Colors.white, fontWeight: 500, ), ); diff --git a/pubspec.yaml b/pubspec.yaml index 9288b1f..5789100 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+19 +version: 1.0.1+20 environment: sdk: ^3.5.3