repair river api and telegram issue

This commit is contained in:
ALim Aidrus 2025-09-03 10:19:12 +08:00
parent 0d4d70cca6
commit adb3cb0754

View File

@ -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<void> _logAndSave({
@ -279,7 +286,6 @@ class RiverInSituSamplingService {
}
Future<void> _handleSuccessAlert(RiverInSituSamplingData data, List<Map<String, dynamic>>? 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';