44'use client' ;
55
66import {
7+ AttributeSchema ,
78 EmbeddedFlowExecuteRequestConfig ,
89 FlowMetadataResponse ,
910 generateFlattenedUserProfile ,
@@ -69,6 +70,7 @@ export type ThunderIDClientProviderProps = Partial<Omit<ThunderIDProviderProps,
6970 ) => Promise < { data : { user : User } ; error : string ; success : boolean } > ;
7071 user : User | null ;
7172 userProfile : UserProfile ;
73+ userSchema ?: Record < string , AttributeSchema > | null ;
7274 } ;
7375
7476const ThunderIDClientProvider : FC < PropsWithChildren < ThunderIDClientProviderProps > > = ( {
@@ -86,6 +88,7 @@ const ThunderIDClientProvider: FC<PropsWithChildren<ThunderIDClientProviderProps
8688 signUpUrl,
8789 user : _user ,
8890 userProfile : _userProfile ,
91+ userSchema : _userSchema = null ,
8992 updateProfile,
9093 applicationId,
9194 organizationHandle,
@@ -100,11 +103,16 @@ const ThunderIDClientProvider: FC<PropsWithChildren<ThunderIDClientProviderProps
100103 const [ isLoading , setIsLoading ] = useState < boolean > ( true ) ;
101104 const [ user , setUser ] = useState < User | null > ( _user ) ;
102105 const [ userProfile , setUserProfile ] = useState < UserProfile > ( _userProfile ) ;
106+ const [ userSchema , setUserSchema ] = useState < Record < string , AttributeSchema > | null > ( _userSchema ) ;
103107
104108 useEffect ( ( ) => {
105109 setUserProfile ( _userProfile ) ;
106110 } , [ _userProfile ] ) ;
107111
112+ useEffect ( ( ) => {
113+ setUserSchema ( _userSchema ) ;
114+ } , [ _userSchema ] ) ;
115+
108116 useEffect ( ( ) => {
109117 setUser ( _user ) ;
110118 } , [ _user ] ) ;
@@ -368,7 +376,7 @@ const ThunderIDClientProvider: FC<PropsWithChildren<ThunderIDClientProviderProps
368376 signUp : handleSignUp ,
369377 signUpUrl,
370378 user,
371- userSchema : null ,
379+ userSchema,
372380 vendor : getVendorPrefix ( vendor ) ,
373381 } ) ,
374382 [
@@ -382,6 +390,7 @@ const ThunderIDClientProvider: FC<PropsWithChildren<ThunderIDClientProviderProps
382390 signInUrl ,
383391 signUpUrl ,
384392 user ,
393+ userSchema ,
385394 initialMeta ,
386395 vendor ,
387396 ] ,
@@ -398,7 +407,12 @@ const ThunderIDClientProvider: FC<PropsWithChildren<ThunderIDClientProviderProps
398407 >
399408 < ThemeProvider theme = { preferences ?. theme ?. overrides } mode = { getActiveTheme ( preferences ?. theme ?. mode as any ) } >
400409 < FlowProvider >
401- < UserProvider profile = { userProfile } onUpdateProfile = { handleProfileUpdate } updateProfile = { updateProfile } >
410+ < UserProvider
411+ profile = { userProfile }
412+ userSchema = { userSchema }
413+ onUpdateProfile = { handleProfileUpdate }
414+ updateProfile = { updateProfile }
415+ >
402416 { children }
403417 </ UserProvider >
404418 </ FlowProvider >
0 commit comments