@@ -20,24 +20,21 @@ import { useSwitchToParentAccount } from 'src/features/Account/SwitchAccounts/us
2020import { setTokenInLocalStorage } from 'src/features/Account/SwitchAccounts/utils' ;
2121import { useIsIAMDelegationEnabled } from 'src/features/IAM/hooks/useIsIAMEnabled' ;
2222import { sendSwitchToParentAccountEvent } from 'src/utilities/analytics/customEventAnalytics' ;
23- import { getStorage , setStorage , storage } from 'src/utilities/storage' ;
23+ import { getStorage , storage } from 'src/utilities/storage' ;
2424
2525import { ChildAccountList } from './SwitchAccounts/ChildAccountList' ;
2626import { ChildAccountsTable } from './SwitchAccounts/ChildAccountsTable' ;
2727import { updateParentTokenInLocalStorage } from './SwitchAccounts/utils' ;
2828
2929import type { APIError , Filter , UserType } from '@linode/api-v4' ;
3030
31- const SWITCH_ACCOUNT_COMPANY_KEY = 'switch_account/company_name' ;
32-
3331interface Props {
3432 onClose : ( ) => void ;
3533 open : boolean ;
3634 userType : undefined | UserType ;
3735}
3836
3937interface HandleSwitchToChildAccountProps {
40- company ?: string ;
4138 currentTokenWithBearer ?: string ;
4239 euuid : string ;
4340 event : React . MouseEvent < HTMLElement > ;
@@ -131,12 +128,11 @@ export const SwitchAccountDrawer = (props: Props) => {
131128 event,
132129 onClose,
133130 userType,
134- company,
135131 } : HandleSwitchToChildAccountProps ) => {
136132 const isProxyOrDelegateUserType =
137133 userType === 'proxy' || userType === 'delegate' ;
134+
138135 try {
139- setStorage ( SWITCH_ACCOUNT_COMPANY_KEY , company ?? '' ) ;
140136 if ( isProxyOrDelegateUserType ) {
141137 // Revoke proxy token before switching accounts.
142138 await revokeToken ( ) . catch ( ( ) => {
@@ -166,7 +162,6 @@ export const SwitchAccountDrawer = (props: Props) => {
166162 location . replace ( '/linodes' ) ;
167163 } catch {
168164 // Error is handled by createTokenError.
169- setStorage ( SWITCH_ACCOUNT_COMPANY_KEY , '' ) ;
170165 }
171166 } ,
172167 [ createToken , isProxyUserType , updateCurrentToken , revokeToken ]
@@ -248,7 +243,7 @@ export const SwitchAccountDrawer = (props: Props) => {
248243 .
249244 </ Typography >
250245
251- { hasError && (
246+ { hasError ? (
252247 < Stack alignItems = "center" gap = { 1 } justifyContent = "center" >
253248 < ErrorStateCloud />
254249 < Typography > Unable to load data.</ Typography >
@@ -265,8 +260,7 @@ export const SwitchAccountDrawer = (props: Props) => {
265260 Try again
266261 </ Button >
267262 </ Stack >
268- ) }
269- { ! hasError && (
263+ ) : (
270264 < >
271265 < DebouncedSearchTextField
272266 clearable
@@ -292,51 +286,52 @@ export const SwitchAccountDrawer = (props: Props) => {
292286 No search results
293287 </ Typography >
294288 ) }
289+
290+ { isIAMDelegationEnabled && (
291+ < ChildAccountsTable
292+ childAccounts = { childAccounts }
293+ currentTokenWithBearer = {
294+ isProxyOrDelegateUserType
295+ ? currentParentTokenWithBearer
296+ : currentTokenWithBearer
297+ }
298+ filter = { filter }
299+ isLoading = { isLoading }
300+ isSwitchingChildAccounts = { isSwitchingChildAccounts }
301+ onClose = { onClose }
302+ onPageChange = { handlePageChange }
303+ onPageSizeChange = { handlePageSizeChange }
304+ onSwitchAccount = { handleSwitchToChildAccount }
305+ page = { page }
306+ pageSize = { pageSize }
307+ setIsSwitchingChildAccounts = { setIsSwitchingChildAccounts }
308+ totalResults = { delegatedChildAccounts ?. results || 0 }
309+ userType = { userType }
310+ />
311+ ) }
312+ { ! isIAMDelegationEnabled && (
313+ < ChildAccountList
314+ childAccounts = { childAccounts }
315+ currentTokenWithBearer = {
316+ isProxyOrDelegateUserType
317+ ? currentParentTokenWithBearer
318+ : currentTokenWithBearer
319+ }
320+ fetchNextPage = { fetchNextPage }
321+ filter = { filter }
322+ hasNextPage = { hasNextPage }
323+ isFetchingNextPage = { isFetchingNextPage }
324+ isLoading = { isLoading }
325+ isSwitchingChildAccounts = { isSwitchingChildAccounts }
326+ onClose = { onClose }
327+ onSwitchAccount = { handleSwitchToChildAccount }
328+ refetchFn = { refetchFn }
329+ setIsSwitchingChildAccounts = { setIsSwitchingChildAccounts }
330+ userType = { userType }
331+ />
332+ ) }
295333 </ >
296334 ) }
297- { isIAMDelegationEnabled && (
298- < ChildAccountsTable
299- childAccounts = { childAccounts }
300- currentTokenWithBearer = {
301- isProxyOrDelegateUserType
302- ? currentParentTokenWithBearer
303- : currentTokenWithBearer
304- }
305- filter = { filter }
306- isLoading = { isLoading }
307- isSwitchingChildAccounts = { isSwitchingChildAccounts }
308- onClose = { onClose }
309- onPageChange = { handlePageChange }
310- onPageSizeChange = { handlePageSizeChange }
311- onSwitchAccount = { handleSwitchToChildAccount }
312- page = { page }
313- pageSize = { pageSize }
314- setIsSwitchingChildAccounts = { setIsSwitchingChildAccounts }
315- totalResults = { delegatedChildAccounts ?. results || 0 }
316- userType = { userType }
317- />
318- ) }
319- { ! isIAMDelegationEnabled && (
320- < ChildAccountList
321- childAccounts = { childAccounts }
322- currentTokenWithBearer = {
323- isProxyOrDelegateUserType
324- ? currentParentTokenWithBearer
325- : currentTokenWithBearer
326- }
327- fetchNextPage = { fetchNextPage }
328- filter = { filter }
329- hasNextPage = { hasNextPage }
330- isFetchingNextPage = { isFetchingNextPage }
331- isLoading = { isLoading }
332- isSwitchingChildAccounts = { isSwitchingChildAccounts }
333- onClose = { onClose }
334- onSwitchAccount = { handleSwitchToChildAccount }
335- refetchFn = { refetchFn }
336- setIsSwitchingChildAccounts = { setIsSwitchingChildAccounts }
337- userType = { userType }
338- />
339- ) }
340335 </ Drawer >
341336 ) ;
342337} ;
0 commit comments