Skip to content

Commit 56a47e3

Browse files
committed
Mount components once mutation is resolved
1 parent b99a632 commit 56a47e3

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

packages/clerk-js/src/core/clerk.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ import type {
3636
AuthenticateWithMetamaskParams,
3737
AuthenticateWithOKXWalletParams,
3838
BillingNamespace,
39-
Clerk as ClerkInterface,
4039
ClerkAPIError,
4140
ClerkAuthenticateWithWeb3Params,
41+
Clerk as ClerkInterface,
4242
ClerkOptions,
4343
ClientJSONSnapshot,
4444
ClientResource,
@@ -826,6 +826,9 @@ export class Clerk implements ClerkInterface {
826826
if (this.#instanceType === 'development') {
827827
this.__internal_openEnableOrganizationsPrompt({
828828
componentName: 'OrganizationProfile',
829+
onComplete: () => {
830+
this.openOrganizationProfile();
831+
},
829832
});
830833
}
831834
return;
@@ -856,6 +859,9 @@ export class Clerk implements ClerkInterface {
856859
if (this.#instanceType === 'development') {
857860
this.__internal_openEnableOrganizationsPrompt({
858861
componentName: 'OrganizationSwitcher',
862+
onComplete: () => {
863+
this.openCreateOrganization();
864+
},
859865
});
860866
}
861867
return;
@@ -998,6 +1004,9 @@ export class Clerk implements ClerkInterface {
9981004
if (this.#instanceType === 'development') {
9991005
this.__internal_openEnableOrganizationsPrompt({
10001006
componentName: 'OrganizationProfile',
1007+
onComplete: () => {
1008+
this.mountOrganizationProfile(node, props);
1009+
},
10011010
});
10021011
}
10031012
return;
@@ -1038,6 +1047,9 @@ export class Clerk implements ClerkInterface {
10381047
if (this.#instanceType === 'development') {
10391048
this.__internal_openEnableOrganizationsPrompt({
10401049
componentName: 'OrganizationSwitcher',
1050+
onComplete: () => {
1051+
this.mountCreateOrganization();
1052+
},
10411053
});
10421054
}
10431055
return;
@@ -1069,6 +1081,9 @@ export class Clerk implements ClerkInterface {
10691081
if (this.#instanceType === 'development') {
10701082
this.__internal_openEnableOrganizationsPrompt({
10711083
componentName: 'OrganizationSwitcher',
1084+
onComplete: () => {
1085+
this.mountOrganizationSwitcher(node, props);
1086+
},
10721087
});
10731088
}
10741089
return;
@@ -1105,9 +1120,14 @@ export class Clerk implements ClerkInterface {
11051120
public mountOrganizationList = (node: HTMLDivElement, props?: OrganizationListProps) => {
11061121
this.assertComponentsReady(this.#componentControls);
11071122
if (disabledOrganizationsFeature(this, this.environment)) {
1123+
debugger;
11081124
if (this.#instanceType === 'development') {
11091125
this.__internal_openEnableOrganizationsPrompt({
11101126
componentName: 'OrganizationList',
1127+
onComplete: () => {
1128+
debugger;
1129+
this.mountOrganizationList(node, props);
1130+
},
11111131
});
11121132
}
11131133
return;
@@ -1295,6 +1315,9 @@ export class Clerk implements ClerkInterface {
12951315
if (this.#instanceType === 'development') {
12961316
this.__internal_openEnableOrganizationsPrompt({
12971317
componentName: 'OrganizationSwitcher',
1318+
onComplete: () => {
1319+
this.mountTaskChooseOrganization(node, props);
1320+
},
12981321
});
12991322
}
13001323
return;

packages/clerk-js/src/ui/components/devPrompts/EnableOrganizationsPrompt/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ const EnableOrganizationsPromptInternal = (props: __internal_EnableOrganizations
2424
.__internal_enableEnvironmentSetting({
2525
enable_organizations: true,
2626
})
27-
.then(() => {
27+
.then(async () => {
2828
// Re-fetch environment to get updated settings
2929
// @ts-expect-error - __unstable__environment is not typed
3030
const environment = clerk?.__unstable__environment;
31-
environment.fetch?.();
31+
await environment.fetch?.();
3232
clerk?.__internal_closeEnableOrganizationsPrompt?.();
33+
props.onComplete?.();
3334
})
3435
.finally(() => {
3536
setIsLoading(false);

packages/shared/src/types/clerk.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,13 +1436,16 @@ export type __internal_UserVerificationProps = RoutingOptions & {
14361436

14371437
export type __internal_UserVerificationModalProps = WithoutRouting<__internal_UserVerificationProps>;
14381438

1439-
export type __internal_EnableOrganizationsPromptProps =
1439+
export type __internal_EnableOrganizationsPromptProps = {
1440+
onComplete?: () => void;
1441+
} & (
14401442
| {
14411443
componentName: 'OrganizationSwitcher' | 'OrganizationProfile' | 'OrganizationList';
14421444
}
14431445
| {
14441446
utilityName: 'useOrganizationList' | 'useOrganization';
1445-
};
1447+
}
1448+
);
14461449

14471450
type GoogleOneTapRedirectUrlProps = SignInForceRedirectUrl & SignUpForceRedirectUrl;
14481451

0 commit comments

Comments
 (0)