|
|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import { GroupPanelType, useGroupInfo } from 'tailchat-shared';
|
|
|
|
|
import { GroupPanelType, isValidStr, useGroupInfo } from 'tailchat-shared';
|
|
|
|
|
import { useParams } from 'react-router';
|
|
|
|
|
import { GroupHeader } from './GroupHeader';
|
|
|
|
|
import { GroupSection } from '@/components/GroupSection';
|
|
|
|
|
@ -10,7 +10,7 @@ interface GroupParams {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 个人面板侧边栏组件
|
|
|
|
|
* 群组面板侧边栏组件
|
|
|
|
|
*/
|
|
|
|
|
export const Sidebar: React.FC = React.memo(() => {
|
|
|
|
|
const { groupId } = useParams<GroupParams>();
|
|
|
|
|
@ -21,24 +21,33 @@ export const Sidebar: React.FC = React.memo(() => {
|
|
|
|
|
<div>
|
|
|
|
|
<GroupHeader groupId={groupId} />
|
|
|
|
|
|
|
|
|
|
<div className="p-2">
|
|
|
|
|
<div className="p-2 space-y-1">
|
|
|
|
|
{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) => (
|
|
|
|
|
<div key={panel.id}>
|
|
|
|
|
<GroupPanelItem
|
|
|
|
|
name={panel.name}
|
|
|
|
|
icon={<div>#</div>}
|
|
|
|
|
to={`/main/group/${groupId}/${panel.id}`}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</GroupSection>
|
|
|
|
|
))}
|
|
|
|
|
.filter((panel) => !isValidStr(panel.parentId))
|
|
|
|
|
.map((panel) =>
|
|
|
|
|
panel.type === GroupPanelType.GROUP ? (
|
|
|
|
|
<GroupSection key={panel.id} header={panel.name}>
|
|
|
|
|
{groupPanels
|
|
|
|
|
.filter((sub) => sub.parentId === panel.id)
|
|
|
|
|
.map((sub) => (
|
|
|
|
|
<div key={sub.id}>
|
|
|
|
|
<GroupPanelItem
|
|
|
|
|
name={sub.name}
|
|
|
|
|
icon={<div>#</div>}
|
|
|
|
|
to={`/main/group/${groupId}/${sub.id}`}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</GroupSection>
|
|
|
|
|
) : (
|
|
|
|
|
<GroupPanelItem
|
|
|
|
|
key={panel.id}
|
|
|
|
|
name={panel.name}
|
|
|
|
|
icon={<div>#</div>}
|
|
|
|
|
to={`/main/group/${groupId}/${panel.id}`}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|