fix: enable component search and pricing in offline mode
**Problem:** Configurator was broken in offline mode - no component search and no price calculation because /api/components returned empty list. **Solution:** Added local component fallback to ComponentHandler: 1. **ComponentHandler with localDB** (component.go) - Added localDB parameter to NewComponentHandler - List() now fallbacks to local_components when offline - Converts LocalComponent to ComponentView format - Preserves prices from local cache 2. **Updated initialization** (main.go) - Pass localDB to NewComponentHandler **Impact:** - ✅ Component search works offline - ✅ Prices load from local_components table - ✅ Configuration creation fully functional offline - ✅ Price calculation works with cached prices **Testing:** - Verified /api/components returns local components - Verified current_price field populated from cache - Search, filtering, and pagination work correctly Fixes critical Phase 2.5 offline mode issue. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -364,7 +364,7 @@ func setupRouter(cfg *config.Config, local *localdb.LocalDB, connMgr *db.Connect
|
||||
configService := services.NewLocalConfigurationService(local, syncService, quoteService, isOnline)
|
||||
|
||||
// Handlers
|
||||
componentHandler := handlers.NewComponentHandler(componentService)
|
||||
componentHandler := handlers.NewComponentHandler(componentService, local)
|
||||
quoteHandler := handlers.NewQuoteHandler(quoteService)
|
||||
exportHandler := handlers.NewExportHandler(exportService, configService, componentService)
|
||||
pricingHandler := handlers.NewPricingHandler(mariaDB, pricingService, alertService, componentRepo, priceRepo, statsRepo)
|
||||
|
||||
Reference in New Issue
Block a user