SentTabButtonWbw.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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?: (keyPath: string[]) => void;
  13. }
  14. const SentTabButtonWidget = ({ style, onMenuClick, count = 0 }: IWidget) => {
  15. const intl = useIntl();
  16. const items: MenuProps["items"] = [
  17. {
  18. label: "排序",
  19. key: "orderby",
  20. icon: <CalendarOutlined />,
  21. children: [
  22. {
  23. label: "完成度",
  24. key: "progress",
  25. },
  26. {
  27. label: "问题数量",
  28. key: "qa",
  29. },
  30. ],
  31. },
  32. {
  33. label: "显示完成度",
  34. key: "show-progress",
  35. icon: <BlockOutlined />,
  36. },
  37. ];
  38. const handleMenuClick: MenuProps["onClick"] = (e) => {
  39. e.domEvent.stopPropagation();
  40. if (typeof onMenuClick !== "undefined") {
  41. onMenuClick(e.keyPath);
  42. }
  43. };
  44. const menuProps = {
  45. items,
  46. onClick: handleMenuClick,
  47. };
  48. return (
  49. <Dropdown.Button
  50. style={style}
  51. size="small"
  52. type="text"
  53. menu={menuProps}
  54. onClick={handleButtonClick}
  55. >
  56. {intl.formatMessage({
  57. id: "buttons.wbw",
  58. })}
  59. <Badge size="small" color="geekblue" count={count}></Badge>
  60. </Dropdown.Button>
  61. );
  62. };
  63. export default SentTabButtonWidget;