Revert "Merge pull request #373 from Oloodi/368-sub-task-provision-and-copy-validation-database-instance"
This reverts commit8deb293158, reversing changes made tofbab4f729d.
This commit is contained in:
@@ -31,11 +31,9 @@ extension HomeNavigator on IModularNavigator {
|
||||
/// Optionally provide a [tab] query param (e.g. `find`).
|
||||
void pushShifts({String? tab}) {
|
||||
if (tab == null) {
|
||||
navigate('/worker-main/shifts');
|
||||
pushNamed('/worker-main/shifts');
|
||||
} else {
|
||||
navigate('/worker-main/shifts', arguments: <String, dynamic>{
|
||||
'initialTab': tab,
|
||||
});
|
||||
pushNamed('/worker-main/shifts?tab=$tab');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,8 @@ class WorkerHomePage extends StatelessWidget {
|
||||
EmptyStateWidget(
|
||||
message: emptyI18n.no_shifts_today,
|
||||
actionLink: emptyI18n.find_shifts_cta,
|
||||
onAction: () => Modular.to.pushShifts(tab: 'find'),
|
||||
onAction: () =>
|
||||
Modular.to.pushShifts(tab: 'find'),
|
||||
)
|
||||
else
|
||||
Column(
|
||||
|
||||
@@ -31,7 +31,6 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
on<LoadShiftsEvent>(_onLoadShifts);
|
||||
on<LoadHistoryShiftsEvent>(_onLoadHistoryShifts);
|
||||
on<LoadAvailableShiftsEvent>(_onLoadAvailableShifts);
|
||||
on<LoadFindFirstEvent>(_onLoadFindFirst);
|
||||
on<LoadShiftsForRangeEvent>(_onLoadShiftsForRange);
|
||||
on<FilterAvailableShiftsEvent>(_onFilterAvailableShifts);
|
||||
}
|
||||
@@ -63,7 +62,6 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
availableLoaded: false,
|
||||
historyLoading: false,
|
||||
historyLoaded: false,
|
||||
myShiftsLoaded: true,
|
||||
searchQuery: '',
|
||||
jobType: 'all',
|
||||
));
|
||||
@@ -84,7 +82,6 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
try {
|
||||
final historyResult = await getHistoryShifts();
|
||||
emit(currentState.copyWith(
|
||||
myShiftsLoaded: true,
|
||||
historyShifts: historyResult,
|
||||
historyLoading: false,
|
||||
historyLoaded: true,
|
||||
@@ -116,67 +113,6 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onLoadFindFirst(
|
||||
LoadFindFirstEvent event,
|
||||
Emitter<ShiftsState> emit,
|
||||
) async {
|
||||
if (state is! ShiftsLoaded) {
|
||||
emit(const ShiftsLoaded(
|
||||
myShifts: [],
|
||||
pendingShifts: [],
|
||||
cancelledShifts: [],
|
||||
availableShifts: [],
|
||||
historyShifts: [],
|
||||
availableLoading: false,
|
||||
availableLoaded: false,
|
||||
historyLoading: false,
|
||||
historyLoaded: false,
|
||||
myShiftsLoaded: false,
|
||||
searchQuery: '',
|
||||
jobType: 'all',
|
||||
));
|
||||
}
|
||||
|
||||
final currentState =
|
||||
state is ShiftsLoaded ? state as ShiftsLoaded : null;
|
||||
if (currentState != null && currentState.availableLoaded) return;
|
||||
|
||||
if (currentState != null) {
|
||||
emit(currentState.copyWith(availableLoading: true));
|
||||
}
|
||||
|
||||
try {
|
||||
final availableResult =
|
||||
await getAvailableShifts(const GetAvailableShiftsArguments());
|
||||
final loadedState = state is ShiftsLoaded
|
||||
? state as ShiftsLoaded
|
||||
: const ShiftsLoaded(
|
||||
myShifts: [],
|
||||
pendingShifts: [],
|
||||
cancelledShifts: [],
|
||||
availableShifts: [],
|
||||
historyShifts: [],
|
||||
availableLoading: true,
|
||||
availableLoaded: false,
|
||||
historyLoading: false,
|
||||
historyLoaded: false,
|
||||
myShiftsLoaded: false,
|
||||
searchQuery: '',
|
||||
jobType: 'all',
|
||||
);
|
||||
emit(loadedState.copyWith(
|
||||
availableShifts: _filterPastShifts(availableResult),
|
||||
availableLoading: false,
|
||||
availableLoaded: true,
|
||||
));
|
||||
} catch (_) {
|
||||
if (state is ShiftsLoaded) {
|
||||
final current = state as ShiftsLoaded;
|
||||
emit(current.copyWith(availableLoading: false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onLoadShiftsForRange(
|
||||
LoadShiftsForRangeEvent event,
|
||||
Emitter<ShiftsState> emit,
|
||||
@@ -188,10 +124,7 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
|
||||
if (state is ShiftsLoaded) {
|
||||
final currentState = state as ShiftsLoaded;
|
||||
emit(currentState.copyWith(
|
||||
myShifts: myShiftsResult,
|
||||
myShiftsLoaded: true,
|
||||
));
|
||||
emit(currentState.copyWith(myShifts: myShiftsResult));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -205,7 +138,6 @@ class ShiftsBloc extends Bloc<ShiftsEvent, ShiftsState> {
|
||||
availableLoaded: false,
|
||||
historyLoading: false,
|
||||
historyLoaded: false,
|
||||
myShiftsLoaded: true,
|
||||
searchQuery: '',
|
||||
jobType: 'all',
|
||||
));
|
||||
|
||||
@@ -14,8 +14,6 @@ class LoadHistoryShiftsEvent extends ShiftsEvent {}
|
||||
|
||||
class LoadAvailableShiftsEvent extends ShiftsEvent {}
|
||||
|
||||
class LoadFindFirstEvent extends ShiftsEvent {}
|
||||
|
||||
class LoadShiftsForRangeEvent extends ShiftsEvent {
|
||||
final DateTime start;
|
||||
final DateTime end;
|
||||
|
||||
@@ -22,7 +22,6 @@ class ShiftsLoaded extends ShiftsState {
|
||||
final bool availableLoaded;
|
||||
final bool historyLoading;
|
||||
final bool historyLoaded;
|
||||
final bool myShiftsLoaded;
|
||||
final String searchQuery;
|
||||
final String jobType;
|
||||
|
||||
@@ -36,7 +35,6 @@ class ShiftsLoaded extends ShiftsState {
|
||||
required this.availableLoaded,
|
||||
required this.historyLoading,
|
||||
required this.historyLoaded,
|
||||
required this.myShiftsLoaded,
|
||||
required this.searchQuery,
|
||||
required this.jobType,
|
||||
});
|
||||
@@ -51,7 +49,6 @@ class ShiftsLoaded extends ShiftsState {
|
||||
bool? availableLoaded,
|
||||
bool? historyLoading,
|
||||
bool? historyLoaded,
|
||||
bool? myShiftsLoaded,
|
||||
String? searchQuery,
|
||||
String? jobType,
|
||||
}) {
|
||||
@@ -65,7 +62,6 @@ class ShiftsLoaded extends ShiftsState {
|
||||
availableLoaded: availableLoaded ?? this.availableLoaded,
|
||||
historyLoading: historyLoading ?? this.historyLoading,
|
||||
historyLoaded: historyLoaded ?? this.historyLoaded,
|
||||
myShiftsLoaded: myShiftsLoaded ?? this.myShiftsLoaded,
|
||||
searchQuery: searchQuery ?? this.searchQuery,
|
||||
jobType: jobType ?? this.jobType,
|
||||
);
|
||||
@@ -82,7 +78,6 @@ class ShiftsLoaded extends ShiftsState {
|
||||
availableLoaded,
|
||||
historyLoading,
|
||||
historyLoaded,
|
||||
myShiftsLoaded,
|
||||
searchQuery,
|
||||
jobType,
|
||||
];
|
||||
|
||||
@@ -21,7 +21,6 @@ class ShiftsPage extends StatefulWidget {
|
||||
class _ShiftsPageState extends State<ShiftsPage> {
|
||||
late String _activeTab;
|
||||
DateTime? _selectedDate;
|
||||
bool _prioritizeFind = false;
|
||||
final ShiftsBloc _bloc = Modular.get<ShiftsBloc>();
|
||||
|
||||
@override
|
||||
@@ -29,22 +28,12 @@ class _ShiftsPageState extends State<ShiftsPage> {
|
||||
super.initState();
|
||||
_activeTab = widget.initialTab ?? 'myshifts';
|
||||
_selectedDate = widget.selectedDate;
|
||||
print('ShiftsPage init: initialTab=$_activeTab');
|
||||
_prioritizeFind = widget.initialTab == 'find';
|
||||
if (_prioritizeFind) {
|
||||
_bloc.add(LoadFindFirstEvent());
|
||||
} else {
|
||||
_bloc.add(LoadShiftsEvent());
|
||||
}
|
||||
_bloc.add(LoadShiftsEvent());
|
||||
if (_activeTab == 'history') {
|
||||
print('ShiftsPage init: loading history tab');
|
||||
_bloc.add(LoadHistoryShiftsEvent());
|
||||
}
|
||||
if (_activeTab == 'find') {
|
||||
print('ShiftsPage init: entering find tab (not loaded yet)');
|
||||
if (!_prioritizeFind) {
|
||||
_bloc.add(LoadAvailableShiftsEvent());
|
||||
}
|
||||
_bloc.add(LoadAvailableShiftsEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +43,6 @@ class _ShiftsPageState extends State<ShiftsPage> {
|
||||
if (widget.initialTab != null && widget.initialTab != _activeTab) {
|
||||
setState(() {
|
||||
_activeTab = widget.initialTab!;
|
||||
_prioritizeFind = widget.initialTab == 'find';
|
||||
});
|
||||
}
|
||||
if (widget.selectedDate != null && widget.selectedDate != _selectedDate) {
|
||||
@@ -98,10 +86,6 @@ class _ShiftsPageState extends State<ShiftsPage> {
|
||||
final bool historyLoaded = (state is ShiftsLoaded)
|
||||
? state.historyLoaded
|
||||
: false;
|
||||
final bool myShiftsLoaded = (state is ShiftsLoaded)
|
||||
? state.myShiftsLoaded
|
||||
: false;
|
||||
final bool blockTabsForFind = _prioritizeFind && !availableLoaded;
|
||||
|
||||
// Note: "filteredJobs" logic moved to FindShiftsTab
|
||||
// Note: Calendar logic moved to MyShiftsTab
|
||||
@@ -140,8 +124,7 @@ class _ShiftsPageState extends State<ShiftsPage> {
|
||||
"My Shifts",
|
||||
UiIcons.calendar,
|
||||
myShifts.length,
|
||||
showCount: myShiftsLoaded,
|
||||
enabled: !blockTabsForFind,
|
||||
enabled: true,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildTab(
|
||||
@@ -160,7 +143,7 @@ class _ShiftsPageState extends State<ShiftsPage> {
|
||||
UiIcons.clock,
|
||||
historyShifts.length,
|
||||
showCount: historyLoaded,
|
||||
enabled: !blockTabsForFind && baseLoaded,
|
||||
enabled: baseLoaded,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -22,12 +22,6 @@ class _FindShiftsTabState extends State<FindShiftsTab> {
|
||||
String _searchQuery = '';
|
||||
String _jobType = 'all';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
print('FindShiftsTab init: tab entered, data pending');
|
||||
}
|
||||
|
||||
Widget _buildFilterTab(String id, String label) {
|
||||
final isSelected = _jobType == id;
|
||||
return GestureDetector(
|
||||
|
||||
Reference in New Issue
Block a user