You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailchat/web/src/routes/Main/Content/Group/Sidebar.tsx

46 lines
1.3 KiB
TypeScript

import React from 'react';
import { GroupPanelType, useGroupInfo } from 'tailchat-shared';
import { useParams } from 'react-router';
import { GroupHeader } from './GroupHeader';
import { GroupSection } from '@/components/GroupSection';
import { GroupPanelItem } from '@/components/GroupPanelItem';
interface GroupParams {
groupId: string;
}
/**
*
*/
export const Sidebar: React.FC = React.memo(() => {
const { groupId } = useParams<GroupParams>();
const groupInfo = useGroupInfo(groupId);
const groupPanels = groupInfo?.panels ?? [];
return (
<div>
<GroupHeader groupId={groupId} />
<div className="p-2">
{groupPanels
.filter((panel) => panel.type === GroupPanelType.GROUP)
.map((group) => (
<GroupSection key={group.id} header={group.name}>
{groupPanels
.filter((panel) => panel.parentId === group.id)
.map((panel) => (
<GroupPanelItem
key={panel.id}
name={panel.name}
icon={<div>#</div>}
to={`/main/group/${groupId}/${panel.id}`}
/>
))}
</GroupSection>
))}
</div>
</div>
);
});
Sidebar.displayName = 'Sidebar';