import { useMutation, useQuery } from "@tanstack/react-query"; import { useState } from "react"; import { Loader2 } from "lucide-react"; import { DEFAULT_LOCATION_CODE } from "@/shared/keyword-locations"; import { LocationSelect } from "@/client/components/LocationSelect"; import { useSession } from "@/lib/auth-client"; import { saveOnboardingSite } from "@/serverFunctions/onboardingChat"; import { OnboardingAccountMenu } from "./OnboardingAccountMenu"; import { OnboardingChatConversation } from "./OnboardingChatConversation"; import { invalidateOnboardingChatState, onboardingChatStateQueryOptions, } from "./onboardingChatQueries"; // Full-viewport chat surface. Breaks out of the centered, padded AuthPageShell // with `fixed inset-0` so the chat fills the screen. There's no header bar — // the strategy's first message carries the context — and inner content is // constrained to a narrow column for comfortable reading width. function StrategyShell({ children }: { children: React.ReactNode }) { return (
{children}
); } export function OnboardingChat() { const stateQuery = useQuery(onboardingChatStateQueryOptions()); const { data: session } = useSession(); const accountMenu = ; if (stateQuery.isError) { return (
Couldn’t load your strategy. Please refresh to try again.
); } if (!stateQuery.data) { return (
Loading…
); } const { projectId, domain } = stateQuery.data; return ( {accountMenu} {!domain ? ( ) : ( )} ); } function SiteForm({ projectId }: { projectId: string }) { const [domain, setDomain] = useState(""); const [locationCode, setLocationCode] = useState(DEFAULT_LOCATION_CODE); const save = useMutation({ mutationFn: () => saveOnboardingSite({ data: { projectId, domain, locationCode } }), onSuccess: invalidateOnboardingChatState, }); return (
{ event.preventDefault(); if (domain.trim()) { save.mutate(); } }} >
CrawlerX

Tell us about your website.

If you have multiple websites, you can set that up later.

); }