diff --git a/packages/client/src/components/organization/switcher/index.tsx b/packages/client/src/components/organization/switcher/index.tsx index 2fcf4a1e..e2ee8ec0 100644 --- a/packages/client/src/components/organization/switcher/index.tsx +++ b/packages/client/src/components/organization/switcher/index.tsx @@ -5,6 +5,7 @@ import { DataRender } from 'components/data-render'; import { useOrganizationDetail, useUserOrganizations } from 'data/organization'; import { useRouterQuery } from 'hooks/use-router-query'; import Link from 'next/link'; +import { useMemo } from 'react'; import styles from './index.module.scss'; @@ -17,6 +18,11 @@ export const UserOrganizationsSwitcher = () => { loading: userOrganizationsLoading, error: userOrganizationsError, } = useUserOrganizations(); + const filterUserOrganizations = useMemo(() => { + return userOrganizations && userOrganizations.length + ? userOrganizations.filter((org) => org.id !== organizationId) + : []; + }, [userOrganizations, organizationId]); return ( { normalContent={() => { return ( - {userOrganizations.length ? ( + {filterUserOrganizations.length ? ( <> - {userOrganizations - .filter((org) => org.id !== organizationId) - .map((org) => { - return ( - - - - - - {org.name} - - - - - ); - })} + {filterUserOrganizations.map((org) => { + return ( + + + + + + {org.name} + + + + + ); + })} ) : null}