1
+ import { useClerk } from '@clerk/shared/react/index' ;
2
+
3
+ import { withRedirectToAfterSignUp } from '@/ui/common' ;
1
4
import { ChooseEnterpriseConnectionCard } from '@/ui/common/ChooseEnterpriseConnectionCard' ;
2
- import { useCoreSignUp , useSignUpContext } from '@/ui/contexts' ;
5
+ import { useSignUpContext } from '@/ui/contexts' ;
3
6
import { Flow , localizationKeys } from '@/ui/customizables' ;
7
+ import { withCardStateProvider } from '@/ui/elements/contexts' ;
4
8
import { LoadingCard } from '@/ui/elements/LoadingCard' ;
5
9
import { useFetch } from '@/ui/hooks' ;
6
10
7
- /**
8
- * @experimental
9
- */
10
- export const SignUpChooseEnterpriseConnection = ( ) => {
11
- const signUp = useCoreSignUp ( ) ;
11
+ const SignUpChooseEnterpriseConnectionInternal = ( ) => {
12
+ const clerk = useClerk ( ) ;
12
13
const ctx = useSignUpContext ( ) ;
14
+
15
+ const signUp = clerk . client . signUp ;
13
16
const { data : enterpriseConnections , isLoading } = useFetch ( signUp ?. __experimental_getEnterpriseConnections , {
14
17
signUpId : signUp . id ,
15
18
} ) ;
16
19
17
20
const handleEnterpriseSSO = ( enterpriseConnectionId : string ) => {
18
- if ( ! signUp . emailAddress ) {
19
- return ;
20
- }
21
-
22
21
const redirectUrl = ctx . ssoCallbackUrl ;
23
22
const redirectUrlComplete = ctx . afterSignUpUrl || '/' ;
24
23
25
24
void signUp . authenticateWithRedirect ( {
26
25
strategy : 'enterprise_sso' ,
27
- identifier : signUp . emailAddress ,
28
26
redirectUrl,
29
27
redirectUrlComplete,
30
28
continueSignUp : true ,
@@ -51,3 +49,10 @@ export const SignUpChooseEnterpriseConnection = () => {
51
49
</ Flow . Part >
52
50
) ;
53
51
} ;
52
+
53
+ /**
54
+ * @experimental
55
+ */
56
+ export const SignUpChooseEnterpriseConnection = withRedirectToAfterSignUp (
57
+ withCardStateProvider ( SignUpChooseEnterpriseConnectionInternal ) ,
58
+ ) ;
0 commit comments