"use client"; import * as React from "react"; import { Loader2 } from "lucide-react"; import { FormRenderer } from "@/components/forms/form-renderer"; import { Button } from "@/components/ui/button"; import type { ViewConfig } from "@/lib/hooks/use-view-data"; import { useWorkspaceStore } from "@/lib/stores/workspace-store"; import { api } from "@/lib/trpc"; import { cn } from "@/lib/utils"; export interface FormViewProps { config: ViewConfig; className?: string; } export function FormView({ config, className }: FormViewProps) { void config; const workspace = useWorkspaceStore((s) => s.currentWorkspace); const workspaceHandle = workspace?.slug ?? workspace?.id; const listQuery = api.forms.list.useQuery( { workspace: workspaceHandle! }, { enabled: Boolean(workspaceHandle) }, ); const [selectedId, setSelectedId] = React.useState(null); const forms = listQuery.data?.forms ?? []; if (!workspaceHandle) { return (
Select a workspace to use forms.
); } if (listQuery.isPending) { return (
Loading forms
); } if (listQuery.isError) { return (
Could not load forms for this workspace.
); } if (forms.length === 0) { return (
No forms in this workspace yet. Create a form to show it here.
); } return (
{selectedId ? ( ) : null}
{selectedId ? ( ) : (

Pick a form above to fill it out in this view.

)}
); }