Update Saqel Platform: 2026-09-08 18:44:36

This commit is contained in:
Hamza-Ayed
2026-09-08 18:44:36 +03:00
parent dbbd7786f2
commit dd8b95035f
4 changed files with 38 additions and 24 deletions
@@ -113,7 +113,7 @@ class TeacherRepository {
Uri.parse('$baseUrl${AppConfig.meEndpoint}'),
headers: headers,
)
.timeout(const Duration(seconds: 4));
.timeout(const Duration(seconds: 30));
if (response.statusCode == 200) {
return json.decode(response.body);
@@ -134,19 +134,21 @@ class TeacherRepository {
Uri.parse('$baseUrl${AppConfig.profileStatusEndpoint}'),
headers: headers,
)
.timeout(const Duration(seconds: 4));
.timeout(const Duration(seconds: 30));
final decoded = json.decode(response.body);
if (response.statusCode == 200) {
final decoded = json.decode(response.body);
if (decoded['status'] == 'success') {
return TeacherProfileModel.fromJson(decoded);
}
}
throw StateError(decoded['message']?.toString() ??
'فشل تحميل ملف المعلم (HTTP ${response.statusCode}).');
} catch (e) {
AppLogger.log('getProfileStatus notice: $e', tag: 'TEACHER_REPO');
if (e is StateError) rethrow;
throw StateError('تعذر الاتصال بملف المعلم: $e');
}
throw StateError('تعذر تحميل ملف المعلم من الخادم.');
}
Future<TeacherProfileModel> setupProfile({
@@ -569,10 +571,11 @@ class TeacherRepository {
totalLessons:
int.tryParse(c['lessons_total']?.toString() ?? '0') ?? 0,
militaryStudents: (c['military_students'] as num?)?.toInt() ?? 0,
externalSubscribers: (c['external_subscribers'] as num?)?.toInt() ?? 0,
priceJod:
double.tryParse(c['price_jod']?.toString() ?? '') ?? 0,
netRevenueJod: double.tryParse(c['net_revenue_jod']?.toString() ?? '') ?? 0,
externalSubscribers:
(c['external_subscribers'] as num?)?.toInt() ?? 0,
priceJod: double.tryParse(c['price_jod']?.toString() ?? '') ?? 0,
netRevenueJod:
double.tryParse(c['net_revenue_jod']?.toString() ?? '') ?? 0,
);
}).toList();
}
@@ -77,21 +77,29 @@ class _TeacherAuthScreenState extends State<TeacherAuthScreen> {
SaqelToast.showError(context, 'يرجى إدخال رمز التحقق المكون من 6 أرقام');
return;
}
if (_fullNameController.text.trim().isEmpty ||
_selectedSubject == null ||
_schoolController.text.trim().isEmpty ||
_selectedGrades.isEmpty) {
final hasAnyProfileData = _fullNameController.text.trim().isNotEmpty ||
_selectedSubject != null ||
_schoolController.text.trim().isNotEmpty ||
_selectedGrades.isNotEmpty;
final hasCompleteProfileData = _fullNameController.text.trim().isNotEmpty &&
_selectedSubject != null &&
_schoolController.text.trim().isNotEmpty &&
_selectedGrades.isNotEmpty;
if (hasAnyProfileData && !hasCompleteProfileData) {
SaqelToast.showError(context,
'أكمل الاسم والمادة والمدرسة وصفًا واحدًا على الأقل قبل التحقق');
'إما اترك بيانات الملف فارغة لتسجيل الدخول، أو أكملها كلها لإنشاء ملف معلم جديد');
return;
}
context.read<TeacherAuthCubit>().verifyOtp(
phone,
otp,
fullName: _fullNameController.text.trim(),
specialization: _selectedSubject,
schoolName: _schoolController.text.trim(),
gradesTaught: _selectedGrades.toList(),
fullName:
hasCompleteProfileData ? _fullNameController.text.trim() : null,
specialization: hasCompleteProfileData ? _selectedSubject : null,
schoolName:
hasCompleteProfileData ? _schoolController.text.trim() : null,
gradesTaught:
hasCompleteProfileData ? _selectedGrades.toList() : null,
);
}