Skip to content

Commit

Permalink
Allow querying customers by externalId
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Dec 20, 2024
1 parent c3c1354 commit d141493
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/web/lib/api/customers/get-customer-or-throw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d141493

Please sign in to comment.