Add mitra online/offline status with heartbeat-based auto-offline, customer-mitra pairing via Valkey pub/sub blast, session management, and control center dashboard with real-time stats. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
1.0 KiB
Dart
28 lines
1.0 KiB
Dart
import 'package:go_router/go_router.dart';
|
|
import 'core/auth/auth_bloc.dart';
|
|
import 'features/auth/screens/login_screen.dart';
|
|
import 'features/auth/screens/otp_screen.dart';
|
|
import 'features/home/home_screen.dart';
|
|
import 'features/chat/screens/active_sessions_screen.dart';
|
|
|
|
GoRouter buildRouter(AuthBloc authBloc) {
|
|
return GoRouter(
|
|
initialLocation: '/login',
|
|
redirect: (context, state) {
|
|
final authState = authBloc.state;
|
|
final isAuthRoute = state.matchedLocation.startsWith('/login') ||
|
|
state.matchedLocation.startsWith('/otp');
|
|
|
|
if (authState is AuthAuthenticated) return isAuthRoute ? '/home' : null;
|
|
if (!isAuthRoute) return '/login';
|
|
return null;
|
|
},
|
|
routes: [
|
|
GoRoute(path: '/login', builder: (_, __) => const LoginScreen()),
|
|
GoRoute(path: '/otp', builder: (context, state) => OtpScreen(phone: state.extra as String)),
|
|
GoRoute(path: '/home', builder: (_, __) => const HomeScreen()),
|
|
GoRoute(path: '/sessions', builder: (_, __) => const ActiveSessionsScreen()),
|
|
],
|
|
);
|
|
}
|