diff --git a/backend/src/models/flavor.rs b/backend/src/models/flavor.rs index 943c7ff..518178e 100644 --- a/backend/src/models/flavor.rs +++ b/backend/src/models/flavor.rs @@ -22,7 +22,7 @@ pub struct FlavorUpdate { pub struct FlavorCreate { name: String, short_code: String, - ingredient_types: Vec, + ingredient_types: Vec, } impl Update for FlavorUpdate { @@ -58,11 +58,11 @@ impl CrudBackend for Flavor { .fetch_one(&mut *conn) .await?; - for ingredient_type in create.ingredient_types { + for ingredient_type_id in create.ingredient_types { sqlx::query!( r#"INSERT INTO ingredients_required (flavor_id, ingredient_id) VALUES ($1, $2)"#, flavor.id, - ingredient_type.id, + ingredient_type_id, ) .execute(&mut *conn) .await?; diff --git a/frontend/components/forms/flavor.tsx b/frontend/components/forms/flavor.tsx index 49eabda..a145f94 100644 --- a/frontend/components/forms/flavor.tsx +++ b/frontend/components/forms/flavor.tsx @@ -43,7 +43,7 @@ async function getIngredientTypes( ): Promise { const res = await fetch(`/api/ingredients_type?query=${query}&page=${page}`) const data = await res.json() - return data.map((type: { name: string; id: string }) => ({ + return data.rows.map((type: { name: string; id: string }) => ({ label: type.name, value: type.id, })) diff --git a/frontend/components/pages/flavors.tsx b/frontend/components/pages/flavors.tsx index 63fdf51..0198a4f 100644 --- a/frontend/components/pages/flavors.tsx +++ b/frontend/components/pages/flavors.tsx @@ -52,6 +52,7 @@ const PERM_DELETE = UserPermissions.SuperAdmin import { FlavorForm as EntityForm, Flavor as Entity } from "../forms/flavor" import { IngredientTypeForm } from "../forms/ingredient_type" import { AllIngredientTypes } from "../forms/all_ingredient_types" +import { Badge } from "../ui/badge" interface PaginatedResponse { rows: Entity[] @@ -78,7 +79,13 @@ function IngredientCell({ flavorId }: { flavorId: string }) { if (isLoading) return Loading... if (!flavor) return Unknown - return {flavor.name} + return ( +
+ {flavor.map((f_is: { id: string; name: string }) => ( + {f_is.name} + ))} +
+ ) } export function FlavorsPage({ userPerms }: Props) {