update news
This commit is contained in:
@@ -357,6 +357,10 @@ class ApiConstants {
|
||||
/// POST /api/method/frappe.client.get_list
|
||||
static const String frappeGetList = '/frappe.client.get_list';
|
||||
|
||||
/// Frappe client get (requires sid and csrf_token)
|
||||
/// POST /api/method/frappe.client.get
|
||||
static const String frappeGet = '/frappe.client.get';
|
||||
|
||||
/// Register user (requires session sid and csrf_token)
|
||||
/// POST /api/method/building_material.building_material.api.user.register
|
||||
static const String frappeRegister = '/building_material.building_material.api.user.register';
|
||||
|
||||
@@ -17,6 +17,7 @@ import 'package:worker/features/auth/presentation/pages/business_unit_selection_
|
||||
import 'package:worker/features/auth/presentation/pages/login_page.dart';
|
||||
import 'package:worker/features/auth/presentation/pages/otp_verification_page.dart';
|
||||
import 'package:worker/features/auth/presentation/pages/register_page.dart';
|
||||
import 'package:worker/features/auth/presentation/pages/splash_page.dart';
|
||||
import 'package:worker/features/cart/presentation/pages/cart_page.dart';
|
||||
import 'package:worker/features/cart/presentation/pages/checkout_page.dart';
|
||||
import 'package:worker/features/chat/presentation/pages/chat_list_page.dart';
|
||||
@@ -48,12 +49,14 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
final authState = ref.watch(authProvider);
|
||||
|
||||
return GoRouter(
|
||||
// Initial route
|
||||
initialLocation: RouteNames.login,
|
||||
// Initial route - start with splash screen
|
||||
initialLocation: RouteNames.splash,
|
||||
|
||||
// Redirect based on auth state
|
||||
redirect: (context, state) {
|
||||
final isLoading = authState.isLoading;
|
||||
final isLoggedIn = authState.value != null;
|
||||
final isOnSplashPage = state.matchedLocation == RouteNames.splash;
|
||||
final isOnLoginPage = state.matchedLocation == RouteNames.login;
|
||||
final isOnRegisterPage = state.matchedLocation == RouteNames.register;
|
||||
final isOnBusinessUnitPage =
|
||||
@@ -62,8 +65,18 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
final isOnAuthPage =
|
||||
isOnLoginPage || isOnRegisterPage || isOnBusinessUnitPage || isOnOtpPage;
|
||||
|
||||
// If not logged in and not on auth pages, redirect to login
|
||||
if (!isLoggedIn && !isOnAuthPage) {
|
||||
// While loading auth state, show splash screen
|
||||
if (isLoading) {
|
||||
return RouteNames.splash;
|
||||
}
|
||||
|
||||
// After loading, redirect from splash to appropriate page
|
||||
if (isOnSplashPage && !isLoading) {
|
||||
return isLoggedIn ? RouteNames.home : RouteNames.login;
|
||||
}
|
||||
|
||||
// If not logged in and not on auth/splash pages, redirect to login
|
||||
if (!isLoggedIn && !isOnAuthPage && !isOnSplashPage) {
|
||||
return RouteNames.login;
|
||||
}
|
||||
|
||||
@@ -78,6 +91,14 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
|
||||
// Route definitions
|
||||
routes: [
|
||||
// Splash Screen Route
|
||||
GoRoute(
|
||||
path: RouteNames.splash,
|
||||
name: RouteNames.splash,
|
||||
pageBuilder: (context, state) =>
|
||||
MaterialPage(key: state.pageKey, child: const SplashPage()),
|
||||
),
|
||||
|
||||
// Authentication Routes
|
||||
GoRoute(
|
||||
path: RouteNames.login,
|
||||
@@ -486,7 +507,8 @@ class RouteNames {
|
||||
'/model-houses/design-request/create';
|
||||
static const String designRequestDetail = '/model-houses/design-request/:id';
|
||||
|
||||
// Authentication Routes (TODO: implement when auth feature is ready)
|
||||
// Authentication Routes
|
||||
static const String splash = '/splash';
|
||||
static const String login = '/login';
|
||||
static const String otpVerification = '/otp-verification';
|
||||
static const String register = '/register';
|
||||
|
||||
Reference in New Issue
Block a user