aaa
This commit is contained in:
@@ -7,6 +7,7 @@ import '../../features/auth/di/auth_dependency_injection.dart';
|
||||
import '../../features/warehouse/presentation/pages/warehouse_selection_page.dart';
|
||||
import '../../features/operation/presentation/pages/operation_selection_page.dart';
|
||||
import '../../features/products/presentation/pages/products_page.dart';
|
||||
import '../../features/products/presentation/pages/product_detail_page.dart';
|
||||
import '../../features/warehouse/domain/entities/warehouse_entity.dart';
|
||||
import '../storage/secure_storage.dart';
|
||||
|
||||
@@ -121,6 +122,49 @@ class AppRouter {
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
/// Product Detail Route
|
||||
/// Path: /product-detail
|
||||
/// Takes warehouseId, productId, and warehouseName as extra parameter
|
||||
/// Shows detailed information for a specific product
|
||||
GoRoute(
|
||||
path: '/product-detail',
|
||||
name: 'product-detail',
|
||||
builder: (context, state) {
|
||||
final params = state.extra as Map<String, dynamic>?;
|
||||
|
||||
if (params == null) {
|
||||
// If no params, redirect to warehouses
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.go('/warehouses');
|
||||
});
|
||||
return const _ErrorScreen(
|
||||
message: 'Product detail parameters are required',
|
||||
);
|
||||
}
|
||||
|
||||
// Extract required parameters
|
||||
final warehouseId = params['warehouseId'] as int?;
|
||||
final productId = params['productId'] as int?;
|
||||
final warehouseName = params['warehouseName'] as String?;
|
||||
|
||||
// Validate parameters
|
||||
if (warehouseId == null || productId == null || warehouseName == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.go('/warehouses');
|
||||
});
|
||||
return const _ErrorScreen(
|
||||
message: 'Invalid product detail parameters',
|
||||
);
|
||||
}
|
||||
|
||||
return ProductDetailPage(
|
||||
warehouseId: warehouseId,
|
||||
productId: productId,
|
||||
warehouseName: warehouseName,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
// ==================== Error Handling ====================
|
||||
@@ -326,6 +370,26 @@ extension AppRouterExtension on BuildContext {
|
||||
);
|
||||
}
|
||||
|
||||
/// Navigate to product detail page
|
||||
///
|
||||
/// [warehouseId] - ID of the warehouse
|
||||
/// [productId] - ID of the product to view
|
||||
/// [warehouseName] - Name of the warehouse (for display)
|
||||
void goToProductDetail({
|
||||
required int warehouseId,
|
||||
required int productId,
|
||||
required String warehouseName,
|
||||
}) {
|
||||
push(
|
||||
'/product-detail',
|
||||
extra: {
|
||||
'warehouseId': warehouseId,
|
||||
'productId': productId,
|
||||
'warehouseName': warehouseName,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Pop current route
|
||||
void goBack() => pop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user