feat: placement mur/sol pour templates carrelage avec prompt adapté

This commit is contained in:
2026-06-24 14:52:57 +02:00
parent e85314eb77
commit cdde567558
5 changed files with 104 additions and 31 deletions
+8 -1
View File
@@ -6,10 +6,17 @@ import { getTemplateImagePath, listTemplates } from '@/lib/mockupTemplates'
import type { MockupGenerateRequest } from '@/types/mockup'
function buildPrompt(req: MockupGenerateRequest): string {
let carrelageContext = 'tiles covering the floor or wall of a modern room'
if (req.family === 'Carrelage' && req.placement === 'mur') {
carrelageContext = 'wall tiles (faïence) covering the wall of a modern bathroom or kitchen — applied only to the wall, not the floor'
} else if (req.family === 'Carrelage' && req.placement === 'sol') {
carrelageContext = 'floor tiles covering the floor of a modern room — applied only to the floor, not the walls'
}
const familyContext: Record<string, string> = {
'Menuiserie': 'door installed in a residential entrance or hallway, visible wall and floor context',
'Baies vitrées': 'bay window or sliding door installed in a living room with garden view',
'Carrelage': 'tiles covering the floor or wall of a modern room',
'Carrelage': carrelageContext,
}
const context = familyContext[req.family] ?? 'product installed in an appropriate room setting'
const dimClause = req.dimensions
+2 -1
View File
@@ -17,6 +17,7 @@ export async function POST(req: NextRequest) {
const form = await req.formData()
const name = form.get('name') as string
const family = form.get('family') as string
const placement = (form.get('placement') as string) || undefined
const description = (form.get('description') as string) ?? ''
const imageFile = form.get('image') as File
@@ -26,6 +27,6 @@ export async function POST(req: NextRequest) {
const buffer = Buffer.from(await imageFile.arrayBuffer())
const ext = imageFile.name.split('.').pop() ?? 'jpg'
const template = await saveTemplate({ name, family, description, filename: '' }, buffer, ext)
const template = await saveTemplate({ name, family, placement, description, filename: '' }, buffer, ext)
return Response.json(template)
}