import React from 'react'; import { Avatar, List } from 'antd'; import classNames from 'classnames'; import styles from './NoticeList.less'; export default function NoticeList({ data = [], onClick, onClear, title, locale, emptyText, emptyImage, showClear = true, }) { 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)}> {leftIcon}} title={
{item.title}
{item.extra}
} description={
{item.description}
{item.datetime}
} />
); })}
{showClear ? (
{locale.clear} {title}
) : null}
); }