import { Button, Divider, Input, Typography } from 'antd'; import React, { useCallback, useRef, useState } from 'react'; import { createGroup, GroupPanelType, useAppDispatch, useAsyncRequest, } from 'tailchat-shared'; import type { GroupPanel } from 'tailchat-shared'; import { Avatar } from '../Avatar'; import { closeModal, ModalWrapper } from '../Modal'; import { Slides, SlidesRef } from '../Slides'; import { groupActions } from '../../../../shared/redux/slices'; const panelTemplate: { key: string; label: string; panels: GroupPanel[]; }[] = [ { key: 'default', label: '默认群组', panels: [ { id: '00', name: '文字频道', type: GroupPanelType.GROUP, }, { id: '01', name: '大厅', parentId: '00', type: GroupPanelType.TEXT, }, ], }, { key: 'work', label: '工作协同', panels: [ { id: '00', name: '公共', type: GroupPanelType.GROUP, }, { id: '01', name: '全员', parentId: '00', type: GroupPanelType.TEXT, }, { id: '10', name: '临时会议', type: GroupPanelType.GROUP, }, { id: '11', name: '会议室1', parentId: '10', type: GroupPanelType.TEXT, }, { id: '11', name: '会议室2', parentId: '10', type: GroupPanelType.TEXT, }, ], }, ]; export const ModalCreateGroup: React.FC = React.memo(() => { const slidesRef = useRef(null); const [panels, setPanels] = useState([]); const [name, setName] = useState(''); const dispatch = useAppDispatch(); const handleSelectTemplate = useCallback((panels: GroupPanel[]) => { setPanels(panels); slidesRef.current?.next(); }, []); const handleBack = useCallback(() => { slidesRef.current?.prev(); }, []); const [{ loading }, handleCreate] = useAsyncRequest(async () => { const data = await createGroup(name, panels); dispatch(groupActions.appendGroups([data])); closeModal(); }, [name, panels]); return (
创建群组 选择以下模板, 开始创建属于自己的群组吧!
{panelTemplate.map((template, index) => ( <> {/* Hardcode: 将第一个模板与之后的模板区分开 */} {index === 1 && }
handleSelectTemplate(template.panels)} > {template.label}
))}
自定义你的群组 不要担心, 在此之后你可以随时进行变更
{/* TODO */}
群组名称:
setName(e.target.value)} />
); }); ModalCreateGroup.displayName = 'ModalCreateGroup';