From fd3787760d5b6cc34ee9d543b49c4c7439f33868 Mon Sep 17 00:00:00 2001 From: AtsushiM Date: Thu, 16 Jan 2025 16:17:07 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20Header=E5=86=85=E3=81=ABTenantSwitcher?= =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Header/Header.tsx | 69 +++++++++++-------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/packages/smarthr-ui/src/components/Header/Header.tsx b/packages/smarthr-ui/src/components/Header/Header.tsx index 48028c29de..7eb8347dca 100644 --- a/packages/smarthr-ui/src/components/Header/Header.tsx +++ b/packages/smarthr-ui/src/components/Header/Header.tsx @@ -100,15 +100,6 @@ export const Header: React.FC & ElementProps> = ({ [logo, enableNew], ) - const currentTenantName = useMemo(() => { - if (tenants && tenants.length >= 1) { - const current = tenants.find(({ id }) => id === currentTenantId) - return current ? current.name : tenants[0].name - } - - return undefined - }, [currentTenantId, tenants]) - return ( @@ -118,19 +109,12 @@ export const Header: React.FC & ElementProps> = ({ {enableNew ? ( ) : ( - currentTenantName && ( -
- {tenants && tenants.length > 1 ? ( - - ) : ( - {currentTenantName} - )} -
- ) + )}
@@ -154,6 +138,39 @@ const MemoizedAppLauncher = React.memo & { + styles: { tenantInfo: string; tenantNameText: string } + } +>(({ currentTenantId, tenants, styles, onTenantSelect }) => { + const currentTenantName = useMemo(() => { + if (tenants && tenants.length >= 1) { + const current = tenants.find(({ id }) => id === currentTenantId) + return current ? current.name : tenants[0].name + } + + return undefined + }, [currentTenantId, tenants]) + + return ( + currentTenantName && ( +
+ {tenants && tenants.length > 1 ? ( + + ) : ( + + {currentTenantName} + + )} +
+ ) + ) +}) + const MultiTenantDropdownMenuButton = React.memo< Pick, 'tenants'> & Pick & { label: string } >(({ label, tenants, onTenantSelect }) => { @@ -177,11 +194,3 @@ const MultiTenantDropdownMenuButton = React.memo< ) }) - -const OnlyOneTenant = React.memo>( - ({ className, children }) => ( - - {children} - - ), -)