пва
This commit is contained in:
Binary file not shown.
@@ -204,4 +204,18 @@ export async function registerAuthRoutes(fastify) {
|
||||
})
|
||||
return { user: mapUserForClient(updated) }
|
||||
})
|
||||
|
||||
fastify.delete('/api/me', { preHandler: [fastify.authenticate] }, async (request, reply) => {
|
||||
const userId = request.user.sub
|
||||
|
||||
const ACTIVE_STATUSES = ['DRAFT', 'PENDING_PAYMENT', 'PAID', 'IN_PROGRESS', 'SHIPPED', 'READY_FOR_PICKUP']
|
||||
|
||||
const activeOrders = await prisma.order.findMany({
|
||||
where: { userId, status: { in: ACTIVE_STATUSES } },
|
||||
select: { id: true },
|
||||
})
|
||||
|
||||
await prisma.user.delete({ where: { id: userId } })
|
||||
return { ok: true, activeOrderIds: activeOrders.map((o) => o.id) }
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user