done
This commit is contained in:
@@ -79,6 +79,7 @@ class AttendanceRemoteDataSourceImpl implements AttendanceRemoteDataSource {
|
|||||||
if (e is ServerException || e is NetworkException) {
|
if (e is ServerException || e is NetworkException) {
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
|
print('خطأ غير متوقع: $e');
|
||||||
throw ServerException(message: 'خطأ غير متوقع');
|
throw ServerException(message: 'خطأ غير متوقع');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,24 @@ class AttendanceResponseDto {
|
|||||||
final data = json['data'];
|
final data = json['data'];
|
||||||
|
|
||||||
return AttendanceResponseDto(
|
return AttendanceResponseDto(
|
||||||
id: data['id'],
|
id: data['id']?.toString() ?? '',
|
||||||
employeeId: data['employeeId'],
|
employeeId: data['employeeId']?.toString() ?? '',
|
||||||
login: data['login'],
|
login: _parseDateTime(data['login']),
|
||||||
logout: data['logout'],
|
logout: _parseDateTime(data['logout']),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DateTime? _parseDateTime(dynamic value) {
|
||||||
|
if (value == null) return null;
|
||||||
|
if (value is DateTime) return value;
|
||||||
|
if (value is String) {
|
||||||
|
try {
|
||||||
|
return DateTime.parse(value);
|
||||||
|
} catch (e) {
|
||||||
|
print('Error parsing date: $value - $e');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user