Skip to content

Commit

Permalink
fix: Adds a secondary check and a fall back to Plain (#2118)
Browse files Browse the repository at this point in the history
* Adds a secondary check and a fall back.

Names are required for Plain and we don't always have a username, nor do
we always have a name this takes care of both

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
perkinsjr and autofix-ci[bot] authored Sep 20, 2024
1 parent cc0eedd commit 2d99e07
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions apps/dashboard/lib/trpc/routers/plain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const createPlainIssue = rateLimitedProcedure(ratelimit.create)
}

const email = user.emailAddresses.at(0)!.emailAddress;

const plainUser = await client.upsertCustomer({
identifier: {
emailAddress: email,
Expand All @@ -49,14 +48,14 @@ export const createPlainIssue = rateLimitedProcedure(ratelimit.create)
email: email,
isVerified: user.emailAddresses.at(0)?.verification?.status === "verified",
},
fullName: user.username ?? "",
fullName: user.username ?? user.firstName ?? "none avail",
},
onUpdate: {
email: {
email: email,
isVerified: user.emailAddresses.at(0)?.verification?.status === "verified",
},
fullName: { value: user.username ?? "" },
fullName: { value: user.username ?? user.firstName ?? "none avail" },
},
});
if (plainUser.error) {
Expand All @@ -79,7 +78,10 @@ export const createPlainIssue = rateLimitedProcedure(ratelimit.create)
uiComponent.row({
mainContent: [uiComponent.plainText({ text: ctx.tenant.id, color: "MUTED" })],
asideContent: [
uiComponent.copyButton({ value: ctx.tenant.id, tooltip: "Copy Tenant Id" }),
uiComponent.copyButton({
value: ctx.tenant.id,
tooltip: "Copy Tenant Id",
}),
],
}),
],
Expand Down

0 comments on commit 2d99e07

Please sign in to comment.