From d141493fcbfafc163fe6923454521730f900aaae Mon Sep 17 00:00:00 2001 From: Steven Tey Date: Fri, 20 Dec 2024 11:30:44 -0800 Subject: [PATCH] Allow querying customers by externalId --- apps/web/lib/api/customers/get-customer-or-throw.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/web/lib/api/customers/get-customer-or-throw.ts b/apps/web/lib/api/customers/get-customer-or-throw.ts index 72058b253b..d5026ad732 100644 --- a/apps/web/lib/api/customers/get-customer-or-throw.ts +++ b/apps/web/lib/api/customers/get-customer-or-throw.ts @@ -9,7 +9,16 @@ export const getCustomerOrThrow = async ({ workspaceId: string; }) => { const customer = await prisma.customer.findUnique({ - where: { id }, + where: { + ...(id.startsWith("ext_") + ? { + projectId_externalId: { + projectId: workspaceId, + externalId: id.replace("ext_", ""), + }, + } + : { id }), + }, }); if (!customer || customer.projectId !== workspaceId) {