import { Avatar, List } from 'antd'; import classNames from 'classnames'; import React from 'react'; import { NoticeIconData } from './index'; import styles from './NoticeList.less'; export interface NoticeIconTabProps { count?: number; emptyText?: React.ReactNode; emptyImage?: string; list?: NoticeIconData[]; name?: string; showClear?: boolean; showViewMore?: boolean; style?: React.CSSProperties; title?: string; data?: any[]; onClick: (item: any) => void; onClear: (item: any) => void; locale: any; onViewMore: (e: any) => void; } const NoticeList: React.FC = ({ data = [], onClick, onClear, title, locale, emptyText, emptyImage, onViewMore = null, showClear = true, showViewMore = false, }) => { if (data.length === 0) { return (
{emptyImage ? not found : null}
{emptyText || locale.emptyText}
); } return (
{data.map((item, i) => { const itemCls = classNames(styles.item, { [styles.read]: item.read, }); // eslint-disable-next-line no-nested-ternary const leftIcon = item.avatar ? ( typeof item.avatar === 'string' ? ( ) : ( {item.avatar} ) ) : null; return ( onClick(item)}> {item.title}
{item.extra}
} description={
{item.description}
{item.datetime}
} /> ); })}
{showClear ? (
{locale.clear} {locale[title] || title}
) : null} {showViewMore ?
{locale.viewMore}
: null}
); }; export default NoticeList;