import { useMutation, useQueryClient, useSuspenseQuery, } from "@tanstack/react-query" import { createFileRoute, Navigate, useNavigate } from "@tanstack/react-router" import { Workflow } from "lucide-react" import { Suspense } from "react" import { FlowsService } from "@/client" import { flowKeys, flowsQueryOptions } from "@/components/Flow/queries" import { Button } from "@/components/ui/button" import { Skeleton } from "@/components/ui/skeleton" export const Route = createFileRoute("/_canvas/flows/")({ component: () => ( }> ), head: () => ({ meta: [{ title: "Flows - Fluksio" }] }), }) function Loading() { return (
) } function FlowsIndex() { const navigate = useNavigate() const queryClient = useQueryClient() const { data: flows } = useSuspenseQuery(flowsQueryOptions()) const create = useMutation({ mutationFn: () => FlowsService.saveFlow({ name: "my_first_flow", requestBody: { name: "my_first_flow", nodes: [], inputs: [] }, }), onSuccess: () => { queryClient.invalidateQueries({ queryKey: flowKeys.all }) navigate({ to: "/flows/$flowName", params: { flowName: "my_first_flow" }, }) }, }) // With flows around, open the first one rather than showing an empty page. if (flows.data.length > 0) { return ( ) } return (

No flows yet

A flow is a handful of nodes passing messages to each other. Start with one and add nodes as you go.

) }