the user name of the employee is being displayed

This commit is contained in:
Daniah Ayad Al-sultani
2026-02-17 16:51:13 +03:00
parent bb6f3931ce
commit 5117fbdabe
4 changed files with 63 additions and 8 deletions

View File

@@ -6,12 +6,15 @@ abstract class UserLocalDataSource {
Future<void> clearCache();
Future<void> cacheEmployeeId(String id);
Future<String?> getCachedEmployeeId();
Future<void> cacheFullName(String name);
Future<String?> getCachedFullName();
}
class UserLocalDataSourceImpl implements UserLocalDataSource {
final SharedPreferences sharedPreferences;
static const String _tokenKey = 'user_token';
static const String _employeeIdKey = 'employee_id';
static const String _fullNameKey = 'full_name';
UserLocalDataSourceImpl({required this.sharedPreferences});
@@ -26,9 +29,13 @@ class UserLocalDataSourceImpl implements UserLocalDataSource {
}
@override
Future<void> clearCache() async {
await sharedPreferences.remove(_tokenKey);
await sharedPreferences.remove(_employeeIdKey);
Future<void> cacheFullName(String name) async {
await sharedPreferences.setString(_fullNameKey, name);
}
@override
Future<String?> getCachedFullName() async {
return sharedPreferences.getString(_fullNameKey);
}
@override
@@ -40,4 +47,11 @@ class UserLocalDataSourceImpl implements UserLocalDataSource {
Future<String?> getCachedEmployeeId() async {
return sharedPreferences.getString(_employeeIdKey);
}
@override
Future<void> clearCache() async {
await sharedPreferences.remove(_tokenKey);
await sharedPreferences.remove(_employeeIdKey);
await sharedPreferences.remove(_fullNameKey);
}
}

View File

@@ -41,6 +41,9 @@ class AuthRepositoryImpl implements AuthRepository {
if (responseDto.data?.employeeId != null) {
print("AUTH_REPO: Caching EmployeeId: ${responseDto.data!.employeeId}");
await localDataSource.cacheEmployeeId(responseDto.data!.employeeId!);
if (responseDto.data!.fullName != null) {
await localDataSource.cacheFullName(responseDto.data!.fullName!);
}
} else {
print("AUTH_REPO: EmployeeId is NULL in response!");
}