@@ -7,7 +7,6 @@ import { Card } from '@/ui/elements/Card';
7
7
import { withCardStateProvider } from '@/ui/elements/contexts' ;
8
8
import { Header } from '@/ui/elements/Header' ;
9
9
import { useMultipleSessions } from '@/ui/hooks/useMultipleSessions' ;
10
- import { getIdentifier } from '@/utils/user' ;
11
10
12
11
import { useOrganizationListInView } from '../../../OrganizationList/OrganizationListPage' ;
13
12
import { withTaskGuard } from '../withTaskGuard' ;
@@ -22,9 +21,6 @@ const TaskSelectOrganizationInternal = () => {
22
21
const { otherSessions } = useMultipleSessions ( { user } ) ;
23
22
const { navigateAfterSignOut, navigateAfterMultiSessionSingleSignOutUrl } = useSignOutContext ( ) ;
24
23
25
- const isLoading = userMemberships ?. isLoading || userInvitations ?. isLoading || userSuggestions ?. isLoading ;
26
- const hasExistingResources = ! ! ( userMemberships ?. count || userInvitations ?. count || userSuggestions ?. count ) ;
27
-
28
24
const handleSignOut = ( ) => {
29
25
if ( otherSessions . length === 0 ) {
30
26
return signOut ( navigateAfterSignOut ) ;
@@ -33,12 +29,32 @@ const TaskSelectOrganizationInternal = () => {
33
29
return signOut ( navigateAfterMultiSessionSingleSignOutUrl , { sessionId : session ?. id } ) ;
34
30
} ;
35
31
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
+
36
36
return (
37
37
< Flow . Root flow = 'taskSelectOrganization' >
38
38
< 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
+ < >
42
58
< Header . Root
43
59
showLogo
44
60
sx = { t => ( { padding : `${ t . space . $none } ${ t . space . $8 } ` } ) }
@@ -48,43 +64,25 @@ const TaskSelectOrganizationInternal = () => {
48
64
</ Header . Root >
49
65
50
66
< TaskSelectOrganizationFlows initialFlow = { hasExistingResources ? 'select' : 'create' } />
51
- </ Card . Content >
67
+ </ >
68
+ ) }
69
+ </ Card . Content >
52
70
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' ) }
85
83
/>
86
- </ Flex >
87
- ) }
84
+ </ Card . Action >
85
+ </ Card . Footer >
88
86
</ Card . Root >
89
87
</ Flow . Root >
90
88
) ;
0 commit comments