import React, { memo, type TeactNode } from '../../../lib/teact/teact'; import { getActions } from '../../../global'; import type { ApiPeer } from '../../../api/types'; import type { CustomPeer } from '../../../types'; import buildClassName from '../../../util/buildClassName'; import useLastCallback from '../../../hooks/useLastCallback'; import Avatar from '../../common/Avatar'; import PeerChip from '../../common/PeerChip'; import Button from '../../ui/Button'; import Modal from '../../ui/Modal'; import styles from './TableInfoModal.module.scss'; type ChatItem = { chatId: string; withEmojiStatus?: boolean }; export type TableData = [TeactNode | undefined, TeactNode | ChatItem][]; type OwnProps = { isOpen?: boolean; title?: string; tableData?: TableData; headerAvatarPeer?: ApiPeer | CustomPeer; header?: TeactNode; modalHeader?: TeactNode; footer?: TeactNode; buttonText?: string; className?: string; hasBackdrop?: boolean; onClose: NoneToVoidFunction; onButtonClick?: NoneToVoidFunction; }; const TableInfoModal = ({ isOpen, title, tableData, headerAvatarPeer, header, modalHeader, footer, buttonText, className, hasBackdrop, onClose, onButtonClick, }: OwnProps) => { const { openChat } = getActions(); const handleOpenChat = useLastCallback((peerId: string) => { openChat({ id: peerId }); onClose(); }); return ( {headerAvatarPeer && ( )} {header}
{tableData?.map(([label, value]) => ( <> {label &&
{label}
}
{typeof value === 'object' && 'chatId' in value ? ( ) : value}
))}
{footer} {buttonText && ( )}
); }; export default memo(TableInfoModal);