Fix UI for inventory page

This commit is contained in:
Urtzi Alfaro
2025-09-15 15:31:27 +02:00
parent 36cfc88f93
commit 65a53c6d16
10 changed files with 953 additions and 378 deletions

View File

@@ -160,12 +160,22 @@ class Ingredient(Base):
def to_dict(self) -> Dict[str, Any]:
"""Convert model to dictionary for API responses"""
# Map to response schema format - use ingredient_category as primary category
# Map to response schema format - use appropriate category based on product type
category = None
if self.ingredient_category:
if self.product_type == ProductType.FINISHED_PRODUCT and self.product_category:
# For finished products, use product_category
category = self.product_category.value
elif self.product_type == ProductType.INGREDIENT and self.ingredient_category:
# For ingredients, use ingredient_category
category = self.ingredient_category.value
elif self.ingredient_category and self.ingredient_category != IngredientCategory.OTHER:
# If ingredient_category is set and not 'OTHER', use it
category = self.ingredient_category.value
elif self.product_category:
# For finished products, we could map to a generic category
# Fall back to product_category if available
category = self.product_category.value
else:
# Final fallback
category = "other"
return {