chnages has been made
This commit is contained in:
@@ -13,11 +13,13 @@ abstract class AttendanceRemoteDataSource {
|
||||
Future<AttendanceResponseDto> login({
|
||||
required String employeeId,
|
||||
required File faceImage,
|
||||
bool localAuth = false,
|
||||
});
|
||||
|
||||
Future<AttendanceResponseDto> logout({
|
||||
required String employeeId,
|
||||
required File faceImage,
|
||||
bool localAuth = false,
|
||||
});
|
||||
|
||||
Future<List<AttendanceRecordDto>> getAttendanceRecords({
|
||||
@@ -43,11 +45,13 @@ class AttendanceRemoteDataSourceImpl implements AttendanceRemoteDataSource {
|
||||
Future<AttendanceResponseDto> login({
|
||||
required String employeeId,
|
||||
required File faceImage,
|
||||
bool localAuth = false,
|
||||
}) async {
|
||||
try {
|
||||
final formData = FormData.fromMap({
|
||||
'EmployeeId': employeeId,
|
||||
'FaceImage': await MultipartFile.fromFile(faceImage.path),
|
||||
'IsAuth': localAuth.toString(),
|
||||
});
|
||||
|
||||
final response = await apiClient.post(
|
||||
@@ -107,11 +111,13 @@ class AttendanceRemoteDataSourceImpl implements AttendanceRemoteDataSource {
|
||||
Future<AttendanceResponseDto> logout({
|
||||
required String employeeId,
|
||||
required File faceImage,
|
||||
bool localAuth = false,
|
||||
}) async {
|
||||
try {
|
||||
final formData = FormData.fromMap({
|
||||
'EmployeeId': employeeId,
|
||||
'FaceImage': await MultipartFile.fromFile(faceImage.path),
|
||||
'IsAuth': localAuth.toString(),
|
||||
});
|
||||
|
||||
final response = await apiClient.post(
|
||||
|
||||
49
lib/data/datasources/theme_remote_data_source.dart
Normal file
49
lib/data/datasources/theme_remote_data_source.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../../core/error/exceptions.dart';
|
||||
import '../../core/network/api_client.dart';
|
||||
import '../dto/theme_response_dto.dart';
|
||||
|
||||
abstract class ThemeRemoteDataSource {
|
||||
Future<ThemeDataDto> getTheme();
|
||||
}
|
||||
|
||||
class ThemeRemoteDataSourceImpl implements ThemeRemoteDataSource {
|
||||
final ApiClient apiClient;
|
||||
|
||||
ThemeRemoteDataSourceImpl({required this.apiClient});
|
||||
|
||||
@override
|
||||
Future<ThemeDataDto> getTheme() async {
|
||||
try {
|
||||
debugPrint('[ThemeDataSource] Calling GET /Theme (with auth)...');
|
||||
|
||||
final res = await apiClient.get('/Theme'); // ✅ no custom headers
|
||||
|
||||
debugPrint('[ThemeDataSource] Status: ${res.statusCode}');
|
||||
debugPrint('[ThemeDataSource] Data: ${res.data}');
|
||||
|
||||
if (res.statusCode == 200) {
|
||||
final dto = ThemeResponseDto.fromJson(
|
||||
Map<String, dynamic>.from(res.data),
|
||||
);
|
||||
|
||||
if (dto.isSuccess && dto.data != null) {
|
||||
debugPrint('[ThemeDataSource] ✅ logo = ${dto.data!.logo}');
|
||||
return dto.data!;
|
||||
}
|
||||
|
||||
throw ServerException(message: dto.message ?? 'Theme request failed');
|
||||
}
|
||||
|
||||
throw ServerException(
|
||||
message: 'Theme request failed (code ${res.statusCode})',
|
||||
);
|
||||
} on ServerException {
|
||||
rethrow;
|
||||
} catch (e, stack) {
|
||||
debugPrint('[ThemeDataSource] ❌ Exception: $e');
|
||||
debugPrint('[ThemeDataSource] ❌ Stack: $stack');
|
||||
throw ServerException(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user