Skip to content

Commit db991c2

Browse files
committed
Do not render identifier if not email or username
1 parent 790e66a commit db991c2

File tree

3 files changed

+42
-44
lines changed

3 files changed

+42
-44
lines changed

packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskSelectOrganization/index.tsx

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { Card } from '@/ui/elements/Card';
77
import { withCardStateProvider } from '@/ui/elements/contexts';
88
import { Header } from '@/ui/elements/Header';
99
import { useMultipleSessions } from '@/ui/hooks/useMultipleSessions';
10-
import { getIdentifier } from '@/utils/user';
1110

1211
import { useOrganizationListInView } from '../../../OrganizationList/OrganizationListPage';
1312
import { withTaskGuard } from '../withTaskGuard';
@@ -22,9 +21,6 @@ const TaskSelectOrganizationInternal = () => {
2221
const { otherSessions } = useMultipleSessions({ user });
2322
const { navigateAfterSignOut, navigateAfterMultiSessionSingleSignOutUrl } = useSignOutContext();
2423

25-
const isLoading = userMemberships?.isLoading || userInvitations?.isLoading || userSuggestions?.isLoading;
26-
const hasExistingResources = !!(userMemberships?.count || userInvitations?.count || userSuggestions?.count);
27-
2824
const handleSignOut = () => {
2925
if (otherSessions.length === 0) {
3026
return signOut(navigateAfterSignOut);
@@ -33,12 +29,32 @@ const TaskSelectOrganizationInternal = () => {
3329
return signOut(navigateAfterMultiSessionSingleSignOutUrl, { sessionId: session?.id });
3430
};
3531

32+
const isLoading = userMemberships?.isLoading || userInvitations?.isLoading || userSuggestions?.isLoading;
33+
const hasExistingResources = !!(userMemberships?.count || userInvitations?.count || userSuggestions?.count);
34+
const identifier = user?.primaryEmailAddress?.emailAddress ?? user?.username;
35+
3636
return (
3737
<Flow.Root flow='taskSelectOrganization'>
3838
<Card.Root>
39-
{!isLoading && user ? (
40-
<>
41-
<Card.Content sx={t => ({ padding: `${t.space.$8} ${t.space.$none} ${t.space.$none}`, gap: t.space.$6 })}>
39+
<Card.Content sx={t => ({ padding: `${t.space.$8} ${t.space.$none} ${t.space.$none}`, gap: t.space.$6 })}>
40+
{isLoading ? (
41+
<Flex
42+
direction={'row'}
43+
align={'center'}
44+
justify={'center'}
45+
sx={t => ({
46+
height: '100%',
47+
minHeight: t.sizes.$100,
48+
})}
49+
>
50+
<Spinner
51+
size={'lg'}
52+
colorScheme={'primary'}
53+
elementDescriptor={descriptors.spinner}
54+
/>
55+
</Flex>
56+
) : (
57+
<>
4258
<Header.Root
4359
showLogo
4460
sx={t => ({ padding: `${t.space.$none} ${t.space.$8}` })}
@@ -48,43 +64,25 @@ const TaskSelectOrganizationInternal = () => {
4864
</Header.Root>
4965

5066
<TaskSelectOrganizationFlows initialFlow={hasExistingResources ? 'select' : 'create'} />
51-
</Card.Content>
67+
</>
68+
)}
69+
</Card.Content>
5270

53-
<Card.Footer>
54-
<Card.Action elementId='signOut'>
55-
<Card.ActionText
56-
localizationKey={localizationKeys('taskSelectOrganization.signOut.actionText', {
57-
// TODO -> Change this key name to identifier
58-
// TODO -> what happens if the user does not email address? only username or phonenumber
59-
// Signed in as +55482323232
60-
emailAddress: user.primaryEmailAddress?.emailAddress || getIdentifier(user),
61-
})}
62-
/>
63-
<Card.ActionLink
64-
onClick={void handleSignOut}
65-
localizationKey={localizationKeys('taskSelectOrganization.signOut.actionLink')}
66-
/>
67-
</Card.Action>
68-
</Card.Footer>
69-
</>
70-
) : (
71-
// TODO -> Improve loading UI to keep consistent height with SignIn/SignUp
72-
<Flex
73-
direction={'row'}
74-
align={'center'}
75-
justify={'center'}
76-
sx={t => ({
77-
height: '100%',
78-
minHeight: t.sizes.$100,
79-
})}
80-
>
81-
<Spinner
82-
size={'lg'}
83-
colorScheme={'primary'}
84-
elementDescriptor={descriptors.spinner}
71+
<Card.Footer>
72+
<Card.Action elementId='signOut'>
73+
{identifier && (
74+
<Card.ActionText
75+
localizationKey={localizationKeys('taskSelectOrganization.signOut.actionText', {
76+
identifier,
77+
})}
78+
/>
79+
)}
80+
<Card.ActionLink
81+
onClick={handleSignOut}
82+
localizationKey={localizationKeys('taskSelectOrganization.signOut.actionLink')}
8583
/>
86-
</Flex>
87-
)}
84+
</Card.Action>
85+
</Card.Footer>
8886
</Card.Root>
8987
</Flow.Root>
9088
);

packages/localizations/src/en-US.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const enUS: LocalizationResource = {
77
subtitle: 'Tell us a bit about your organization',
88
signOut: {
99
actionLink: 'Sign out',
10-
actionText: 'Signed in as {{emailAddress}}',
10+
actionText: 'Signed in as {{identifier}}',
1111
},
1212
createOrganizationScreen: {
1313
formButtonSubmit: 'Create organization',

packages/types/src/localization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ export type __internal_LocalizationResource = {
12061206
title: LocalizationValue;
12071207
subtitle: LocalizationValue;
12081208
signOut: {
1209-
actionText: LocalizationValue<'emailAddress'>;
1209+
actionText: LocalizationValue<'identifier'>;
12101210
actionLink: LocalizationValue;
12111211
};
12121212
createOrganizationScreen: {

0 commit comments

Comments
 (0)