Update Saqel Platform: 2026-09-08 18:19:28

This commit is contained in:
Hamza-Ayed
2026-09-08 18:19:28 +03:00
parent 75451ebc3f
commit e5cbd89323
22 changed files with 1537 additions and 595 deletions
@@ -7,6 +7,7 @@ import '../../data/repositories/teacher_repository.dart';
abstract class TeacherAuthState {}
class TeacherAuthInitial extends TeacherAuthState {}
class TeacherAuthLoading extends TeacherAuthState {}
class TeacherAuthOtpSent extends TeacherAuthState {
@@ -42,13 +43,16 @@ class TeacherAuthCubit extends Cubit<TeacherAuthState> {
try {
final token = await _storage.getToken();
if (token == null || token.isEmpty) {
AppLogger.log('No teacher token -> Unauthenticated', tag: 'TEACHER_AUTH');
AppLogger.log('No teacher token -> Unauthenticated',
tag: 'TEACHER_AUTH');
emit(TeacherUnauthenticated());
return;
}
final profile = await repository.getProfileStatus();
AppLogger.log('Teacher authenticated: ${profile.name} (${profile.specialization})', tag: 'TEACHER_AUTH');
AppLogger.log(
'Teacher authenticated: ${profile.name} (${profile.specialization})',
tag: 'TEACHER_AUTH');
emit(TeacherAuthenticated(profile: profile));
} catch (e) {
AppLogger.error('Session check failed', error: e, tag: 'TEACHER_AUTH');
@@ -67,7 +71,8 @@ class TeacherAuthCubit extends Cubit<TeacherAuthState> {
if (res['status'] == 'success') {
emit(TeacherAuthOtpSent(phoneNumber: phoneNumber));
} else {
emit(TeacherAuthError(res['message']?.toString() ?? 'فشل إرسال رمز التحقق'));
emit(TeacherAuthError(
res['message']?.toString() ?? 'فشل إرسال رمز التحقق'));
}
} catch (e) {
emit(TeacherAuthError(e.toString()));
@@ -84,9 +89,13 @@ class TeacherAuthCubit extends Cubit<TeacherAuthState> {
}) async {
emit(TeacherAuthLoading());
try {
final res = await repository.verifyOtp(phoneNumber, otp, fullName: fullName);
final res =
await repository.verifyOtp(phoneNumber, otp, fullName: fullName);
if (res['status'] == 'success') {
if ((fullName ?? '').trim().isNotEmpty && (specialization ?? '').trim().isNotEmpty && (schoolName ?? '').trim().isNotEmpty && (gradesTaught?.isNotEmpty ?? false)) {
if ((fullName ?? '').trim().isNotEmpty &&
(specialization ?? '').trim().isNotEmpty &&
(schoolName ?? '').trim().isNotEmpty &&
(gradesTaught?.isNotEmpty ?? false)) {
try {
await repository.setupProfile(
fullName: fullName!.trim(),
@@ -100,7 +109,8 @@ class TeacherAuthCubit extends Cubit<TeacherAuthState> {
final profile = await repository.getProfileStatus();
emit(TeacherAuthenticated(profile: profile));
} else {
emit(TeacherAuthError(res['message']?.toString() ?? 'رمز التحقق غير صحيح'));
emit(TeacherAuthError(
res['message']?.toString() ?? 'رمز التحقق غير صحيح'));
}
} catch (e) {
emit(TeacherAuthError(e.toString()));