@@ -49,7 +49,6 @@ const CreateOrganizationButton = ({
49
49
} ;
50
50
51
51
export const OrganizationListPage = withCardStateProvider ( ( ) => {
52
- const card = useCardState ( ) ;
53
52
const { userMemberships, userSuggestions, userInvitations } = useOrganizationListInView ( ) ;
54
53
const isLoading = userMemberships ?. isLoading || userInvitations ?. isLoading || userSuggestions ?. isLoading ;
55
54
const hasAnyData = ! ! ( userMemberships ?. count || userInvitations ?. count || userSuggestions ?. count ) ;
@@ -59,7 +58,6 @@ export const OrganizationListPage = withCardStateProvider(() => {
59
58
return (
60
59
< Card . Root >
61
60
< Card . Content sx = { t => ( { padding : `${ t . space . $8 } ${ t . space . $none } ${ t . space . $none } ` } ) } >
62
- < Card . Alert sx = { t => ( { margin : `${ t . space . $none } ${ t . space . $5 } ` } ) } > { card . error } </ Card . Alert >
63
61
{ isLoading && (
64
62
< Flex
65
63
direction = { 'row' }
@@ -86,6 +84,7 @@ export const OrganizationListPage = withCardStateProvider(() => {
86
84
} ) ;
87
85
88
86
const OrganizationListFlows = ( { showListInitially } : { showListInitially : boolean } ) => {
87
+ const card = useCardState ( ) ;
89
88
const { navigateAfterCreateOrganization, skipInvitationScreen, hideSlug } = useOrganizationListContext ( ) ;
90
89
const [ isCreateOrganizationFlow , setCreateOrganizationFlow ] = useState ( ! showListInitially ) ;
91
90
return (
@@ -95,30 +94,35 @@ const OrganizationListFlows = ({ showListInitially }: { showListInitially: boole
95
94
) }
96
95
97
96
{ isCreateOrganizationFlow && (
98
- < Box
99
- sx = { t => ( {
100
- padding : `${ t . space . $none } ${ t . space . $5 } ${ t . space . $5 } ` ,
101
- } ) }
102
- >
103
- < CreateOrganizationForm
104
- flow = 'organizationList'
105
- startPage = { { headerTitle : localizationKeys ( 'organizationList.createOrganization' ) } }
106
- skipInvitationScreen = { skipInvitationScreen }
107
- navigateAfterCreateOrganization = { org =>
108
- navigateAfterCreateOrganization ( org ) . then ( ( ) => setCreateOrganizationFlow ( false ) )
109
- }
110
- onCancel = {
111
- showListInitially && isCreateOrganizationFlow ? ( ) => setCreateOrganizationFlow ( false ) : undefined
112
- }
113
- hideSlug = { hideSlug }
114
- />
115
- </ Box >
97
+ < >
98
+ < Card . Alert sx = { t => ( { margin : `${ t . space . $none } ${ t . space . $5 } ` } ) } > { card . error } </ Card . Alert >
99
+
100
+ < Box
101
+ sx = { t => ( {
102
+ padding : `${ t . space . $none } ${ t . space . $5 } ${ t . space . $5 } ` ,
103
+ } ) }
104
+ >
105
+ < CreateOrganizationForm
106
+ flow = 'organizationList'
107
+ startPage = { { headerTitle : localizationKeys ( 'organizationList.createOrganization' ) } }
108
+ skipInvitationScreen = { skipInvitationScreen }
109
+ navigateAfterCreateOrganization = { org =>
110
+ navigateAfterCreateOrganization ( org ) . then ( ( ) => setCreateOrganizationFlow ( false ) )
111
+ }
112
+ onCancel = {
113
+ showListInitially && isCreateOrganizationFlow ? ( ) => setCreateOrganizationFlow ( false ) : undefined
114
+ }
115
+ hideSlug = { hideSlug }
116
+ />
117
+ </ Box >
118
+ </ >
116
119
) }
117
120
</ >
118
121
) ;
119
122
} ;
120
123
121
124
export const OrganizationListPageList = ( props : { onCreateOrganizationClick : ( ) => void } ) => {
125
+ const card = useCardState ( ) ;
122
126
const environment = useEnvironment ( ) ;
123
127
124
128
const { ref, userMemberships, userSuggestions, userInvitations } = useOrganizationListInView ( ) ;
@@ -128,6 +132,9 @@ export const OrganizationListPageList = (props: { onCreateOrganizationClick: ()
128
132
const hasNextPage = userMemberships ?. hasNextPage || userInvitations ?. hasNextPage || userSuggestions ?. hasNextPage ;
129
133
130
134
const onCreateOrganizationClick = ( ) => {
135
+ // Clean error originated from the list when switching to form
136
+ card . setError ( undefined ) ;
137
+
131
138
props . onCreateOrganizationClick ( ) ;
132
139
} ;
133
140
@@ -154,6 +161,7 @@ export const OrganizationListPageList = (props: { onCreateOrganizationClick: ()
154
161
} ) }
155
162
/>
156
163
</ Header . Root >
164
+ < Card . Alert sx = { t => ( { margin : `${ t . space . $none } ${ t . space . $5 } ` } ) } > { card . error } </ Card . Alert >
157
165
< Col elementDescriptor = { descriptors . main } >
158
166
< PreviewListItems >
159
167
< Actions role = 'menu' >
0 commit comments