revamp new trip flow

This commit is contained in:
2024-09-24 22:58:28 +02:00
parent eaa2334942
commit ed60fcba06
26 changed files with 663 additions and 302 deletions

View File

@@ -29,11 +29,10 @@ Dio dio = Dio(
fetchTrip(
Trip trip,
Future<UserPreferences> preferences,
UserPreferences preferences,
) async {
UserPreferences prefs = await preferences;
Map<String, dynamic> data = {
"preferences": prefs.toJson(),
"preferences": preferences.toJson(),
"start": trip.landmarks!.first.location,
};
String dataString = jsonEncode(data);
@@ -47,11 +46,16 @@ fetchTrip(
// handle errors
if (response.statusCode != 200) {
trip.updateUUID("error");
if (response.data["detail"] != null) {
trip.updateError(response.data["detail"]);
log(response.data["detail"]);
// throw Exception(response.data["detail"]);
String errorDetail;
if (response.data.runtimeType == String) {
errorDetail = response.data;
} else {
errorDetail = response.data["detail"] ?? "Unknown error";
}
trip.updateError(errorDetail);
log(errorDetail);
// Actualy no need to throw an exception, we can just log the error and let the user retry
// throw Exception(errorDetail);
} else {
Map<String, dynamic> json = response.data;