fixed pages

This commit is contained in:
2026-09-04 08:15:25 +02:00
parent c80535eb97
commit a1167a2d03
14 changed files with 363 additions and 174 deletions
+34
View File
@@ -9,11 +9,13 @@ class TeacherParticipant {
final int bookingId;
final String fullName;
final bool isLost;
final bool isPending;
const TeacherParticipant({
required this.bookingId,
required this.fullName,
required this.isLost,
this.isPending = false,
});
factory TeacherParticipant.fromMap(Map<String, dynamic> m) =>
@@ -21,6 +23,7 @@ class TeacherParticipant {
bookingId: (m['booking_id'] as num?)?.toInt() ?? 0,
fullName: (m['full_name'] ?? '').toString().trim(),
isLost: m['is_lost'] == true,
isPending: m['is_pending'] == true,
);
}
@@ -407,4 +410,35 @@ class TeacherApi {
throw Exception(data['error'] ?? data['message'] ?? 'Errore inserimento');
}
}
/// Conferma una prenotazione in attesa (pending -> booked).
static Future<void> confirmPending({
required String token,
required int bookingId,
}) async {
final uri = Uri.parse(
'${ApiConfig.laravelApiBase}/api_teacher_confirm_pending.php',
);
final res = await http.post(
uri,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer $token',
},
body: 'booking_id=$bookingId',
);
Map<String, dynamic> data;
try {
data = jsonDecode(res.body) as Map<String, dynamic>;
} catch (_) {
throw Exception('RAW(${res.statusCode}): ${res.body}');
}
if (res.statusCode != 200 || data['success'] != true) {
throw Exception(data['error'] ?? data['message'] ?? 'Errore conferma');
}
}
}