Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useState } from "react";
import { useParams } from "react-router-dom";
import ForwardedIconComponent from "@/components/common/genericIconComponent";
import { convertTestName } from "@/components/common/storeCardComponent/utils/convert-test-name";
Expand All @@ -22,12 +23,22 @@ export default function TemplateGetStartedCardComponent({

const folderIdUrl = folderId ?? myCollectionId;

const [loading, setLoading] = useState(false);

const handleClick = () => {
if (loading) return;

if (flow) {
setLoading(true);
updateIds(flow.data!);
addFlow({ flow }).then((id) => {
navigate(`/flow/${id}/folder/${folderIdUrl}`);
});
addFlow({ flow })
.then((id) => {
navigate(`/flow/${id}/folder/${folderIdUrl}`);
})
.finally(() => {
setLoading(false);
});

track("New Flow Created", { template: `${flow.name} Template` });
} else {
console.error(`Flow template not found`);
Expand Down
17 changes: 12 additions & 5 deletions src/frontend/src/modals/templatesModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function TemplatesModal({
setOpen,
}: newFlowModalPropsType): JSX.Element {
const [currentTab, setCurrentTab] = useState("get-started");
const [loading, setLoading] = useState(false);
const addFlow = useAddFlow();
const navigate = useCustomNavigate();
const { folderId } = useParams();
Expand Down Expand Up @@ -86,11 +87,17 @@ export default function TemplatesModal({
</div>
<Button
onClick={() => {
addFlow().then((id) => {
navigate(
`/flow/${id}${folderId ? `/folder/${folderId}` : ""}`,
);
});
if (loading) return;
setLoading(true);
addFlow()
.then((id) => {
navigate(
`/flow/${id}${folderId ? `/folder/${folderId}` : ""}`,
);
})
.finally(() => {
setLoading(false);
});
track("New Flow Created", { template: "Blank Flow" });
}}
size="sm"
Expand Down
Loading