Merge pull request #432 from Oloodi/408-feature-implement-paidunpaid-breaks---client-app-frontend-development
Small changes in the staff application
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
import 'package:krow_domain/krow_domain.dart' as domain;
|
import 'package:krow_domain/krow_domain.dart' as domain;
|
||||||
|
|
||||||
class StaffSession {
|
class StaffSession {
|
||||||
const StaffSession({required this.user, this.staff, this.ownerId});
|
const StaffSession({this.staff, this.ownerId});
|
||||||
|
|
||||||
final domain.User user;
|
|
||||||
final domain.Staff? staff;
|
final domain.Staff? staff;
|
||||||
final String? ownerId;
|
final String? ownerId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,7 +239,6 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
|
|||||||
);
|
);
|
||||||
StaffSessionStore.instance.setSession(
|
StaffSessionStore.instance.setSession(
|
||||||
StaffSession(
|
StaffSession(
|
||||||
user: domainUser,
|
|
||||||
staff: domainStaff,
|
staff: domainStaff,
|
||||||
ownerId: staffRecord?.ownerId,
|
ownerId: staffRecord?.ownerId,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -22,19 +22,17 @@ class ProfileSetupRepositoryImpl implements ProfileSetupRepository {
|
|||||||
final auth.User? firebaseUser = _service.auth.currentUser;
|
final auth.User? firebaseUser = _service.auth.currentUser;
|
||||||
if (firebaseUser == null) {
|
if (firebaseUser == null) {
|
||||||
throw const NotAuthenticatedException(
|
throw const NotAuthenticatedException(
|
||||||
technicalMessage: 'User not authenticated.');
|
technicalMessage: 'User not authenticated.',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final StaffSession? session = StaffSessionStore.instance.session;
|
final StaffSession? session = StaffSessionStore.instance.session;
|
||||||
final String email = session?.user.email ?? '';
|
final String email = session?.staff?.email ?? '';
|
||||||
final String? phone = firebaseUser.phoneNumber;
|
final String? phone = firebaseUser.phoneNumber;
|
||||||
|
|
||||||
final fdc.OperationResult<CreateStaffData, CreateStaffVariables> result =
|
final fdc.OperationResult<CreateStaffData, CreateStaffVariables> result =
|
||||||
await _service.connector
|
await _service.connector
|
||||||
.createStaff(
|
.createStaff(userId: firebaseUser.uid, fullName: fullName)
|
||||||
userId: firebaseUser.uid,
|
|
||||||
fullName: fullName,
|
|
||||||
)
|
|
||||||
.bio(bio)
|
.bio(bio)
|
||||||
.preferredLocations(preferredLocations)
|
.preferredLocations(preferredLocations)
|
||||||
.maxDistanceMiles(maxDistanceMiles.toInt())
|
.maxDistanceMiles(maxDistanceMiles.toInt())
|
||||||
@@ -57,7 +55,7 @@ class ProfileSetupRepositoryImpl implements ProfileSetupRepository {
|
|||||||
|
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
StaffSessionStore.instance.setSession(
|
StaffSessionStore.instance.setSession(
|
||||||
StaffSession(user: session.user, staff: staff, ownerId: session.ownerId),
|
StaffSession(staff: staff, ownerId: session.ownerId),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -76,7 +76,41 @@ class HomeRepositoryImpl
|
|||||||
@override
|
@override
|
||||||
Future<String?> getStaffName() async {
|
Future<String?> getStaffName() async {
|
||||||
final session = StaffSessionStore.instance.session;
|
final session = StaffSessionStore.instance.session;
|
||||||
return session?.staff?.name;
|
|
||||||
|
// If session data is available, return staff name immediately
|
||||||
|
if (session?.staff?.name != null) {
|
||||||
|
return session!.staff!.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If session is not initialized, attempt to fetch staff data to populate session
|
||||||
|
return await _service.run(() async {
|
||||||
|
final staffId = await _service.getStaffId();
|
||||||
|
final response = await _service.connector
|
||||||
|
.getStaffById(id: staffId)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
if (response.data.staff == null) {
|
||||||
|
throw Exception('Staff data not found for ID: $staffId');
|
||||||
|
}
|
||||||
|
|
||||||
|
final staff = response.data.staff!;
|
||||||
|
final updatedSession = StaffSession(
|
||||||
|
staff: Staff(
|
||||||
|
id: staff.id,
|
||||||
|
authProviderId: staff.userId,
|
||||||
|
name: staff.fullName,
|
||||||
|
email: staff.email ?? '',
|
||||||
|
phone: staff.phone,
|
||||||
|
status: StaffStatus.completedProfile,
|
||||||
|
address: staff.addres,
|
||||||
|
avatar: staff.photoUrl,
|
||||||
|
),
|
||||||
|
ownerId: session?.ownerId,
|
||||||
|
);
|
||||||
|
StaffSessionStore.instance.setSession(updatedSession);
|
||||||
|
|
||||||
|
return staff.fullName;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mappers specific to Home's Domain Entity 'Shift'
|
// Mappers specific to Home's Domain Entity 'Shift'
|
||||||
|
|||||||
Reference in New Issue
Block a user