🔨 refactor(ApiModal/index.tsx): import PopUpContext from correct file path to fix module import error
✨ feat(ApiModal/index.tsx): add closeEdit and setCloseEdit functions to PopUpContext to handle closing of edit modal 🔨 refactor(ApiModal/index.tsx): remove unused imports and variables to improve code readability 🔨 refactor(ApiModal/index.tsx): remove commented out code to clean up codebase 🔨 refactor(ApiModal/index.tsx): remove unused useEffect dependencies to improve code readability 🔨 refactor(ApiModal/index.tsx): remove unused setOpen function parameter to clean up codebase
This commit is contained in:
parent
dde4ed07ef
commit
663c5b1c4e
1 changed files with 40 additions and 12 deletions
|
|
@ -50,6 +50,7 @@ import { TabsContext } from "../../contexts/tabsContext";
|
||||||
import { FlowType } from "../../types/flow/index";
|
import { FlowType } from "../../types/flow/index";
|
||||||
import { buildTweaks, classNames } from "../../utils";
|
import { buildTweaks, classNames } from "../../utils";
|
||||||
import BaseModal from "../baseModal";
|
import BaseModal from "../baseModal";
|
||||||
|
import { PopUpContext } from "../../contexts/popUpContext";
|
||||||
|
|
||||||
const ApiModal = forwardRef(
|
const ApiModal = forwardRef(
|
||||||
(
|
(
|
||||||
|
|
@ -62,12 +63,14 @@ const ApiModal = forwardRef(
|
||||||
},
|
},
|
||||||
ref
|
ref
|
||||||
) => {
|
) => {
|
||||||
|
const { closeEdit, setCloseEdit } = useContext(PopUpContext);
|
||||||
const [activeTab, setActiveTab] = useState("0");
|
const [activeTab, setActiveTab] = useState("0");
|
||||||
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
||||||
const [openAccordion, setOpenAccordion] = useState([]);
|
const [openAccordion, setOpenAccordion] = useState([]);
|
||||||
const tweak = useRef([]);
|
const tweak = useRef([]);
|
||||||
const tweaksList = useRef([]);
|
const tweaksList = useRef([]);
|
||||||
const { setTweak, getTweak, tabsState } = useContext(TabsContext);
|
const { setTweak, getTweak, tabsState } = useContext(TabsContext);
|
||||||
|
|
||||||
const copyToClipboard = () => {
|
const copyToClipboard = () => {
|
||||||
if (!navigator.clipboard || !navigator.clipboard.writeText) {
|
if (!navigator.clipboard || !navigator.clipboard.writeText) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -108,25 +111,45 @@ const ApiModal = forwardRef(
|
||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (closeEdit !== "") {
|
||||||
if(flow["data"]["nodes"].length == 0){
|
tweak.current = getTweak;
|
||||||
tweak.current = [];
|
|
||||||
setTweak(tweak.current);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
else{
|
|
||||||
if (tweak.current.length > 0) {
|
if (tweak.current.length > 0) {
|
||||||
tweak.current = getTweak;
|
setActiveTab("3");
|
||||||
|
openAccordions();
|
||||||
} else {
|
} else {
|
||||||
startTweaks();
|
startTweaks();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (tweak?.current) {
|
||||||
|
startTweaks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}, [closeEdit]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
filterNodes();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
|
||||||
|
// if(flow["data"]["nodes"].length == 0){
|
||||||
|
// tweak.current = [];
|
||||||
|
// setTweak(tweak.current);
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// else{
|
||||||
|
// if (tweak.current.length > 0) {
|
||||||
|
// tweak.current = getTweak;
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// startTweaks();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}, [flow["data"]["nodes"]]);
|
// }, [flow["data"]["nodes"]]);
|
||||||
|
|
||||||
function startTweaks() {
|
function startTweaks() {
|
||||||
const t = buildTweaks(flow);
|
const t = buildTweaks(flow);
|
||||||
|
|
@ -265,8 +288,13 @@ const ApiModal = forwardRef(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setOpen = (x: boolean) => {
|
||||||
|
setCloseEdit("");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseModal>
|
<BaseModal setOpen={setOpen}>
|
||||||
<BaseModal.Trigger>{children}</BaseModal.Trigger>
|
<BaseModal.Trigger>{children}</BaseModal.Trigger>
|
||||||
<BaseModal.Header description={EXPORT_CODE_DIALOG}>
|
<BaseModal.Header description={EXPORT_CODE_DIALOG}>
|
||||||
<span className="pr-2">Code</span>
|
<span className="pr-2">Code</span>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue