feat: implement staff availability, clock-in, payments and fix UI navigation

This commit is contained in:
Suriya
2026-01-30 21:46:44 +05:30
parent 56aab9e1f6
commit ac7874c634
55 changed files with 1373 additions and 463 deletions

View File

@@ -16,16 +16,15 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
int newIndex = state.currentIndex;
// Detect which tab is active based on the route path
// Using contains() to handle child routes and trailing slashes
if (path.contains(StaffMainRoutes.shiftsFull)) {
newIndex = 0;
} else if (path.contains(StaffMainRoutes.paymentsFull)) {
newIndex = 1;
} else if (path.contains(StaffMainRoutes.homeFull)) {
newIndex = 2;
} else if (path.contains(StaffMainRoutes.clockInFull)) {
if (path.contains('/clock-in')) {
newIndex = 3;
} else if (path.contains(StaffMainRoutes.profileFull)) {
} else if (path.contains('/payments')) {
newIndex = 1;
} else if (path.contains('/home')) {
newIndex = 2;
} else if (path.contains('/shifts')) {
newIndex = 0;
} else if (path.contains('/profile')) {
newIndex = 4;
}
@@ -37,6 +36,9 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
void navigateToTab(int index) {
if (index == state.currentIndex) return;
// Optimistically update the tab index for instant feedback
emit(state.copyWith(currentIndex: index));
switch (index) {
case 0:
Modular.to.navigateToShifts();
@@ -54,7 +56,6 @@ class StaffMainCubit extends Cubit<StaffMainState> implements Disposable {
Modular.to.navigateToProfile();
break;
}
// State update will happen via _onRouteChanged
}
@override

View File

@@ -17,8 +17,8 @@ class StaffMainPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider<StaffMainCubit>(
create: (BuildContext context) => Modular.get<StaffMainCubit>(),
return BlocProvider<StaffMainCubit>.value(
value: Modular.get<StaffMainCubit>(),
child: Scaffold(
extendBody: true,
body: const RouterOutlet(),

View File

@@ -73,10 +73,10 @@ class StaffMainModule extends Module {
'/time-card',
module: StaffTimeCardModule(),
);
r.module('/availability', module: StaffAvailabilityModule());
r.module(
'/clock-in',
module: StaffClockInModule(),
'/availability',
module: StaffAvailabilityModule(),
);
}
}

View File

@@ -53,7 +53,7 @@ dependencies:
path: ../availability
staff_clock_in:
path: ../clock_in
dev_dependencies:
flutter_test:
sdk: flutter