SentTabButtonWbw.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { useIntl } from "react-intl";
  2. import { Badge, Dropdown } from "antd";
  3. import type { MenuProps } from "antd";
  4. import { BlockOutlined, CalendarOutlined } from "@ant-design/icons";
  5. const handleButtonClick = (e: React.MouseEvent<HTMLButtonElement>) => {
  6. console.log("click left button", e);
  7. };
  8. interface IWidget {
  9. style?: React.CSSProperties;
  10. sentId: string;
  11. count?: number;
  12. onMenuClick?: Function;
  13. }
  14. const SentTabButtonWidget = ({
  15. style,
  16. ___sentId,
  17. onMenuClick,
  18. count = 0,
  19. }: IWidget) => {
  20. const intl = useIntl();
  21. const items: MenuProps["items"] = [
  22. {
  23. label: "排序",
  24. key: "orderby",
  25. icon: <CalendarOutlined />,
  26. children: [
  27. {
  28. label: "完成度",
  29. key: "progress",
  30. },
  31. {
  32. label: "问题数量",
  33. key: "qa",
  34. },
  35. ],
  36. },
  37. {
  38. label: "显示完成度",
  39. key: "show-progress",
  40. icon: <BlockOutlined />,
  41. },
  42. ];
  43. const handleMenuClick: MenuProps["onClick"] = (e) => {
  44. e.domEvent.stopPropagation();
  45. if (typeof onMenuClick !== "undefined") {
  46. onMenuClick(e.keyPath);
  47. }
  48. };
  49. const menuProps = {
  50. items,
  51. onClick: handleMenuClick,
  52. };
  53. return (
  54. <Dropdown.Button
  55. style={style}
  56. size="small"
  57. type="text"
  58. menu={menuProps}
  59. onClick={handleButtonClick}
  60. >
  61. {intl.formatMessage({
  62. id: "buttons.wbw",
  63. })}
  64. <Badge size="small" color="geekblue" count={count}></Badge>
  65. </Dropdown.Button>
  66. );
  67. };
  68. export default SentTabButtonWidget;