ChannelPicker.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { useState } from "react";
  2. import { Button, Modal } from "antd";
  3. import ChannelPickerTable from "./ChannelPickerTable";
  4. import { IChannel } from "./Channel";
  5. import { ArticleType } from "../article/Article";
  6. interface IWidget {
  7. type?: ArticleType | "editable";
  8. articleId?: string;
  9. multiSelect?: boolean;
  10. }
  11. const Widget = ({ type, articleId, multiSelect }: IWidget) => {
  12. const [isModalOpen, setIsModalOpen] = useState(false);
  13. const showModal = () => {
  14. setIsModalOpen(true);
  15. };
  16. const handleOk = () => {
  17. setIsModalOpen(false);
  18. };
  19. const handleCancel = () => {
  20. setIsModalOpen(false);
  21. };
  22. return (
  23. <>
  24. <Button type="primary" onClick={showModal}>
  25. Select channel
  26. </Button>
  27. <Modal
  28. width={"80%"}
  29. title="选择版本风格"
  30. open={isModalOpen}
  31. onOk={handleOk}
  32. onCancel={handleCancel}
  33. >
  34. <ChannelPickerTable
  35. type={type}
  36. articleId={articleId}
  37. multiSelect={multiSelect}
  38. onSelect={(e: IChannel) => {
  39. console.log(e);
  40. handleCancel();
  41. }}
  42. />
  43. </Modal>
  44. </>
  45. );
  46. };
  47. export default Widget;