2
0

SuggestionButton.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Space, Tooltip } from "antd";
  2. import { LikeOutlined, DeleteOutlined } from "@ant-design/icons";
  3. import { ISentence } from "../SentEdit";
  4. import { HandOutlinedIcon } from "../../../assets/icon";
  5. import SuggestionPopover from "./SuggestionPopover";
  6. import store from "../../../store";
  7. import { openPanel } from "../../../reducers/right-panel";
  8. import { show } from "../../../reducers/discussion";
  9. export const prOpen = (data: ISentence) => {
  10. store.dispatch(
  11. show({
  12. type: "pr",
  13. sent: data,
  14. })
  15. );
  16. store.dispatch(openPanel("suggestion"));
  17. };
  18. interface IWidget {
  19. data: ISentence;
  20. hideCount?: boolean;
  21. hideInZero?: boolean;
  22. }
  23. const SuggestionButton = ({
  24. data,
  25. hideCount = false,
  26. hideInZero = false,
  27. }: IWidget) => {
  28. const prNumber = data.suggestionCount?.suggestion;
  29. return hideInZero && prNumber === 0 ? (
  30. <></>
  31. ) : (
  32. <Space
  33. style={{
  34. cursor: "pointer",
  35. color: prNumber && prNumber > 0 ? "#1890ff" : "unset",
  36. }}
  37. onClick={(event) => {
  38. prOpen(data);
  39. }}
  40. >
  41. <Tooltip title="修改建议">
  42. <HandOutlinedIcon />
  43. </Tooltip>
  44. <SuggestionPopover
  45. book={data.book}
  46. para={data.para}
  47. start={data.wordStart}
  48. end={data.wordEnd}
  49. channelId={data.channel.id}
  50. />
  51. {hideCount ? <></> : prNumber}
  52. </Space>
  53. );
  54. };
  55. export default SuggestionButton;