feat: Refactor profile completion use cases and update related imports in HomeCubit and StaffHomeModule
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
|
||||
import 'package:staff_home/src/domain/usecases/get_home_shifts.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
import 'package:staff_home/src/domain/repositories/home_repository.dart';
|
||||
import 'package:staff_home/src/domain/usecases/get_home_shifts.dart';
|
||||
|
||||
part 'home_state.dart';
|
||||
|
||||
@@ -14,18 +13,18 @@ class HomeCubit extends Cubit<HomeState> with BlocErrorHandler<HomeState> {
|
||||
final GetHomeShifts _getHomeShifts;
|
||||
final HomeRepository _repository;
|
||||
|
||||
/// Use case that checks whether the staff member's personal info is complete.
|
||||
/// Use case that checks whether the staff member's profile is complete.
|
||||
///
|
||||
/// Used to determine whether profile-gated features (such as shift browsing)
|
||||
/// should be enabled on the home screen.
|
||||
final GetPersonalInfoCompletionUseCase _getPersonalInfoCompletion;
|
||||
final GetProfileCompletionUseCase _getProfileCompletion;
|
||||
|
||||
HomeCubit({
|
||||
required HomeRepository repository,
|
||||
required GetPersonalInfoCompletionUseCase getPersonalInfoCompletion,
|
||||
required GetProfileCompletionUseCase getProfileCompletion,
|
||||
}) : _getHomeShifts = GetHomeShifts(repository),
|
||||
_repository = repository,
|
||||
_getPersonalInfoCompletion = getPersonalInfoCompletion,
|
||||
_getProfileCompletion = getProfileCompletion,
|
||||
super(const HomeState.initial());
|
||||
|
||||
Future<void> loadShifts() async {
|
||||
@@ -37,7 +36,7 @@ class HomeCubit extends Cubit<HomeState> with BlocErrorHandler<HomeState> {
|
||||
// Fetch shifts, name, benefits and profile completion status concurrently
|
||||
final results = await Future.wait([
|
||||
_getHomeShifts.call(),
|
||||
_getPersonalInfoCompletion.call(),
|
||||
_getProfileCompletion.call(),
|
||||
_repository.getBenefits(),
|
||||
_repository.getStaffName(),
|
||||
]);
|
||||
|
||||
@@ -24,9 +24,9 @@ class StaffHomeModule extends Module {
|
||||
() => StaffConnectorRepositoryImpl(),
|
||||
);
|
||||
|
||||
// Use case for checking personal info profile completion
|
||||
i.addLazySingleton<GetPersonalInfoCompletionUseCase>(
|
||||
() => GetPersonalInfoCompletionUseCase(
|
||||
// Use case for checking profile completion
|
||||
i.addLazySingleton<GetProfileCompletionUseCase>(
|
||||
() => GetProfileCompletionUseCase(
|
||||
repository: i.get<StaffConnectorRepository>(),
|
||||
),
|
||||
);
|
||||
@@ -35,7 +35,7 @@ class StaffHomeModule extends Module {
|
||||
i.addSingleton(
|
||||
() => HomeCubit(
|
||||
repository: i.get<HomeRepository>(),
|
||||
getPersonalInfoCompletion: i.get<GetPersonalInfoCompletionUseCase>(),
|
||||
getProfileCompletion: i.get<GetProfileCompletionUseCase>(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ 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:geolocator/geolocator.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
|
||||
import '../../blocs/shifts/shifts_bloc.dart';
|
||||
@@ -315,7 +317,9 @@ class _FindShiftsTabState extends State<FindShiftsTab> {
|
||||
children: [
|
||||
// Incomplete profile banner
|
||||
if (!widget.profileComplete) ...[
|
||||
Container(
|
||||
GestureDetector(
|
||||
onTap: () => Modular.to.toProfile(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(UiConstants.space4),
|
||||
child: UiNoticeBanner(
|
||||
icon: UiIcons.sparkles,
|
||||
@@ -331,6 +335,7 @@ class _FindShiftsTabState extends State<FindShiftsTab> {
|
||||
.incomplete_profile_banner_message,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
// Search and Filters
|
||||
Container(
|
||||
|
||||
Reference in New Issue
Block a user