SurfSense/surfsense_web/app/dashboard/searchspaces/page.tsx
DESKTOP-RTLN3BA\$punk 9c858a520d refactor: enhance onboarding experience
- Replaced the completion step component with a more streamlined onboarding page that includes action cards for managing teams, adding sources, and starting chats.
- Updated the search space form to make the description field optional and improved validation messages.
- Adjusted the onboarding logic to support auto-configuration of LLM roles and improved loading states.
- Removed unused imports and components to clean up the codebase.
2025-12-02 00:05:28 -08:00

59 lines
1.5 KiB
TypeScript

"use client";
import { motion } from "motion/react";
import { useRouter } from "next/navigation";
import { toast } from "sonner";
import { SearchSpaceForm } from "@/components/search-space-form";
export default function SearchSpacesPage() {
const router = useRouter();
const handleCreateSearchSpace = async (data: { name: string; description?: string }) => {
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/searchspaces`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${localStorage.getItem("surfsense_bearer_token")}`,
},
body: JSON.stringify({
name: data.name,
description: data.description || "",
}),
}
);
if (!response.ok) {
toast.error("Failed to create search space");
throw new Error("Failed to create search space");
}
const result = await response.json();
toast.success("Search space created successfully", {
description: `"${data.name}" has been created.`,
});
// Redirect to the newly created search space's onboarding
router.push(`/dashboard/${result.id}/onboard`);
return result;
} catch (error) {
console.error("Error creating search space:", error);
throw error;
}
};
return (
<motion.div
className="container mx-auto py-10"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.5 }}
>
<div className="mx-auto max-w-5xl">
<SearchSpaceForm onSubmit={handleCreateSearchSpace} />
</div>
</motion.div>
);
}