chnages has been made and net salary is being displayed

This commit is contained in:
Daniah Ayad Al-sultani
2026-02-11 14:31:03 +03:00
parent 1002937045
commit a7930d19e5
23 changed files with 691 additions and 141 deletions

View File

@@ -3,9 +3,14 @@ import '../../core/error/exceptions.dart';
import '../../core/network/api_client.dart';
import '../dto/login_dto.dart';
import '../dto/login_response_dto.dart';
import '../dto/change_password_request_dto.dart';
import '../dto/change_password_response_dto.dart';
abstract class AuthRemoteDataSource {
Future<LoginResponseDto> login(LoginDto dto);
Future<ChangePasswordResponseDto> changePassword(
ChangePasswordRequestDto dto,
);
}
class AuthRemoteDataSourceImpl implements AuthRemoteDataSource {
@@ -72,4 +77,37 @@ class AuthRemoteDataSourceImpl implements AuthRemoteDataSource {
throw ServerException(message: 'خطأ غير متوقع');
}
}
@override
Future<ChangePasswordResponseDto> changePassword(
ChangePasswordRequestDto dto,
) async {
try {
final response = await apiClient.post(
'/Auth/change-password',
data: dto.toJson(),
);
if (response.statusCode == 200) {
return ChangePasswordResponseDto.fromJson(response.data);
} else {
throw ServerException(
message: response.data['message'] ?? 'فشل تغيير كلمة المرور',
statusCode: response.statusCode,
);
}
} on DioException catch (e) {
final message =
e.response?.data?['message'] ??
e.response?.data?['error'] ??
'فشل تغيير كلمة المرور';
throw ServerException(
message: message,
statusCode: e.response?.statusCode,
);
} catch (e) {
if (e is ServerException) rethrow;
throw ServerException(message: 'خطأ غير متوقع: $e');
}
}
}