From adb3cb0754dd1eb7815c9827b5c9cbe984e4567f Mon Sep 17 00:00:00 2001 From: ALim Aidrus Date: Wed, 3 Sep 2025 10:19:12 +0800 Subject: [PATCH] repair river api and telegram issue --- lib/services/river_in_situ_sampling_service.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/services/river_in_situ_sampling_service.dart b/lib/services/river_in_situ_sampling_service.dart index 11f2728..6036e0c 100644 --- a/lib/services/river_in_situ_sampling_service.dart +++ b/lib/services/river_in_situ_sampling_service.dart @@ -170,13 +170,14 @@ class RiverInSituSamplingService { if (dataResult['success'] != true) { await _logAndSave(data: data, status: 'L1', message: dataResult['message']!, apiResults: [dataResult], ftpStatuses: [], serverName: serverName); - return {'success': false, 'message': dataResult['message']}; + // FIX: Also return the status code for the UI + return {'status': 'L1', 'success': false, 'message': dataResult['message']}; } final recordId = dataResult['data']?['r_man_id']?.toString(); if (recordId == null) { await _logAndSave(data: data, status: 'L1', message: 'API Error: Missing record ID.', apiResults: [dataResult], ftpStatuses: [], serverName: serverName); - return {'success': false, 'message': 'API Error: Missing record ID.'}; + return {'status': 'L1', 'success': false, 'message': 'API Error: Missing record ID.'}; } data.reportId = recordId; @@ -252,7 +253,13 @@ class RiverInSituSamplingService { _handleSuccessAlert(data, appSettings, isDataOnly: !apiSuccess); } - return {'success': apiSuccess || ftpSuccess, 'message': finalMessage}; + // FIX: Add the 'status' and 'reportId' keys to the return map for the UI. + return { + 'status': finalStatus, + 'success': apiSuccess || ftpSuccess, + 'message': finalMessage, + 'reportId': data.reportId + }; } Future _logAndSave({ @@ -279,7 +286,6 @@ class RiverInSituSamplingService { } Future _handleSuccessAlert(RiverInSituSamplingData data, List>? appSettings, {required bool isDataOnly}) async { - debugPrint("[DEBUG] appSettings passed to _handleSuccessAlert: ${jsonEncode(appSettings)}"); try { final submissionType = isDataOnly ? "(Data Only)" : "(Data & Images)"; final stationName = data.selectedStation?['sampling_river'] ?? 'N/A';