import { BellOutlined } from "@ant-design/icons";
import { Badge, Spin, Tabs } from "antd";
import useMergedState from "rc-util/es/hooks/useMergedState";
import React from "react";
import classNames from "classnames";
import NoticeList from "./NoticeList";
import HeaderDropdown from "../HeaderDropdown";
import styles from "./index.less";
const { TabPane } = Tabs;
const NoticeIcon = (props) => {
const getNotificationBox = () => {
const {
children,
loading,
onClear,
onTabChange,
onItemClick,
onViewMore,
clearText,
viewMoreText,
} = props;
if (!children) {
return null;
}
const panes = [];
React.Children.forEach(children, (child) => {
if (!child) {
return;
}
const { list, title, count, tabKey, showClear, showViewMore } =
child.props;
const len = list && list.length ? list.length : 0;
const msgCount = count || count === 0 ? count : len;
const tabTitle = msgCount > 0 ? `${title} (${msgCount})` : title;
panes.push(
onClear && onClear(title, tabKey)}
onClick={(item) => onItemClick && onItemClick(item, child.props)}
onViewMore={(event) => onViewMore && onViewMore(child.props, event)}
showClear={showClear}
showViewMore={showViewMore}
title={title}
/>
);
});
return (
<>
{panes}
>
);
};
const { className, count, bell } = props;
const [visible, setVisible] = useMergedState(false, {
value: props.popupVisible,
onChange: props.onPopupVisibleChange,
});
const noticeButtonClass = classNames(className, styles.noticeButton);
const notificationBox = getNotificationBox();
const NoticeBellIcon = bell || ;
const trigger = (
{NoticeBellIcon}
);
if (!notificationBox) {
return trigger;
}
return (
{trigger}
);
};
NoticeIcon.defaultProps = {
emptyImage:
"https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg",
};
NoticeIcon.Tab = NoticeList;
export default NoticeIcon;