feat: add servings field to Recipe model and implement inventory comparison functionality
This commit is contained in:
@@ -295,7 +295,7 @@ export class RecipesService {
|
||||
include: {
|
||||
ingredients: {
|
||||
include: {
|
||||
product: true,
|
||||
product: { include: { nutrition: true } },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -308,7 +308,7 @@ export class RecipesService {
|
||||
include: {
|
||||
ingredients: {
|
||||
include: {
|
||||
product: true,
|
||||
product: { include: { nutrition: true } },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -343,6 +343,7 @@ export class RecipesService {
|
||||
name: updateRecipeDto.name,
|
||||
description: updateRecipeDto.description || null,
|
||||
instructions: updateRecipeDto.instructions || null,
|
||||
servings: updateRecipeDto.servings ?? null,
|
||||
...(updateRecipeDto.imageUrl !== undefined && { imageUrl: updateRecipeDto.imageUrl || null }),
|
||||
ingredients: {
|
||||
create: updateRecipeDto.ingredients.map((ingredient) => ({
|
||||
@@ -356,7 +357,7 @@ export class RecipesService {
|
||||
include: {
|
||||
ingredients: {
|
||||
include: {
|
||||
product: true,
|
||||
product: { include: { nutrition: true } },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -389,7 +390,7 @@ export class RecipesService {
|
||||
return this.prisma.recipe.update({
|
||||
where: { id },
|
||||
data: { imageUrl },
|
||||
include: { ingredients: { include: { product: true } } },
|
||||
include: { ingredients: { include: { product: { include: { nutrition: true } } } } },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -411,6 +412,7 @@ export class RecipesService {
|
||||
description: createRecipeDto.description || null,
|
||||
instructions: createRecipeDto.instructions || null,
|
||||
imageUrl,
|
||||
servings: createRecipeDto.servings ?? null,
|
||||
ingredients: {
|
||||
create: createRecipeDto.ingredients.map((ingredient) => ({
|
||||
productId: ingredient.productId,
|
||||
@@ -423,7 +425,7 @@ export class RecipesService {
|
||||
include: {
|
||||
ingredients: {
|
||||
include: {
|
||||
product: true,
|
||||
product: { include: { nutrition: true } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user