2025-04-07 23:47:06 -07:00
|
|
|
"use client";
|
|
|
|
|
|
2025-12-12 07:51:00 +00:00
|
|
|
import { useAtomValue } from "jotai";
|
2025-09-30 20:27:34 -07:00
|
|
|
import { motion } from "motion/react";
|
2025-04-07 23:47:06 -07:00
|
|
|
import { useRouter } from "next/navigation";
|
2025-12-12 07:51:00 +00:00
|
|
|
import { createSearchSpaceMutationAtom } from "@/atoms/search-spaces/search-space-mutation.atoms";
|
2025-12-17 00:09:43 -08:00
|
|
|
import { SearchSpaceForm } from "@/components/search-space-form";
|
2025-12-25 13:53:41 -08:00
|
|
|
import { trackSearchSpaceCreated } from "@/lib/posthog/events";
|
2025-12-02 01:24:09 -08:00
|
|
|
|
2025-04-07 23:47:06 -07:00
|
|
|
export default function SearchSpacesPage() {
|
2025-07-27 10:05:37 -07:00
|
|
|
const router = useRouter();
|
2025-12-12 08:16:00 +00:00
|
|
|
const { mutateAsync: createSearchSpace } = useAtomValue(createSearchSpaceMutationAtom);
|
2025-04-07 23:47:06 -07:00
|
|
|
|
2025-12-12 07:51:00 +00:00
|
|
|
const handleCreateSearchSpace = async (data: { name: string; description?: string }) => {
|
2025-12-12 08:16:00 +00:00
|
|
|
const result = await createSearchSpace({
|
2025-12-12 07:51:00 +00:00
|
|
|
name: data.name,
|
|
|
|
|
description: data.description || "",
|
|
|
|
|
});
|
2025-07-27 10:05:37 -07:00
|
|
|
|
2025-12-25 13:53:41 -08:00
|
|
|
// Track search space creation
|
|
|
|
|
trackSearchSpaceCreated(result.id, data.name);
|
|
|
|
|
|
2025-12-12 07:51:00 +00:00
|
|
|
// Redirect to the newly created search space's onboarding
|
|
|
|
|
router.push(`/dashboard/${result.id}/onboard`);
|
2025-07-27 10:05:37 -07:00
|
|
|
|
2025-12-12 07:51:00 +00:00
|
|
|
return result;
|
2025-07-27 10:05:37 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
}
|