Skip to content

Commit 94243c9

Browse files
committed
stable customer identifier schema
1 parent 0d9f057 commit 94243c9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

apps/webapp/app/routes/api.v1.plain.customer-cards.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ import { generateImpersonationToken } from "~/services/impersonation.server";
1111
// Schema for the request body from Plain
1212
const PlainCustomerCardRequestSchema = z.object({
1313
cardKeys: z.array(z.string()),
14-
customer: z.object({
15-
id: z.string(),
16-
email: z.string().optional(),
17-
externalId: z.string().optional(),
18-
}),
14+
customer: z
15+
.object({
16+
id: z.string(),
17+
email: z.string().optional(),
18+
externalId: z.string().optional(),
19+
})
20+
.refine(
21+
(data) => data.email || data.externalId,
22+
{
23+
message: "Either customer.email or customer.externalId must be provided",
24+
path: ["customer"],
25+
}
26+
),
1927
thread: z
2028
.object({
2129
id: z.string(),
@@ -320,7 +328,7 @@ export async function action({ request }: ActionFunctionArgs) {
320328
],
321329
asideContent: [
322330
uiComponent.text({
323-
text: `${projectCount} project${projectCount !== 1 ? "s" : ""}`,
331+
text: `${projectCount} recent project${projectCount !== 1 ? "s" : ""}`,
324332
size: "S",
325333
color: "MUTED",
326334
}),

0 commit comments

Comments
 (0)