import React, { memo, type TeactNode } from '../../../lib/teact/teact'; import { getActions } from '../../../global'; import type { ApiPeer, ApiWebDocument } from '../../../api/types'; import type { CustomPeer } from '../../../types'; import buildClassName from '../../../util/buildClassName'; import useLastCallback from '../../../hooks/useLastCallback'; import Avatar from '../../common/Avatar'; import PickerSelectedItem from '../../common/pickers/PickerSelectedItem'; import Button from '../../ui/Button'; import Modal from '../../ui/Modal'; import styles from './TableInfoModal.module.scss'; import StarsBackground from '../../../assets/stars-bg.png'; type ChatItem = { chatId: string }; export type TableData = [TeactNode, TeactNode | ChatItem][]; type OwnProps = { isOpen?: boolean; title?: string; tableData?: TableData; headerImageUrl?: string; logoBackground?: string; headerAvatarPeer?: ApiPeer | CustomPeer; headerAvatarWebPhoto?: ApiWebDocument; noHeaderImage?: boolean; isGift?: boolean; isPrizeStars?: boolean; header?: TeactNode; footer?: TeactNode; buttonText?: string; className?: string; onClose: NoneToVoidFunction; onButtonClick?: NoneToVoidFunction; }; const TableInfoModal = ({ isOpen, title, tableData, headerImageUrl, logoBackground, headerAvatarPeer, headerAvatarWebPhoto, noHeaderImage, isGift, isPrizeStars, header, footer, buttonText, className, onClose, onButtonClick, }: OwnProps) => { const { openChat } = getActions(); const handleOpenChat = useLastCallback((peerId: string) => { openChat({ id: peerId }); onClose(); }); const withAvatar = Boolean(headerAvatarPeer || headerAvatarWebPhoto); return ( {!isGift && !isPrizeStars && !noHeaderImage && ( withAvatar ? ( ) : (
{Boolean(logoBackground) && }
) )} {header} {tableData?.map(([label, value]) => ( ))}
{label} {typeof value === 'object' && 'chatId' in value ? ( ) : value}
{footer} {buttonText && ( )}
); }; export default memo(TableInfoModal);