diff --git a/internal/handlers/pricelist.go b/internal/handlers/pricelist.go index 19c2b40..f6dc2f5 100644 --- a/internal/handlers/pricelist.go +++ b/internal/handlers/pricelist.go @@ -29,6 +29,36 @@ func (h *PricelistHandler) List(c *gin.Context) { return } + // If offline (empty list), fallback to local pricelists + if total == 0 && h.localDB != nil { + localPLs, err := h.localDB.GetLocalPricelists() + if err == nil && len(localPLs) > 0 { + // Convert to PricelistSummary format + summaries := make([]map[string]interface{}, len(localPLs)) + for i, lpl := range localPLs { + summaries[i] = map[string]interface{}{ + "id": lpl.ServerID, + "version": lpl.Version, + "created_by": "sync", + "item_count": 0, // Not tracked + "usage_count": 0, // Not tracked in local + "is_active": true, + "created_at": lpl.CreatedAt, + "synced_from": "local", + } + } + + c.JSON(http.StatusOK, gin.H{ + "pricelists": summaries, + "total": len(summaries), + "page": page, + "per_page": perPage, + "offline": true, + }) + return + } + } + c.JSON(http.StatusOK, gin.H{ "pricelists": pricelists, "total": total,