import React, { useEffect, useState } from "react"; import { Modal } from "antd"; import type { ArticleType } from "../article/Article"; import ChannelTable, { type IChapter } from "./ChannelTable"; import { useAppSelector } from "../../hooks"; import { currentUser as _currentUser } from "../../reducers/current-user"; import type { IChannel } from "./Channel"; import type { TChannelType } from "../../api/Channel"; import { useIntl } from "react-intl"; interface IWidget { trigger?: React.ReactNode; channelType?: TChannelType; type?: ArticleType | "editable"; articleId?: string; multiSelect?: boolean; disableChannels?: string[]; open?: boolean; chapter?: IChapter; onClose?: () => void; onSelect?: (channel: IChannel) => void; } const ChannelTableModalWidget = ({ trigger, type, disableChannels, channelType, open = false, chapter, onClose, onSelect, }: IWidget) => { const [isModalOpen, setIsModalOpen] = useState(open); const intl = useIntl(); const user = useAppSelector(_currentUser); useEffect(() => { setIsModalOpen(open); }, [open]); const showModal = () => { setIsModalOpen(true); }; const handleOk = () => { setIsModalOpen(false); if (typeof onClose !== "undefined") { onClose(); } }; const handleCancel = () => { setIsModalOpen(false); if (typeof onClose !== "undefined") { onClose(); } }; return ( <> {trigger}
{ handleCancel(); if (typeof onClose !== "undefined") { onClose(); } if (typeof onSelect !== "undefined") { onSelect(channel); } }} />
); }; export default ChannelTableModalWidget;