feat(ecosystem): full Grade 10 curriculum sync, real device fingerprinting, teacher video dashboard, and official textbook assets
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../../core/config/app_config.dart';
|
||||
import '../../core/services/device_fingerprint_service.dart';
|
||||
import '../../core/services/storage_service.dart';
|
||||
import '../../core/utils/app_logger.dart';
|
||||
import '../models/teacher_models.dart';
|
||||
@@ -61,10 +62,13 @@ class TeacherRepository {
|
||||
|
||||
Future<Map<String, String>> _authHeaders() async {
|
||||
final token = await _storage.getToken();
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
return {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'X-Device-Fingerprint': 'saqel_teacher_flutter',
|
||||
'X-Device-Fingerprint': fingerprint,
|
||||
'X-Device-Platform': metadata['platform'] ?? 'unknown',
|
||||
if (token != null && token.isNotEmpty) 'Authorization': 'Bearer $token',
|
||||
};
|
||||
}
|
||||
@@ -103,19 +107,23 @@ class TeacherRepository {
|
||||
AppLogger.log('Verifying Teacher OTP for $phoneNumber...',
|
||||
tag: 'TEACHER_REPO');
|
||||
try {
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
final response = await _client
|
||||
.post(
|
||||
Uri.parse('$baseUrl${AppConfig.otpVerifyEndpoint}'),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
'Accept': 'application/json',
|
||||
'X-Device-Fingerprint': fingerprint,
|
||||
'X-Device-Platform': metadata['platform'] ?? 'unknown',
|
||||
},
|
||||
body: json.encode({
|
||||
'phone_number': phoneNumber,
|
||||
'otp': otp,
|
||||
'role': 'teacher',
|
||||
if (fullName != null) 'full_name': fullName,
|
||||
'device_fingerprint': 'saqel_teacher_flutter',
|
||||
'device_fingerprint': fingerprint,
|
||||
}),
|
||||
)
|
||||
.timeout(const Duration(seconds: 30));
|
||||
@@ -546,6 +554,28 @@ class TeacherRepository {
|
||||
throw StateError('تعذر تحميل بيانات المحفظة من الخادم.');
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> getMySubmissions() async {
|
||||
try {
|
||||
final headers = await _authHeaders();
|
||||
final response = await _client
|
||||
.get(
|
||||
Uri.parse('$baseUrl/api/teacher/submissions'),
|
||||
headers: headers,
|
||||
)
|
||||
.timeout(const Duration(seconds: 10));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final decoded = json.decode(response.body);
|
||||
if (decoded['status'] == 'success' && decoded['data']?['submissions'] is List) {
|
||||
return List<Map<String, dynamic>>.from(decoded['data']['submissions']);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
AppLogger.error('getMySubmissions failed', error: e, tag: 'TEACHER_REPO');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
Future<TeacherPayoutRequestModel> requestCliqPayout({
|
||||
required String cliqAlias,
|
||||
required double amountJod,
|
||||
|
||||
Reference in New Issue
Block a user