client: filter current organization

This commit is contained in:
fantasticit 2022-06-30 21:59:14 +08:00
parent 85a12fb03c
commit f1a788fce1
1 changed files with 31 additions and 28 deletions

View File

@ -11,6 +11,7 @@ import styles from './index.module.scss';
const { Text, Paragraph } = Typography; const { Text, Paragraph } = Typography;
export const UserOrganizationsSwitcher = () => { export const UserOrganizationsSwitcher = () => {
const { organizationId } = useRouterQuery<{ organizationId: string }>();
const { const {
data: userOrganizations, data: userOrganizations,
loading: userOrganizationsLoading, loading: userOrganizationsLoading,
@ -29,34 +30,36 @@ export const UserOrganizationsSwitcher = () => {
<Dropdown.Menu> <Dropdown.Menu>
{userOrganizations.length ? ( {userOrganizations.length ? (
<> <>
{userOrganizations.map((org) => { {userOrganizations
return ( .filter((org) => org.id !== organizationId)
<Dropdown.Item key={org.id} style={{ padding: 0 }}> .map((org) => {
<Link return (
href={{ <Dropdown.Item key={org.id} style={{ padding: 0 }}>
pathname: '/app/org/[organizationId]', <Link
query: { href={{
organizationId: org.id, pathname: '/app/org/[organizationId]',
}, query: {
}} organizationId: org.id,
> },
<a style={{ display: 'flex', alignItems: 'center', width: '100%', padding: '8px 16px' }}> }}
<Avatar size="extra-small" src={org.logo} style={{ marginRight: 8 }} /> >
<Paragraph <a style={{ display: 'flex', alignItems: 'center', width: '100%', padding: '8px 16px' }}>
style={{ <Avatar size="extra-small" src={org.logo} style={{ marginRight: 8 }} />
maxWidth: 100, <Paragraph
whiteSpace: 'nowrap', style={{
textOverflow: 'ellipsis', maxWidth: 100,
overflow: 'hidden', whiteSpace: 'nowrap',
}} textOverflow: 'ellipsis',
> overflow: 'hidden',
{org.name} }}
</Paragraph> >
</a> {org.name}
</Link> </Paragraph>
</Dropdown.Item> </a>
); </Link>
})} </Dropdown.Item>
);
})}
<Dropdown.Divider /> <Dropdown.Divider />
</> </>
) : null} ) : null}