From f834422c4e54e4c8d0c8cc814c5791a662794a10 Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Thu, 19 Jun 2025 11:26:42 +0530 Subject: [PATCH] feat: Increase timeout duration for API requests and update relevant calls --- lib/helpers/services/api_service.dart | 42 ++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/lib/helpers/services/api_service.dart b/lib/helpers/services/api_service.dart index 7ff86d9..b7ebb52 100644 --- a/lib/helpers/services/api_service.dart +++ b/lib/helpers/services/api_service.dart @@ -13,6 +13,7 @@ final Logger logger = Logger(); class ApiService { static const Duration timeout = Duration(seconds: 10); static const bool enableLogs = true; + static const Duration extendedTimeout = Duration(seconds: 60); // === Helpers === @@ -208,8 +209,11 @@ class ApiService { } } - final response = - await _postRequest(ApiEndpoints.uploadAttendanceImage, body); + final response = await _postRequest( + ApiEndpoints.uploadAttendanceImage, + body, + customTimeout: extendedTimeout, + ); if (response == null) return false; final json = jsonDecode(response.body); @@ -259,7 +263,12 @@ class ApiService { "gender": gender, "jobRoleId": jobRoleId, }; - final response = await _postRequest(ApiEndpoints.createEmployee, body); + final response = await _postRequest( + ApiEndpoints.reportTask, + body, + customTimeout: extendedTimeout, + ); + if (response == null) return false; final json = jsonDecode(response.body); return response.statusCode == 200 && json['success'] == true; @@ -309,7 +318,12 @@ class ApiService { if (images != null && images.isNotEmpty) "images": images, }; - final response = await _postRequest(ApiEndpoints.reportTask, body); + final response = await _postRequest( + ApiEndpoints.commentTask, + body, + customTimeout: extendedTimeout, + ); + if (response == null) return false; final json = jsonDecode(response.body); if (response.statusCode == 200 && json['success'] == true) { @@ -414,15 +428,17 @@ class ApiService { DateTime? assignmentDate, required String categoryId, }) async { - final body = [{ - "parentTaskId": parentTaskId, - "plannedWork": plannedTask, - "comment": comment, - "workAreaID": workAreaId, - "activityID": activityId, - "workCategoryId": categoryId, - 'completedWork': 0, - }]; + final body = [ + { + "parentTaskId": parentTaskId, + "plannedWork": plannedTask, + "comment": comment, + "workAreaID": workAreaId, + "activityID": activityId, + "workCategoryId": categoryId, + 'completedWork': 0, + } + ]; final response = await _postRequest(ApiEndpoints.assignTask, body); if (response == null) return false;