feat: Implement attire options, documents, and certificates completion use cases in staff profile
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
import 'package:staff_home/src/presentation/blocs/home_cubit.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
/// Page displaying a detailed overview of the worker's benefits.
|
||||
class BenefitsOverviewPage extends StatelessWidget {
|
||||
|
||||
@@ -19,6 +19,9 @@ class ProfileCubit extends Cubit<ProfileState>
|
||||
this._getEmergencyContactsCompletionUseCase,
|
||||
this._getExperienceCompletionUseCase,
|
||||
this._getTaxFormsCompletionUseCase,
|
||||
this._getAttireOptionsCompletionUseCase,
|
||||
this._getStaffDocumentsCompletionUseCase,
|
||||
this._getStaffCertificatesCompletionUseCase,
|
||||
) : super(const ProfileState());
|
||||
final GetStaffProfileUseCase _getProfileUseCase;
|
||||
final SignOutStaffUseCase _signOutUseCase;
|
||||
@@ -26,6 +29,9 @@ class ProfileCubit extends Cubit<ProfileState>
|
||||
final GetEmergencyContactsCompletionUseCase _getEmergencyContactsCompletionUseCase;
|
||||
final GetExperienceCompletionUseCase _getExperienceCompletionUseCase;
|
||||
final GetTaxFormsCompletionUseCase _getTaxFormsCompletionUseCase;
|
||||
final GetAttireOptionsCompletionUseCase _getAttireOptionsCompletionUseCase;
|
||||
final GetStaffDocumentsCompletionUseCase _getStaffDocumentsCompletionUseCase;
|
||||
final GetStaffCertificatesCompletionUseCase _getStaffCertificatesCompletionUseCase;
|
||||
|
||||
/// Loads the staff member's profile.
|
||||
///
|
||||
@@ -130,5 +136,47 @@ class ProfileCubit extends Cubit<ProfileState>
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Loads attire options completion status.
|
||||
Future<void> loadAttireCompletion() async {
|
||||
await handleError(
|
||||
emit: emit,
|
||||
action: () async {
|
||||
final bool? isComplete = await _getAttireOptionsCompletionUseCase();
|
||||
emit(state.copyWith(attireComplete: isComplete));
|
||||
},
|
||||
onError: (String _) {
|
||||
return state.copyWith(attireComplete: false);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Loads documents completion status.
|
||||
Future<void> loadDocumentsCompletion() async {
|
||||
await handleError(
|
||||
emit: emit,
|
||||
action: () async {
|
||||
final bool? isComplete = await _getStaffDocumentsCompletionUseCase();
|
||||
emit(state.copyWith(documentsComplete: isComplete));
|
||||
},
|
||||
onError: (String _) {
|
||||
return state.copyWith(documentsComplete: false);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Loads certificates completion status.
|
||||
Future<void> loadCertificatesCompletion() async {
|
||||
await handleError(
|
||||
emit: emit,
|
||||
action: () async {
|
||||
final bool? isComplete = await _getStaffCertificatesCompletionUseCase();
|
||||
emit(state.copyWith(certificatesComplete: isComplete));
|
||||
},
|
||||
onError: (String _) {
|
||||
return state.copyWith(certificatesComplete: false);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ class ProfileState extends Equatable {
|
||||
this.emergencyContactsComplete,
|
||||
this.experienceComplete,
|
||||
this.taxFormsComplete,
|
||||
this.attireComplete,
|
||||
this.documentsComplete,
|
||||
this.certificatesComplete,
|
||||
});
|
||||
/// Current status of the profile feature
|
||||
final ProfileStatus status;
|
||||
@@ -54,6 +57,15 @@ class ProfileState extends Equatable {
|
||||
|
||||
/// Whether tax forms are complete
|
||||
final bool? taxFormsComplete;
|
||||
|
||||
/// Whether attire options are complete
|
||||
final bool? attireComplete;
|
||||
|
||||
/// Whether documents are complete
|
||||
final bool? documentsComplete;
|
||||
|
||||
/// Whether certificates are complete
|
||||
final bool? certificatesComplete;
|
||||
|
||||
/// Creates a copy of this state with updated values.
|
||||
ProfileState copyWith({
|
||||
@@ -64,6 +76,9 @@ class ProfileState extends Equatable {
|
||||
bool? emergencyContactsComplete,
|
||||
bool? experienceComplete,
|
||||
bool? taxFormsComplete,
|
||||
bool? attireComplete,
|
||||
bool? documentsComplete,
|
||||
bool? certificatesComplete,
|
||||
}) {
|
||||
return ProfileState(
|
||||
status: status ?? this.status,
|
||||
@@ -73,6 +88,9 @@ class ProfileState extends Equatable {
|
||||
emergencyContactsComplete: emergencyContactsComplete ?? this.emergencyContactsComplete,
|
||||
experienceComplete: experienceComplete ?? this.experienceComplete,
|
||||
taxFormsComplete: taxFormsComplete ?? this.taxFormsComplete,
|
||||
attireComplete: attireComplete ?? this.attireComplete,
|
||||
documentsComplete: documentsComplete ?? this.documentsComplete,
|
||||
certificatesComplete: certificatesComplete ?? this.certificatesComplete,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,5 +103,8 @@ class ProfileState extends Equatable {
|
||||
emergencyContactsComplete,
|
||||
experienceComplete,
|
||||
taxFormsComplete,
|
||||
attireComplete,
|
||||
documentsComplete,
|
||||
certificatesComplete,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ class StaffProfilePage extends StatelessWidget {
|
||||
cubit.loadEmergencyContactsCompletion();
|
||||
cubit.loadExperienceCompletion();
|
||||
cubit.loadTaxFormsCompletion();
|
||||
cubit.loadAttireCompletion();
|
||||
cubit.loadDocumentsCompletion();
|
||||
cubit.loadCertificatesCompletion();
|
||||
}
|
||||
|
||||
if (state.status == ProfileStatus.signedOut) {
|
||||
|
||||
@@ -43,11 +43,13 @@ class ComplianceSection extends StatelessWidget {
|
||||
ProfileMenuItem(
|
||||
icon: UiIcons.file,
|
||||
label: i18n.menu_items.documents,
|
||||
completed: state.documentsComplete,
|
||||
onTap: () => Modular.to.toDocuments(),
|
||||
),
|
||||
ProfileMenuItem(
|
||||
icon: UiIcons.certificate,
|
||||
label: i18n.menu_items.certificates,
|
||||
completed: state.certificatesComplete,
|
||||
onTap: () => Modular.to.toCertificates(),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -54,6 +54,7 @@ class OnboardingSection extends StatelessWidget {
|
||||
ProfileMenuItem(
|
||||
icon: UiIcons.shirt,
|
||||
label: i18n.menu_items.attire,
|
||||
completed: state.attireComplete,
|
||||
onTap: () => Modular.to.toAttire(),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -50,6 +50,21 @@ class StaffProfileModule extends Module {
|
||||
repository: i.get<StaffConnectorRepository>(),
|
||||
),
|
||||
);
|
||||
i.addLazySingleton<GetAttireOptionsCompletionUseCase>(
|
||||
() => GetAttireOptionsCompletionUseCase(
|
||||
repository: i.get<StaffConnectorRepository>(),
|
||||
),
|
||||
);
|
||||
i.addLazySingleton<GetStaffDocumentsCompletionUseCase>(
|
||||
() => GetStaffDocumentsCompletionUseCase(
|
||||
repository: i.get<StaffConnectorRepository>(),
|
||||
),
|
||||
);
|
||||
i.addLazySingleton<GetStaffCertificatesCompletionUseCase>(
|
||||
() => GetStaffCertificatesCompletionUseCase(
|
||||
repository: i.get<StaffConnectorRepository>(),
|
||||
),
|
||||
);
|
||||
|
||||
// Presentation layer - Cubit as singleton to avoid recreation
|
||||
// BlocProvider will use this same instance, preventing state emission after close
|
||||
@@ -61,6 +76,9 @@ class StaffProfileModule extends Module {
|
||||
i.get<GetEmergencyContactsCompletionUseCase>(),
|
||||
i.get<GetExperienceCompletionUseCase>(),
|
||||
i.get<GetTaxFormsCompletionUseCase>(),
|
||||
i.get<GetAttireOptionsCompletionUseCase>(),
|
||||
i.get<GetStaffDocumentsCompletionUseCase>(),
|
||||
i.get<GetStaffCertificatesCompletionUseCase>(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user