add dashboard to phone app

This commit is contained in:
root
2026-05-25 05:10:43 -04:00
parent d04c8ce437
commit 277db06d26
67 changed files with 7872 additions and 570 deletions
+92 -86
View File
@@ -7,7 +7,6 @@ import '../../features/auth/screens/splash_screen.dart';
import '../../features/auth/screens/landing_screen.dart';
import '../../features/auth/screens/role_screen.dart';
import '../../features/auth/screens/employee_login_screen.dart';
import '../../features/dashboard/screens/dashboard_shell.dart';
import '../../features/dashboard/screens/home_screen.dart';
import '../../features/dashboard/screens/vehicles_screen.dart';
import '../../features/dashboard/screens/vehicle_detail_screen.dart';
@@ -15,7 +14,14 @@ import '../../features/dashboard/screens/reservations_screen.dart';
import '../../features/dashboard/screens/reservation_detail_screen.dart';
import '../../features/dashboard/screens/customers_screen.dart';
import '../../features/dashboard/screens/customer_detail_screen.dart';
import '../../features/client/screens/client_shell.dart';
import '../../features/dashboard/screens/notifications_screen.dart';
import '../../features/dashboard/screens/online_reservations_screen.dart';
import '../../features/dashboard/screens/contract_screen.dart';
import '../../features/dashboard/screens/contracts_screen.dart';
import '../../features/dashboard/screens/offers_screen.dart';
import '../../features/dashboard/screens/reports_screen.dart';
import '../../features/dashboard/screens/settings_screen.dart';
import '../../features/dashboard/screens/team_screen.dart';
import '../../features/client/screens/client_home_screen.dart';
import '../../features/client/screens/client_vehicle_detail_screen.dart';
import '../../features/client/screens/booking_screen.dart';
@@ -25,7 +31,6 @@ final routerProvider = Provider<GoRouter>((ref) {
final router = GoRouter(
initialLocation: '/splash',
redirect: (context, state) {
// Read (not watch) so redirect is evaluated on router.refresh()
final auth = ref.read(authProvider);
final status = auth.status;
final loc = state.matchedLocation;
@@ -33,12 +38,10 @@ final routerProvider = Provider<GoRouter>((ref) {
final isLanding = loc == '/landing';
final isLogin = loc.startsWith('/login');
// Still initialising — stay on splash
if (status == AuthStatus.unknown) {
return isSplash ? null : '/splash';
}
// Auth resolved — always leave splash
if (isSplash) {
if (status == AuthStatus.authenticated) {
return auth.userType == AppConstants.userTypeEmployee
@@ -49,7 +52,6 @@ final routerProvider = Provider<GoRouter>((ref) {
}
if (status == AuthStatus.unauthenticated) {
// Allow landing, login routes, and the entire client section without auth
if (isLanding || isLogin || loc.startsWith('/client')) return null;
return '/landing';
}
@@ -64,95 +66,99 @@ final routerProvider = Provider<GoRouter>((ref) {
return null;
},
routes: [
GoRoute(
path: '/splash',
builder: (context, _) => const SplashScreen(),
),
GoRoute(
path: '/landing',
builder: (context, _) => const LandingScreen(),
),
GoRoute(
path: '/role',
builder: (context, _) => const RoleScreen(),
),
GoRoute(path: '/splash', builder: (context, _) => const SplashScreen()),
GoRoute(path: '/landing', builder: (context, _) => const LandingScreen()),
GoRoute(path: '/role', builder: (context, _) => const RoleScreen()),
GoRoute(
path: '/login/employee',
builder: (context, _) => const EmployeeLoginScreen(),
),
ShellRoute(
builder: (context, state, child) => DashboardShell(child: child),
routes: [
GoRoute(
path: '/dashboard',
builder: (context, _) => const HomeScreen(),
),
GoRoute(
path: '/dashboard/vehicles',
builder: (context, _) => const VehiclesScreen(),
routes: [
GoRoute(
path: ':id',
builder: (_, state) =>
VehicleDetailScreen(id: state.pathParameters['id']!),
),
],
),
GoRoute(
path: '/dashboard/reservations',
builder: (context, _) => const ReservationsScreen(),
routes: [
GoRoute(
path: ':id',
builder: (_, state) =>
ReservationDetailScreen(id: state.pathParameters['id']!),
),
],
),
GoRoute(
path: '/dashboard/customers',
builder: (context, _) => const CustomersScreen(),
routes: [
GoRoute(
path: ':id',
builder: (_, state) =>
CustomerDetailScreen(id: state.pathParameters['id']!),
),
],
),
],
GoRoute(path: '/dashboard', builder: (context, _) => const HomeScreen()),
GoRoute(
path: '/dashboard/vehicles',
builder: (context, _) => const VehiclesScreen(),
),
ShellRoute(
builder: (context, state, child) => ClientShell(child: child),
routes: [
GoRoute(
path: '/client',
builder: (context, _) => const ClientHomeScreen(),
),
GoRoute(
path: '/client/vehicles/:id',
builder: (_, state) => ClientVehicleDetailScreen(
id: state.pathParameters['id']!,
vehicle: state.extra as MarketplaceVehicle?,
),
),
GoRoute(
path: '/client/book/:vehicleId',
builder: (_, state) => BookingScreen(
vehicleId: state.pathParameters['vehicleId']!,
vehicle: state.extra as MarketplaceVehicle?,
),
),
GoRoute(
path: '/client/bookings',
builder: (context, _) => const MyBookingsScreen(),
),
],
GoRoute(
path: '/dashboard/reservations',
builder: (context, _) => const ReservationsScreen(),
),
GoRoute(
path: '/dashboard/customers',
builder: (context, _) => const CustomersScreen(),
),
GoRoute(
path: '/dashboard/vehicles/:id',
builder: (_, state) =>
VehicleDetailScreen(id: state.pathParameters['id']!),
),
GoRoute(
path: '/dashboard/reservations/:id',
builder: (_, state) =>
ReservationDetailScreen(id: state.pathParameters['id']!),
),
GoRoute(
path: '/dashboard/reservations/:id/contract',
builder: (_, state) =>
ContractScreen(reservationId: state.pathParameters['id']!),
),
GoRoute(
path: '/dashboard/customers/:id',
builder: (_, state) =>
CustomerDetailScreen(id: state.pathParameters['id']!),
),
GoRoute(
path: '/dashboard/notifications',
builder: (context, _) => const NotificationsScreen(),
),
GoRoute(
path: '/dashboard/online-reservations',
builder: (context, _) => const OnlineReservationsScreen(),
),
GoRoute(
path: '/dashboard/contracts',
builder: (context, _) => const ContractsScreen(),
),
GoRoute(
path: '/dashboard/offers',
builder: (context, _) => const OffersScreen(),
),
GoRoute(
path: '/dashboard/reports',
builder: (context, _) => const ReportsScreen(),
),
GoRoute(
path: '/dashboard/settings',
builder: (context, _) => const SettingsScreen(),
),
GoRoute(
path: '/dashboard/team',
builder: (context, _) => const TeamScreen(),
),
GoRoute(
path: '/client',
builder: (context, _) => const ClientHomeScreen(),
),
GoRoute(
path: '/client/bookings',
builder: (context, _) => const MyBookingsScreen(),
),
GoRoute(
path: '/client/vehicles/:id',
builder: (_, state) => ClientVehicleDetailScreen(
id: state.pathParameters['id']!,
vehicle: state.extra as MarketplaceVehicle?,
),
),
GoRoute(
path: '/client/book/:vehicleId',
builder: (_, state) => BookingScreen(
vehicleId: state.pathParameters['vehicleId']!,
vehicle: state.extra as MarketplaceVehicle?,
),
),
],
);
// Trigger redirect re-evaluation whenever auth state changes
ref.listen<AuthState>(authProvider, (_, _) => router.refresh());
return router;