added local db
This commit is contained in:
@@ -5,23 +5,20 @@ import 'package:go_router/go_router.dart';
|
||||
import '../../domain/entities/transaction.dart';
|
||||
import '../../presentation/auth/providers/auth_controller.dart';
|
||||
import '../../presentation/auth/screens/login_screen.dart';
|
||||
import '../../presentation/customer/screens/customer_registration_screen.dart';
|
||||
import '../../presentation/customer/screens/existing_customer_screen.dart';
|
||||
import '../../presentation/payment/screens/payment_screen.dart';
|
||||
import '../../presentation/pos/screens/pos_dashboard_screen.dart';
|
||||
import '../../presentation/receipt/screens/receipt_screen.dart';
|
||||
import '../../presentation/welcome/screens/welcome_screen.dart';
|
||||
|
||||
class AppRoutes {
|
||||
const AppRoutes._();
|
||||
|
||||
static const String login = '/login';
|
||||
static const String welcome = '/';
|
||||
static const String registerCustomer = '/customer/new';
|
||||
static const String existingCustomer = '/customer/find';
|
||||
static const String pos = '/pos';
|
||||
static const String payment = '/pos/payment';
|
||||
static const String receipt = '/pos/receipt';
|
||||
|
||||
/// The terminal itself. Signing in lands here directly — customer capture
|
||||
/// happens at checkout, not before the sale.
|
||||
static const String pos = '/';
|
||||
static const String payment = '/payment';
|
||||
static const String receipt = '/receipt';
|
||||
}
|
||||
|
||||
/// Router with an authentication guard.
|
||||
@@ -48,7 +45,7 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
final atLogin = state.matchedLocation == AppRoutes.login;
|
||||
|
||||
if (!signedIn) return atLogin ? null : AppRoutes.login;
|
||||
if (atLogin) return AppRoutes.welcome;
|
||||
if (atLogin) return AppRoutes.pos;
|
||||
return null;
|
||||
},
|
||||
routes: [
|
||||
@@ -57,48 +54,24 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
name: 'login',
|
||||
pageBuilder: (context, state) => _fade(state, const LoginScreen()),
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.welcome,
|
||||
name: 'welcome',
|
||||
pageBuilder: (context, state) => _fade(state, const WelcomeScreen()),
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.registerCustomer,
|
||||
name: 'registerCustomer',
|
||||
pageBuilder: (context, state) => _slide(
|
||||
state,
|
||||
CustomerRegistrationScreen(
|
||||
prefillMobile: state.uri.queryParameters['mobile'],
|
||||
),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.existingCustomer,
|
||||
name: 'existingCustomer',
|
||||
pageBuilder: (context, state) =>
|
||||
_slide(state, const ExistingCustomerScreen()),
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.pos,
|
||||
name: 'pos',
|
||||
pageBuilder: (context, state) =>
|
||||
_fade(state, const PosDashboardScreen()),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'payment',
|
||||
name: 'payment',
|
||||
pageBuilder: (context, state) =>
|
||||
_slide(state, const PaymentScreen()),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'receipt',
|
||||
name: 'receipt',
|
||||
pageBuilder: (context, state) => _fade(
|
||||
state,
|
||||
ReceiptScreen(transaction: state.extra! as SaleTransaction),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.payment,
|
||||
name: 'payment',
|
||||
pageBuilder: (context, state) => _slide(state, const PaymentScreen()),
|
||||
),
|
||||
GoRoute(
|
||||
path: AppRoutes.receipt,
|
||||
name: 'receipt',
|
||||
pageBuilder: (context, state) => _fade(
|
||||
state,
|
||||
ReceiptScreen(transaction: state.extra! as SaleTransaction),
|
||||
),
|
||||
),
|
||||
],
|
||||
errorBuilder: (context, state) => Scaffold(
|
||||
|
||||
Reference in New Issue
Block a user