fix: Fix broken state from an invalid folderId in the path (#8790)
* Fix the invalid folderId path * log fix
This commit is contained in:
parent
087fa34a57
commit
7d44121691
2 changed files with 15 additions and 2 deletions
|
|
@ -84,8 +84,7 @@ function NoteNode({
|
|||
),
|
||||
[data, bgColor, selected],
|
||||
);
|
||||
console.log(nodeData);
|
||||
console.log();
|
||||
|
||||
return (
|
||||
<>
|
||||
<NodeResizer
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {
|
|||
ENABLE_DATASTAX_LANGFLOW,
|
||||
ENABLE_MCP,
|
||||
} from "@/customization/feature-flags";
|
||||
import { useCustomNavigate } from "@/customization/hooks/use-custom-navigate";
|
||||
import useFlowsManagerStore from "@/stores/flowsManagerStore";
|
||||
import { useFolderStore } from "@/stores/foldersStore";
|
||||
import { FlowType } from "@/types/flow";
|
||||
|
|
@ -30,6 +31,7 @@ const HomePage = ({ type }: { type: "flows" | "components" | "mcp" }) => {
|
|||
const [pageIndex, setPageIndex] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(12);
|
||||
const [search, setSearch] = useState("");
|
||||
const navigate = useCustomNavigate();
|
||||
|
||||
const [flowType, setFlowType] = useState<"flows" | "components" | "mcp">(
|
||||
type,
|
||||
|
|
@ -42,6 +44,18 @@ const HomePage = ({ type }: { type: "flows" | "components" | "mcp" }) => {
|
|||
"";
|
||||
const flows = useFlowsManagerStore((state) => state.flows);
|
||||
|
||||
useEffect(() => {
|
||||
// Only check if we have a folderId and folders have loaded
|
||||
if (folderId && folders && folders.length > 0) {
|
||||
const folderExists = folders.find((folder) => folder.id === folderId);
|
||||
if (!folderExists) {
|
||||
// Folder doesn't exist for this user, redirect to /all
|
||||
console.error("Invalid folderId, redirecting to /all");
|
||||
navigate("/all");
|
||||
}
|
||||
}
|
||||
}, [folderId, folders, navigate]);
|
||||
|
||||
const { data: folderData, isLoading } = useGetFolderQuery({
|
||||
id: folderId ?? myCollectionId!,
|
||||
page: pageIndex,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue