diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 8c05482..3afad14 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -63,7 +63,8 @@ "Bash(git show *)", "Bash(git status *)", "Bash(git revert *)", - "Bash(git commit -m 'Fix price display issues and layout in design review page *)" + "Bash(git commit -m 'Fix price display issues and layout in design review page *)", + "Bash(git commit -m 'Fix: Calculate effectivePrice in design API endpoints *)" ] } } diff --git a/src/app/api/designs/[id]/approve/route.ts b/src/app/api/designs/[id]/approve/route.ts index 3caee91..e0ed3e4 100644 --- a/src/app/api/designs/[id]/approve/route.ts +++ b/src/app/api/designs/[id]/approve/route.ts @@ -1,6 +1,7 @@ import { NextResponse } from 'next/server'; import { prisma } from '@/lib/prisma'; import { sendDesignApprovedEmail } from '@/lib/mail'; +import { toProductDTO } from '@/lib/product'; export async function POST( req: Request, @@ -30,7 +31,10 @@ export async function POST( checkoutLink, }); - return NextResponse.json(updated); + return NextResponse.json({ + ...updated, + product: toProductDTO(updated.product), + }); } catch (err) { console.error('Error approving design:', err); return NextResponse.json( diff --git a/src/app/api/designs/[id]/route.ts b/src/app/api/designs/[id]/route.ts index b240fd2..77ac59c 100644 --- a/src/app/api/designs/[id]/route.ts +++ b/src/app/api/designs/[id]/route.ts @@ -1,6 +1,7 @@ import { NextResponse } from 'next/server'; import { prisma } from '@/lib/prisma'; import { getCurrentCustomer } from '@/lib/auth'; +import { toProductDTO } from '@/lib/product'; export async function GET( req: Request, @@ -16,7 +17,10 @@ export async function GET( return NextResponse.json({ error: 'Design not found' }, { status: 404 }); } - return NextResponse.json(design); + return NextResponse.json({ + ...design, + product: toProductDTO(design.product), + }); } catch (err) { console.error('Error fetching design:', err); return NextResponse.json( @@ -44,7 +48,10 @@ export async function PATCH( include: { product: true, messages: { orderBy: { createdAt: 'asc' } } }, }); - return NextResponse.json(updated); + return NextResponse.json({ + ...updated, + product: toProductDTO(updated.product), + }); } catch (err) { console.error('Error updating design:', err); return NextResponse.json(