visuddhinanda 1 éve
szülő
commit
101b54bb36

+ 26 - 17
dashboard-v4/dashboard/src/components/template/Builder/ArticleTpl.tsx

@@ -24,16 +24,16 @@ const { Paragraph } = Typography;
 
 
 interface IWidget {
 interface IWidget {
   type?: ArticleType;
   type?: ArticleType;
-  id?: string;
+  articleId?: string;
   title?: string;
   title?: string;
   style?: TDisplayStyle;
   style?: TDisplayStyle;
-  channel?: string;
+  channel?: string | null;
   onSelect?: Function;
   onSelect?: Function;
   onCancel?: Function;
   onCancel?: Function;
 }
 }
 const ArticleTplWidget = ({
 const ArticleTplWidget = ({
   type,
   type,
-  id,
+  articleId,
   channel,
   channel,
   title,
   title,
   style = "modal",
   style = "modal",
@@ -43,11 +43,11 @@ const ArticleTplWidget = ({
   const [currChannel, setCurrChannel] = useState(channel);
   const [currChannel, setCurrChannel] = useState(channel);
   const [styleText, setStyleText] = useState(style);
   const [styleText, setStyleText] = useState(style);
   const [typeText, setTypeText] = useState(type);
   const [typeText, setTypeText] = useState(type);
-  const [idText, setIdText] = useState(id);
+  const [idText, setIdText] = useState(articleId);
   const [tplText, setTplText] = useState("");
   const [tplText, setTplText] = useState("");
   const user = useAppSelector(currentUser);
   const user = useAppSelector(currentUser);
 
 
-  const ids = id?.split("_");
+  const ids = articleId?.split("_");
   const id1 = ids ? ids[0] : undefined;
   const id1 = ids ? ids[0] : undefined;
   const channels = ids
   const channels = ids
     ? ids.length > 1
     ? ids.length > 1
@@ -104,8 +104,8 @@ const ArticleTplWidget = ({
           {"id:"}
           {"id:"}
           <Space>
           <Space>
             <Input
             <Input
-              disabled={id ? true : false}
-              defaultValue={id}
+              disabled={articleId ? true : false}
+              defaultValue={articleId}
               width={400}
               width={400}
               value={idText}
               value={idText}
               placeholder="Id"
               placeholder="Id"
@@ -130,9 +130,9 @@ const ArticleTplWidget = ({
           {"channel:"}
           {"channel:"}
           <Space>
           <Space>
             <Input
             <Input
-              defaultValue={channel}
+              defaultValue={channel ?? ""}
               width={400}
               width={400}
-              value={currChannel}
+              value={currChannel ?? ""}
               placeholder="channel"
               placeholder="channel"
               onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
               onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
                 setCurrChannel(event.target.value);
                 setCurrChannel(event.target.value);
@@ -202,20 +202,22 @@ const ArticleTplWidget = ({
 interface IModalWidget {
 interface IModalWidget {
   open?: boolean;
   open?: boolean;
   type?: ArticleType;
   type?: ArticleType;
-  id?: string;
+  articleId?: string;
+  channelsId?: string | null;
   title?: string;
   title?: string;
   style?: TDisplayStyle;
   style?: TDisplayStyle;
   trigger?: JSX.Element;
   trigger?: JSX.Element;
-  onOpenChange?: Function;
+  onClose?: () => void;
 }
 }
 export const ArticleTplModal = ({
 export const ArticleTplModal = ({
   open = false,
   open = false,
   type,
   type,
-  id,
+  articleId,
+  channelsId,
   title,
   title,
   style = "modal",
   style = "modal",
   trigger,
   trigger,
-  onOpenChange,
+  onClose,
 }: IModalWidget) => {
 }: IModalWidget) => {
   const [isModalOpen, setIsModalOpen] = useState(open);
   const [isModalOpen, setIsModalOpen] = useState(open);
 
 
@@ -230,9 +232,10 @@ export const ArticleTplModal = ({
   };
   };
 
 
   const handleCancel = () => {
   const handleCancel = () => {
-    setIsModalOpen(false);
-    if (typeof onOpenChange !== "undefined") {
-      onOpenChange(false);
+    if (onClose) {
+      onClose();
+    } else {
+      setIsModalOpen(false);
     }
     }
   };
   };
 
 
@@ -247,7 +250,13 @@ export const ArticleTplModal = ({
         onCancel={handleCancel}
         onCancel={handleCancel}
         destroyOnClose
         destroyOnClose
       >
       >
-        <ArticleTplWidget type={type} id={id} title={title} style={style} />
+        <ArticleTplWidget
+          type={type}
+          articleId={articleId}
+          channel={channelsId}
+          title={title}
+          style={style}
+        />
       </Modal>
       </Modal>
     </>
     </>
   );
   );