Fix UI for inventory page
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user