diff --git a/packages/client/src/pages/ForumItemPage/ForumItemPage.tsx b/packages/client/src/pages/ForumItemPage/ForumItemPage.tsx index 093fd71..73f8e3f 100644 --- a/packages/client/src/pages/ForumItemPage/ForumItemPage.tsx +++ b/packages/client/src/pages/ForumItemPage/ForumItemPage.tsx @@ -10,6 +10,8 @@ import { forums as previeForums } from '../Forum/components/forumPreviewTable/st import { TForum, TMessage, messageFormFileds } from './model' import ForumMessagesList from './components/forumMessagesList/forumMessagesList' import AddMessageFrame from './components/addMessageFrame/addMessageFrame' +import { useTypedSelector } from '../../redux/store' +import { getUserData } from '../../redux/selectors' const ForumPage = () => { const { id } = useParams() @@ -18,7 +20,7 @@ const ForumPage = () => { if (!forum) return const { theme, messages }: TForum = forum const [forumMessages, updateForum] = useState(messages) - + const user = useTypedSelector(getUserData) const callbacks = { onAddMessage: useCallback( (e: FormEvent) => { @@ -32,7 +34,7 @@ const ForumPage = () => { const newMesage: TMessage = { messageId: uuid(), message, - author: 'Admin', + author: user.login ? user.login : 'Author', time: new Date(), } forum.messages.push(newMesage) @@ -52,6 +54,7 @@ const ForumPage = () => { diff --git a/packages/client/src/pages/ForumItemPage/components/addMessageFrame/addMessageFrame.tsx b/packages/client/src/pages/ForumItemPage/components/addMessageFrame/addMessageFrame.tsx index 2523aac..bab0e10 100644 --- a/packages/client/src/pages/ForumItemPage/components/addMessageFrame/addMessageFrame.tsx +++ b/packages/client/src/pages/ForumItemPage/components/addMessageFrame/addMessageFrame.tsx @@ -6,17 +6,19 @@ import './styles.scss' type TAddMessageFrameProps = { inputName: string onAddMessage: (e: FormEvent) => void + name: string } const AddMessageFrame = ({ inputName, onAddMessage, + name = 'Admin', }: TAddMessageFrameProps) => { const cn = bem('addMessageFrame') return (
-
Admin
+
{name}