import { NextRequest, NextResponse } from 'next/server'; import { customerSchema } from 'mvpmasters-shared'; import prisma from 'src/lib/prisma'; import { authenticateRequest } from 'src/lib/auth-middleware'; export async function PATCH(request: NextRequest, { params }: { params: { id: string } }) { try { const userId = await authenticateRequest(request); if (!userId) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } const body = await request.json(); const validatedData = customerSchema.partial().parse(body); const customer = await prisma.customer.update({ where: { id: params.id, userId }, data: validatedData, }); return NextResponse.json(customer); } catch (error) { return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 }); } }