Skip to content

Commit 6b9ef22

Browse files
committed
fix user cards
1 parent 70f2574 commit 6b9ef22

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

plugins/clerk/components/user-card.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
import type { ResultComponentProps } from "@/plugins/registry";
22

3-
type ClerkUserOutput = {
4-
success: boolean;
5-
data?: {
6-
id: string;
7-
firstName: string | null;
8-
lastName: string | null;
9-
primaryEmailAddress: string | null;
10-
createdAt: number;
11-
};
12-
error?: { message: string };
3+
// The logging layer unwraps standardized outputs, so we receive just the data
4+
type ClerkUserData = {
5+
id: string;
6+
firstName: string | null;
7+
lastName: string | null;
8+
primaryEmailAddress: string | null;
9+
createdAt: number;
1310
};
1411

1512
export function UserCard({ output }: ResultComponentProps) {
16-
const result = output as ClerkUserOutput;
13+
const data = output as ClerkUserData;
1714

18-
if (!result.success || !result.data) {
15+
// Validate we have the expected data shape
16+
if (!data || typeof data !== "object" || !("id" in data)) {
1917
return null;
2018
}
2119

22-
const { data } = result;
2320
const initials = [data.firstName?.[0], data.lastName?.[0]]
2421
.filter(Boolean)
2522
.join("")
2623
.toUpperCase();
2724

2825
const fullName = [data.firstName, data.lastName].filter(Boolean).join(" ");
29-
const createdDate = new Date(data.createdAt).toLocaleDateString();
26+
const createdDate = data.createdAt
27+
? new Date(data.createdAt).toLocaleDateString()
28+
: "Unknown";
3029

3130
return (
3231
<div className="flex items-center gap-4">

0 commit comments

Comments
 (0)