feat: Implement staff attire management including fetching options, user attire status, and upserting attire details.
This commit is contained in:
@@ -11,9 +11,8 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
/// Creates a new [StaffConnectorRepositoryImpl].
|
||||
///
|
||||
/// Requires a [DataConnectService] instance for backend communication.
|
||||
StaffConnectorRepositoryImpl({
|
||||
DataConnectService? service,
|
||||
}) : _service = service ?? DataConnectService.instance;
|
||||
StaffConnectorRepositoryImpl({DataConnectService? service})
|
||||
: _service = service ?? DataConnectService.instance;
|
||||
|
||||
final DataConnectService _service;
|
||||
|
||||
@@ -22,15 +21,17 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
return _service.run(() async {
|
||||
final String staffId = await _service.getStaffId();
|
||||
|
||||
final QueryResult<GetStaffProfileCompletionData,
|
||||
GetStaffProfileCompletionVariables> response =
|
||||
await _service.connector
|
||||
.getStaffProfileCompletion(id: staffId)
|
||||
.execute();
|
||||
final QueryResult<
|
||||
GetStaffProfileCompletionData,
|
||||
GetStaffProfileCompletionVariables
|
||||
>
|
||||
response = await _service.connector
|
||||
.getStaffProfileCompletion(id: staffId)
|
||||
.execute();
|
||||
|
||||
final GetStaffProfileCompletionStaff? staff = response.data.staff;
|
||||
final List<GetStaffProfileCompletionEmergencyContacts>
|
||||
emergencyContacts = response.data.emergencyContacts;
|
||||
final List<GetStaffProfileCompletionEmergencyContacts> emergencyContacts =
|
||||
response.data.emergencyContacts;
|
||||
final List<GetStaffProfileCompletionTaxForms> taxForms =
|
||||
response.data.taxForms;
|
||||
|
||||
@@ -43,11 +44,13 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
return _service.run(() async {
|
||||
final String staffId = await _service.getStaffId();
|
||||
|
||||
final QueryResult<GetStaffPersonalInfoCompletionData,
|
||||
GetStaffPersonalInfoCompletionVariables> response =
|
||||
await _service.connector
|
||||
.getStaffPersonalInfoCompletion(id: staffId)
|
||||
.execute();
|
||||
final QueryResult<
|
||||
GetStaffPersonalInfoCompletionData,
|
||||
GetStaffPersonalInfoCompletionVariables
|
||||
>
|
||||
response = await _service.connector
|
||||
.getStaffPersonalInfoCompletion(id: staffId)
|
||||
.execute();
|
||||
|
||||
final GetStaffPersonalInfoCompletionStaff? staff = response.data.staff;
|
||||
|
||||
@@ -60,11 +63,13 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
return _service.run(() async {
|
||||
final String staffId = await _service.getStaffId();
|
||||
|
||||
final QueryResult<GetStaffEmergencyProfileCompletionData,
|
||||
GetStaffEmergencyProfileCompletionVariables> response =
|
||||
await _service.connector
|
||||
.getStaffEmergencyProfileCompletion(id: staffId)
|
||||
.execute();
|
||||
final QueryResult<
|
||||
GetStaffEmergencyProfileCompletionData,
|
||||
GetStaffEmergencyProfileCompletionVariables
|
||||
>
|
||||
response = await _service.connector
|
||||
.getStaffEmergencyProfileCompletion(id: staffId)
|
||||
.execute();
|
||||
|
||||
return response.data.emergencyContacts.isNotEmpty;
|
||||
});
|
||||
@@ -75,11 +80,13 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
return _service.run(() async {
|
||||
final String staffId = await _service.getStaffId();
|
||||
|
||||
final QueryResult<GetStaffExperienceProfileCompletionData,
|
||||
GetStaffExperienceProfileCompletionVariables> response =
|
||||
await _service.connector
|
||||
.getStaffExperienceProfileCompletion(id: staffId)
|
||||
.execute();
|
||||
final QueryResult<
|
||||
GetStaffExperienceProfileCompletionData,
|
||||
GetStaffExperienceProfileCompletionVariables
|
||||
>
|
||||
response = await _service.connector
|
||||
.getStaffExperienceProfileCompletion(id: staffId)
|
||||
.execute();
|
||||
|
||||
final GetStaffExperienceProfileCompletionStaff? staff =
|
||||
response.data.staff;
|
||||
@@ -93,11 +100,13 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
return _service.run(() async {
|
||||
final String staffId = await _service.getStaffId();
|
||||
|
||||
final QueryResult<GetStaffTaxFormsProfileCompletionData,
|
||||
GetStaffTaxFormsProfileCompletionVariables> response =
|
||||
await _service.connector
|
||||
.getStaffTaxFormsProfileCompletion(id: staffId)
|
||||
.execute();
|
||||
final QueryResult<
|
||||
GetStaffTaxFormsProfileCompletionData,
|
||||
GetStaffTaxFormsProfileCompletionVariables
|
||||
>
|
||||
response = await _service.connector
|
||||
.getStaffTaxFormsProfileCompletion(id: staffId)
|
||||
.execute();
|
||||
|
||||
return response.data.taxForms.isNotEmpty;
|
||||
});
|
||||
@@ -135,9 +144,7 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
final bool hasExperience =
|
||||
(skills is List && skills.isNotEmpty) ||
|
||||
(industries is List && industries.isNotEmpty);
|
||||
return emergencyContacts.isNotEmpty &&
|
||||
taxForms.isNotEmpty &&
|
||||
hasExperience;
|
||||
return emergencyContacts.isNotEmpty && taxForms.isNotEmpty && hasExperience;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -146,14 +153,10 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
final String staffId = await _service.getStaffId();
|
||||
|
||||
final QueryResult<GetStaffByIdData, GetStaffByIdVariables> response =
|
||||
await _service.connector
|
||||
.getStaffById(id: staffId)
|
||||
.execute();
|
||||
await _service.connector.getStaffById(id: staffId).execute();
|
||||
|
||||
if (response.data.staff == null) {
|
||||
throw const ServerException(
|
||||
technicalMessage: 'Staff not found',
|
||||
);
|
||||
throw const ServerException(technicalMessage: 'Staff not found');
|
||||
}
|
||||
|
||||
final GetStaffByIdStaff rawStaff = response.data.staff!;
|
||||
@@ -183,11 +186,13 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
return _service.run(() async {
|
||||
final String staffId = await _service.getStaffId();
|
||||
|
||||
final QueryResult<ListBenefitsDataByStaffIdData,
|
||||
ListBenefitsDataByStaffIdVariables> response =
|
||||
await _service.connector
|
||||
.listBenefitsDataByStaffId(staffId: staffId)
|
||||
.execute();
|
||||
final QueryResult<
|
||||
ListBenefitsDataByStaffIdData,
|
||||
ListBenefitsDataByStaffIdVariables
|
||||
>
|
||||
response = await _service.connector
|
||||
.listBenefitsDataByStaffId(staffId: staffId)
|
||||
.execute();
|
||||
|
||||
return response.data.benefitsDatas.map((data) {
|
||||
final plan = data.vendorBenefitPlan;
|
||||
@@ -200,6 +205,56 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<AttireItem>> getAttireOptions() async {
|
||||
return _service.run(() async {
|
||||
final String staffId = await _service.getStaffId();
|
||||
|
||||
// Fetch all options
|
||||
final QueryResult<ListAttireOptionsData, void> optionsResponse =
|
||||
await _service.connector.listAttireOptions().execute();
|
||||
|
||||
// Fetch user's attire status
|
||||
final QueryResult<GetStaffAttireData, GetStaffAttireVariables>
|
||||
attiresResponse = await _service.connector
|
||||
.getStaffAttire(staffId: staffId)
|
||||
.execute();
|
||||
|
||||
final Map<String, GetStaffAttireStaffAttires> attireMap = {
|
||||
for (final item in attiresResponse.data.staffAttires)
|
||||
item.attireOptionId: item,
|
||||
};
|
||||
|
||||
return optionsResponse.data.attireOptions.map((e) {
|
||||
final GetStaffAttireStaffAttires? userAttire = attireMap[e.id];
|
||||
return AttireItem(
|
||||
id: e.itemId,
|
||||
label: e.label,
|
||||
description: e.description,
|
||||
imageUrl: e.imageUrl,
|
||||
isMandatory: e.isMandatory ?? false,
|
||||
verificationStatus: userAttire?.verificationStatus?.stringValue,
|
||||
photoUrl: userAttire?.verificationPhotoUrl,
|
||||
);
|
||||
}).toList();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> upsertStaffAttire({
|
||||
required String attireOptionId,
|
||||
required String photoUrl,
|
||||
}) async {
|
||||
await _service.run(() async {
|
||||
final String staffId = await _service.getStaffId();
|
||||
|
||||
await _service.connector
|
||||
.upsertStaffAttire(staffId: staffId, attireOptionId: attireOptionId)
|
||||
.verificationPhotoUrl(photoUrl)
|
||||
.execute();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> signOut() async {
|
||||
try {
|
||||
@@ -210,4 +265,3 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,17 @@ abstract interface class StaffConnectorRepository {
|
||||
/// Returns a list of [Benefit] entities.
|
||||
Future<List<Benefit>> getBenefits();
|
||||
|
||||
/// Fetches the attire options for the current authenticated user.
|
||||
///
|
||||
/// Returns a list of [AttireItem] entities.
|
||||
Future<List<AttireItem>> getAttireOptions();
|
||||
|
||||
/// Upserts staff attire photo information.
|
||||
Future<void> upsertStaffAttire({
|
||||
required String attireOptionId,
|
||||
required String photoUrl,
|
||||
});
|
||||
|
||||
/// Signs out the current user.
|
||||
///
|
||||
/// Clears the user's session and authentication state.
|
||||
|
||||
Reference in New Issue
Block a user