import { Avatar } from "antd"; import { useEffect, useState } from "react"; import type { IUser } from "../auth/User" import DiscussionShow from "./DiscussionShow"; import DiscussionEdit from "./DiscussionEdit"; import type { TResType } from "./DiscussionListCard" import type { TDiscussionType } from "./Discussion" export interface IComment { id?: string; //id未提供为新建 resId?: string; resType?: TResType; type: TDiscussionType; tplId?: string; user: IUser; parent?: string | null; title?: string; content?: string; html?: string; summary?: string; status?: "active" | "close"; children?: IComment[]; childrenCount?: number; newTpl?: boolean; createdAt?: string; updatedAt?: string; } interface IWidget { data: IComment; isFocus?: boolean; hideTitle?: boolean; onSelect?: Function; onCreated?: Function; onDelete?: Function; onReply?: Function; onClose?: Function; onConvert?: Function; } const DiscussionItemWidget = ({ data, isFocus = false, hideTitle = false, onSelect, onCreated, onDelete, onReply, onClose, onConvert, }: IWidget) => { const [edit, setEdit] = useState(false); const [currData, setCurrData] = useState(data); useEffect(() => { setCurrData(data); }, [data]); return (
{data.user?.nickName?.slice(0, 1)}
{edit ? ( { setCurrData(e); setEdit(false); }} onCreated={(e: IComment) => { if (typeof onCreated !== "undefined") { onCreated(e); } }} onClose={() => setEdit(false)} /> ) : ( { setEdit(true); }} onSelect={(e: React.MouseEvent) => { if (typeof onSelect !== "undefined") { onSelect(e, currData); } }} onDelete={(_id: string) => { if (typeof onDelete !== "undefined") { onDelete(); } }} onReply={() => { if (typeof onReply !== "undefined") { onReply(currData); } }} onClose={(value: boolean) => { if (typeof onClose !== "undefined") { onClose(value); } }} onConvert={(value: TDiscussionType) => { if (typeof onConvert !== "undefined") { onConvert(value); } }} /> )}
); }; export default DiscussionItemWidget;