SuggestionToolbar.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { Divider, Popconfirm, Space, Tooltip, Typography } from "antd";
  2. import { LikeOutlined, DeleteOutlined } from "@ant-design/icons";
  3. import { useIntl } from "react-intl";
  4. import type { ISentence } from "../SentEdit";
  5. import PrAcceptButton from "./PrAcceptButton";
  6. import InteractiveButton from "./InteractiveButton";
  7. const { Paragraph } = Typography;
  8. interface IWidget {
  9. data: ISentence;
  10. isPr?: boolean;
  11. style?: React.CSSProperties;
  12. compact?: boolean;
  13. prOpen?: boolean;
  14. onAccept?: (value: ISentence) => void;
  15. onDelete?: () => void;
  16. }
  17. const SuggestionToolbarWidget = ({
  18. data,
  19. isPr = false,
  20. onAccept,
  21. style,
  22. compact = false,
  23. onDelete,
  24. }: IWidget) => {
  25. const intl = useIntl();
  26. return (
  27. <Paragraph type="secondary" style={style}>
  28. {isPr ? (
  29. <Space>
  30. <LikeOutlined />
  31. <Divider type="vertical" />
  32. <PrAcceptButton
  33. data={data}
  34. onAccept={(value: ISentence) => {
  35. if (typeof onAccept !== "undefined") {
  36. onAccept(value);
  37. }
  38. }}
  39. />
  40. <Popconfirm
  41. title={intl.formatMessage({
  42. id: "message.delete.confirm",
  43. })}
  44. placement="right"
  45. onConfirm={() => {
  46. if (typeof onDelete !== "undefined") {
  47. onDelete();
  48. }
  49. }}
  50. okType="danger"
  51. okText={intl.formatMessage({
  52. id: `buttons.delete`,
  53. })}
  54. cancelText={intl.formatMessage({
  55. id: `buttons.no`,
  56. })}
  57. >
  58. <Tooltip
  59. title={intl.formatMessage({
  60. id: `buttons.delete`,
  61. })}
  62. >
  63. <DeleteOutlined />
  64. </Tooltip>
  65. </Popconfirm>
  66. </Space>
  67. ) : (
  68. <InteractiveButton data={data} compact={compact} />
  69. )}
  70. </Paragraph>
  71. );
  72. };
  73. export default SuggestionToolbarWidget;