feat: manual nutrition entry on recipe editor
Lets authors enter nutrition values by hand instead of relying only on the AI estimate; the detail-page panel now shows whether data was manually entered or AI-estimated and offers to switch between them. v0.35.0
This commit is contained in:
@@ -60,6 +60,17 @@ const CreateRecipeSchema = z.object({
|
||||
freezerNote: z.string().max(300).optional(),
|
||||
dayOfInstructions: z.string().min(1).max(1000),
|
||||
})).max(10).default([]),
|
||||
// Manually-entered per-serving nutrition — takes precedence over (and
|
||||
// disables) the AI-estimate action on the recipe page, since re-estimating
|
||||
// would silently discard values the author entered on purpose.
|
||||
nutrition: z.object({
|
||||
calories: z.number().min(0).max(10000),
|
||||
proteinG: z.number().min(0).max(1000),
|
||||
carbsG: z.number().min(0).max(1000),
|
||||
fatG: z.number().min(0).max(1000),
|
||||
fiberG: z.number().min(0).max(1000),
|
||||
sodiumMg: z.number().min(0).max(100000),
|
||||
}).optional(),
|
||||
});
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
@@ -132,6 +143,8 @@ export async function POST(req: NextRequest) {
|
||||
language: data.language,
|
||||
sourceUrl: data.sourceUrl,
|
||||
isBatchCook: data.isBatchCook,
|
||||
nutritionData: data.nutrition ? { perServing: data.nutrition } : undefined,
|
||||
nutritionManual: !!data.nutrition,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user