add event update panel
All checks were successful
Release / meta (push) Successful in 8s
Release / linux-build (push) Successful in 6m41s
Release / android-build (push) Successful in 15m19s
Release / release-master (push) Successful in 22s
Release / release-dev (push) Successful in 24s

This commit is contained in:
2025-12-16 16:14:14 +00:00
parent 411e82807b
commit 4a6aee8a15
5 changed files with 505 additions and 19 deletions

View File

@@ -97,10 +97,7 @@ class ApiService {
return body;
}
if (res.statusCode == 401 &&
body is Map<String, dynamic> &&
body['detail'] == 'Not authenticated' &&
_onUnauthorized != null) {
if (res.statusCode == 401 && _onUnauthorized != null) {
await _onUnauthorized!();
}

View File

@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
@@ -441,6 +442,30 @@ class DataService extends ChangeNotifier {
return _locoClasses;
}
Future<void> createLocoEvent({
required int locoId,
required String eventDate,
required Map<String, dynamic> values,
required String details,
String eventType = 'other',
}) async {
try {
await api.put(
'/event/new',
{
'loco_id': locoId,
'loco_event_type': eventType,
'loco_event_date': eventDate,
'loco_event_value': jsonEncode(values),
'loco_event_details': details,
},
);
} catch (e) {
debugPrint('Failed to create loco event: $e');
rethrow;
}
}
void clear() {
_homepageStats = null;
_legs = [];