Skip to content

Commit d141493

Browse files
committed
Allow querying customers by externalId
1 parent c3c1354 commit d141493

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

apps/web/lib/api/customers/get-customer-or-throw.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ export const getCustomerOrThrow = async ({
99
workspaceId: string;
1010
}) => {
1111
const customer = await prisma.customer.findUnique({
12-
where: { id },
12+
where: {
13+
...(id.startsWith("ext_")
14+
? {
15+
projectId_externalId: {
16+
projectId: workspaceId,
17+
externalId: id.replace("ext_", ""),
18+
},
19+
}
20+
: { id }),
21+
},
1322
});
1423

1524
if (!customer || customer.projectId !== workspaceId) {

0 commit comments

Comments
 (0)