import { FC } from 'react'; import { useAppSelector } from '../../../../redux/hooks'; import MarkdownPreview from '../../../articleeditor/MarckDownPreview'; import { Edit } from '../../../../assets/icons/input'; function convertDate(isoString: string) { const date = new Date(isoString); const dd = String(date.getUTCDate()).padStart(2, '0'); const mm = String(date.getUTCMonth() + 1).padStart(2, '0'); const yyyy = date.getUTCFullYear(); const hh = String(date.getUTCHours()).padStart(2, '0'); const min = String(date.getUTCMinutes()).padStart(2, '0'); return `${dd}.${mm}.${yyyy} ${hh}:${min}`; } interface PostItemProps { id: number; groupId: number; authorId: number; authorUsername: string; name: string; content: string; createdAt: string; updatedAt: string; isAdmin: boolean; setModalUpdateActive: (v: boolean) => void; setUpdatePostId: (v: number) => void; } export const PostItem: FC = ({ id, authorId, authorUsername, content, createdAt, isAdmin, setModalUpdateActive, setUpdatePostId, }) => { const members = useAppSelector( (state) => state.groups.fetchGroupById.group?.members, ); const member = members?.find((m) => m.userId === authorId); return (
{authorUsername}
{member ? member.role : 'роль не найдена'}
{convertDate(createdAt)}
{isAdmin && (
{ setUpdatePostId(id); setModalUpdateActive(true); }} >
)}
); };