File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed
Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change 11import 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
1512export 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" >
You can’t perform that action at this time.
0 commit comments